Husk
GitHub

Security

Network policy and the internal-host floor

Three modes, the layer each is enforced at, and the floor that refuses loopback, link-local and RFC1918 even when the mode is full.

Network policy is declared per husk and defaults to egress.

computer:
  network:
    mode: egress
    allow: ['*.github.com', 'pypi.org']
    deny: ['telemetry.example.com']
ModeMeaning
noneNo egress at all
egressThe allow-list, and nothing else. An empty allow-list permits nothing
fullUnrestricted, minus explicit denies and minus the floor below

An egress policy with no allow list allows nothing. Reading an under-specified policy as "everything" is the interpretation that leaks data, so it is not the one Husk picks.

Networking is the feature page — pattern syntax, check order, what Husk itself talks to. This page is the security framing.

Where each mode is enforced

ModeDocker / PodmanHusk's tools and the browser's page loads
none--network=none, enforced by the kernelRefused
egressNot enforced. The container has normal networkingEnforced by hostname
fullNot enforced, by designEnforced only by the floor and by deny

Neither Docker nor Podman can allow-list hostnames, so egress is enforced where the hostname is actually known: in Husk's tools, and in the browser below them.

  • The tools. fetch_url and http_request check the URL, and each redirect hop before it is asked. So do browse, browser_goto, a new tab from browser_tabs, the goto steps of browser_run and the page.goto calls of browser_script.
  • The browser's page loads. The browser driver pauses every document a page loads by itself and checks it against the same policy before anything is sent: each hop of a redirect, a link, a script that sends the page somewhere, a frame and a pop-up's first load. Subresources are not checked: images, scripts and a page's own fetch calls are not documents. On ssh and fly, which start the driver once per call, a page's own loads are checked only while a call runs.

On local, ssh and fly there is no kernel enforcement at all, in any mode: mode: none there stops Husk's tools and the browser, and nothing else. A local machine shares your network.

The floor

isHostAllowed refuses link-local and RFC1918 hosts even in mode: full, unless the operator names them in allow. The check runs before the mode is consulted, so full cannot override it.

Loopback is refused the same way, with one exception besides allow: browse and the browser, which run in the computer, may reach 127.0.0.1 on Docker, Podman and Fly, where that address is the computer's own. fetch_url and http_request run on this machine, so to them loopback is always this machine's, and refused.

Why 169.254.169.254 is the reason

169.254.169.254 is the cloud instance metadata service. On AWS, GCP, Azure, Oracle and DigitalOcean it hands out instance identity, user-data, and — the part that matters — short-lived IAM credentials, to anything on the box that asks. No authentication. A single unauthenticated GET.

An agent that has been prompt-injected will ask. That is not hypothetical: server-side request forgery against the metadata endpoint is the single most productive move available to anyone who gets code or a URL into a cloud workload, and it is the mechanism behind several of the largest cloud breaches on record.

mode: full means the internet. It does not mean "and also the credential vending machine sitting on a link-local address inside my VPC".

Loopback and the private ranges are the same problem one hop further out: the host's own admin panels, an unauthenticated database on the Docker bridge, the router's web UI, the Kubernetes API on 10.x.

What is refused by default, in every mode

Nameslocalhost, *.localhost, *.local, *.internal, metadata.google.internal
IPv6::1, ::, fe80:* (link-local), fc* / fd* (unique-local)
IPv40.0.0.0/8, 10.0.0.0/8, 127.0.0.0/8, 169.254.0.0/16, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10 (CGNAT)
error network policy refuses 169.254.169.254
hint:  link-local and RFC1918 hosts must be named in computer.network.allow

Redirects are followed one hop at a time, and each hop's URL is checked before it is requested. A 302 to http://169.254.169.254/ is refused without asking that address anything, and a public → internal → public chain stops at the internal hop. A hop to another origin drops Authorization, Cookie and Proxy-Authorization, and more than ten hops is an error.

Opening one deliberately

computer:
  network:
    mode: egress
    allow: ['192.168.1.50']

Explicit beats implicit, and the decision is now in the file where a reviewer can see it and a diff can catch it.

What the floor does not catch

The floor reads the host as written, decoded: http://2130706433/ (127.0.0.1 as one number), octal and hex forms, and IPv4-mapped IPv6 such as ::ffff:127.0.0.1 are all read as the addresses they are, and refused. There is no DNS resolution before the request, though, so:

  • DNS rebinding. A public name that resolves to 169.254.169.254 passes the check. This is the classic bypass and Husk does not stop it.
  • allow: ['*']. A * entry satisfies the explicit-allow test and therefore reopens the entire private range. Do not write it and expect the floor to hold.
  • Anything that is not one of Husk's tools or a page's document. web_search talks to Tavily or Brave directly and is not filtered by the husk's policy. Neither is curl in a shell, nor a page's images, scripts and fetch calls.

If you are running an agent on a cloud instance with an instance profile attached, the floor is a speed bump, not a boundary. Remove the instance profile, or use IMDSv2 with a hop limit of 1 and run the agent in a container, or both.

One implementation

The floor is isInternalHost in @husk-ai/core, and nothing else. @husk-ai/runtime and @husk-ai/agent re-export it (the agent's under its old name, isPrivateHost), so a host refused in one place is refused everywhere. There used to be a second copy in the agent, and the two had drifted: it let the metadata endpoint through as an IPv4-mapped address after core had learned to refuse it.

Protocols

fetch_url and http_request accept http: and https: only.

error refusing the file: scheme
hint:  only http and https are fetched; file:// would read the host filesystem

file:, ftp:, data: and gopher: are refused with E_EXEC_DENIED. http_request additionally strips a set of blocked request headers before sending.

Order of checks

For both network tools, in this order:

  1. The URL parses. Otherwise E_EXEC_DENIED, not a valid URL.
  2. The scheme is http: or https:. Otherwise E_EXEC_DENIED, refusing the <scheme> scheme.
  3. The private-address floor, unless the host is named in allow.
  4. deny, then mode — isHostAllowed.

A refusal at 3 or 4 is E_EXEC_DENIED, network policy refuses <host>.

Then the whole sequence again on each redirect's target, before it is requested.