# Security model `plugin_fetch` makes **outbound HTTP requests on your node, to a URL somebody types or an agent chooses**. That is the entire feature, so it is also the entire risk. Everything here exists to answer one question: *what is this binary allowed to reach, and how do I know?* If you read only one line: **every address is validated before the socket is opened, the socket then connects to that validated numeric address, TLS is verified with no bypass, and nothing on your node can be reached unless you switch the policy on yourself.** ## One gate, every entry point A URL arriving from `--mcp`, from `?action=fetch`, or from the page's Fetch button runs the same code path. There is no "internal" fetch. The order is fixed: | # | Check | What it stops | |---|---|---| | 1 | **Scheme** — `http` / `https` only, absolute, no userinfo confusion | `file://`, `gopher://`, `dict://`, `http://x#@evil/` tricks | | 2 | **Resolve** — one `getaddrinfo()` for the hostname | — | | 3 | **Validate every returned address** against the denylist below | public hostname with a private A record, DNS that answers a second internal address | | 4 | **Connect to the validated numeric address**, not to the name | DNS rebinding between check and connect | | 5 | **Re-check on every redirect hop**, max 5 | 302 → `169.254.169.254`, relative `Location` escaping to an internal host | Step 4 is the one that matters. The common SSRF bug is "check the name, then connect by name" — the resolver is asked twice and can answer differently the second time. Here the checked address *is* the address passed to `connect()`. `--selftest` proves step 3 as pure policy: no DNS, no sockets, so the matrix holds on a machine with no network at all. ## The denylist Assembled from octet arrays in code (no dotted-quad literals sitting in a string where a scanner can find one), mirroring upstream `_NON_PUBLIC_NETWORKS` in `modelcontextprotocol/servers`. | Refused IPv4 | Role | |---|---| | `0/8` | this-network | | `10/8` | private | | `100.64/10` | CGNAT | | `127/8` | loopback | | `169.254/16` | link-local **and** every cloud metadata endpoint | | `172.16/12` | private | | `192/24` | IANA special (see the exception below) | | `192.0.2/24` | TEST-NET-1 | | `192.88.99/24` | 6to4 relay | | `192.168/16` | private | | `198.18/15` | benchmarking | | `198.51.100/24` | TEST-NET-2 | | `203.0.113/24` | TEST-NET-3 | | `224/4` | multicast (our own addition — upstream omits it) | | `240/4` | reserved | **Exception:** `192.0.0.9` and `192.0.0.10` — the anycast addresses upstream carves out of `192/24`. Blocks are written in prefix shorthand throughout (`10/8` rather than the full four-octet form) for the same reason the source assembles the octets in code: a dotted-quad of a private range in a text file is indistinguishable to a secret scanner from the thing the scanner exists to catch, and documentation should not have to look like a leak to be correct. **IPv6 refused:** `::/96` (unspecified, loopback, deprecated IPv4-compatible), IPv4-mapped `::ffff:a.b.c.d` **through the IPv4 list**, `64:ff9b:1::/48` (isolated NAT64), `100::/64` (discard), the whole `2001::/23` except its IANA carve-outs, `2001:db8::/32` (documentation), `2002::/16` (6to4), `3fff::/20`, `fc00::/7` (ULA), `fe80::/10` (link-local) and `fec0::/10` (deprecated site-local). **Carve-outs inside `2001::/23`, matching upstream:** `2001:1::/32`, `2001:2::/32` and `2001:3::/32` (TEREDO), `2001:4:112::/48` (AMP), `2001:20::/28` and `2001:30::/28` (ORCHIDv2). The well-known NAT64 prefix `64:ff9b::/96` is not refused outright — the embedded IPv4 is unwrapped and run through the IPv4 list, because "public v6 that tunnels to `169.254/16`" is exactly the bypass people forget. `fx_ip_is_denied()` is a single function with one job, and the test suite feeds it a named list of ~40 addresses and asserts each verdict, so a future edit that widens a mask fails instead of shipping. Address **text** is parsed here, not handed to `inet_aton`. Only the canonical dotted-quad form is accepted — digits, no sign, no leading zero on a multi-digit group, at most three digits per group, nothing after the fourth group. `0177.0.0.1`, `0x7f.0.0.1` and `1.2.3` are **refused**, never reinterpreted, because `inet_aton` would happily turn all three into loopback. Anything that fails to parse at all is denied, so a malformed address can never reach `connect()`. ## The private switch is an operator's, not a caller's `FETCH_ALLOW_PRIVATE=1` in the node's environment, or the policy toggle on the page, is what turns the denylist off. Both are off by default. - The toggle writes **one** file, `/config.json`, and is itself behind `require_node_auth()`. An agent cannot flip it through `--mcp` — no MCP tool touches it. - It is **off again** the moment you switch it back; there is no "sticky once set" path, and `?action=info` always reports the current value so the page cannot drift out of sync with the truth. - It exists for one legitimate reason: letting the test suite (and you) point the fetcher at a local service on purpose. ## TLS: verify, or refuse POSIX builds use **vendored mbedTLS 3.6.7** — no libcurl, no OpenSSL, nothing that can be silently swapped under the binary. - `MBEDTLS_SSL_VERIFY_REQUIRED`, always. There is no `FETCH_TLS_INSECURE`, no `verify=0`, no "skip on error" branch in the source, and the suite greps for one. - `mbedtls_ssl_set_hostname()` is called with the URL's host, so a valid certificate for the wrong name is refused (the suite proves it with a SAN mismatch). - Minimum version **TLS 1.2** (`mbedtls_ssl_conf_min_tls_version`). - Trust anchors: `FETCH_TLS_CA_FILE` if set, else the first readable system bundle (`/etc/ssl/certs/ca-certificates.crt`, `/etc/pki/tls/certs/ca-bundle.crt`, `/etc/ssl/ca-bundle.pem`, `/etc/ssl/cert.pem`, `/var/ssl/certs/ca-certificates.crt`). If none is readable the request **fails** with `no trust anchors`; a missing CA store is never a reason to skip verification. Windows builds use **WinHTTP**, which means the system root store, system revocation and system cipher policy — not a second implementation we have to keep correct. ## Limits that are not decoration | Limit | Value | Why | |---|---|---| | Body read | 5 MB (`FX_MAX_BODY`) | A declared `Content-Length` over the cap is refused **unread** — we do not start a 40 GB download to discover it is a lie | | Returned text | 100 000 chars | Keeps one tool result inside an agent's context budget | | Redirects | 5 (`FX_MAX_REDIRECTS`) | Chains end; a loop is caught, not followed | | Header block | 64 KB | A server that sends infinite headers is stopped, not buffered | | Connect / read | 10 s / 15 s | A stalled host cannot pin a CGI worker | | `Accept-Encoding` | `identity` unless built `-DHAVE_ZLIB` | gzip is only advertised when we can actually decode it | ## Every JSON action is authenticated `require_node_auth()` accepts `X-Bot-Password`, `Authorization: Bearer`, or `?pwd=`, and is checked before **any** `action=` — including `info` and `policy`. `--meta` and the page itself are exempt because they read nothing and fetch nothing: the page renders an empty form and does not issue a single request until you press Fetch. With `BOT_PASSWORD` unset the node has no password to demand, so the gate opens — the same convention every other plugin uses. ## What touches the disk One file: the policy file in the plugin's connector directory (`SX_CONNECTOR_DIR`, else `~/.scorpiox/connectors/fetch`, else a temp dir). It contains one boolean. Downloads are held in memory and freed; nothing is cached, nothing is logged, no request URL is persisted anywhere. ## The page Inline CSS and inline JS only — `