Public: anyone can read this; the crew can change it.

A stranger's outbound private-address fetch is refused and tested at every fetch in src/http #15606

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

This adds a table-driven test, test/outbound-guard.test.ts, that runs every fetch site taking a person-supplied URL through every private address class. A site that bypasses the one guard fails its rows. No production code changes.

Notes

shipped production is serving it deploy 3fede26

opened this

This adds a table-driven test, test/outbound-guard.test.ts, that runs every fetch site taking a person-supplied URL through every private address class. A site that bypasses the one guard fails its rows. No production code changes.

The guard the issue asks for already exists. src/kernel/outbound.ts resolves the name, refuses if any answer is private, connects to the address it checked, and never follows a redirect. I did not add a second src/core/guard module, because a duplicate would have to be kept in step with this one.

None of the fetches in src/http/ take a URL from a request. They reach the forge's own socket, its own loopback port, or the parent issuer from configuration, and test/outbound-sweep.test.ts already lists each one with its reason. So none of them is a row; people's URLs reach the guard through the modules listed below.

What the test checks

  • Sites: webhook delivery, the notify URL, the parity probe, originFetch (which also covers origins/oauth.ts and origins/providers/http.ts), origin discovery, lineage lookup, the gateway door, the certificate probe, pack sources (source_guard and sourceOf), the git mirror and migrate's vetClone.
  • Address classes:
    • IPv4: loopback, unspecified, the three private ranges, 100.64/10, link-local and the metadata address.
    • IPv6 and wrapped forms: ::1, fe80::, fd00::, and the metadata address as IPv4-mapped and as NAT64.
  • Forms: each class is tried as a literal, and as a DNS answer where the site can be given a test resolver. Notify, the parity probe, originFetch and sourceOf can't, so only literals are tried there; for names they rely on the guard's own test. A name whose answers mix a public and a private address is also refused.
  • How a bypass shows: fetch is replaced for the whole file and connects to nothing. A site that skipped the guard would pass the private URL to it, and the recorded list fails the row.
  • Controls: each fetching site gets one public-host check, which proves the row really reaches fetch. The public host answers with a 302 to the metadata address, and the test checks it is never followed. Discovery follows redirects itself and checks each hop with the guard, so its control ends refused without ever contacting the metadata address.
  • New sites: the last test fails when a file in src calls the guard without having a row in the table.

To confirm the test catches a bypass, I temporarily switched the webhook and notify calls to a bare fetch: 28 rows went red. I reverted that before committing.

docs/SECURITY-RUNBOOK.md gains a section, "Someone points the forge at an internal address". It says what is refused and where, what a person sees, how an admin trusts an origin on their own network by name (/settings/origins; webhooks and notify URLs never get that trust), and which test checks all of this.

Egress declarations, the release workflow and the chart are untouched.

Checks run: bun scripts/gate.ts --fix (it rewrapped comments in the new test, which is committed) and bun x tsc --noEmit are clean. scripts/fast.ts named 3292 test files because docs are read repo-wide, so I ran the covering files instead: outbound-guard, outbound-sweep, outbound, shield, docs-index, docs-link, flake and webhooks. 323 pass, 0 fail.

The issue asks for keep_plan and estimate calls, but neither tool is available in this session, so no plan or estimate was recorded.

Try it: bun test test/outbound-guard.test.ts

🤖 Generated with Claude Code

Closes #15596

commented

This adds a table-driven test, test/outbound-guard.test.ts, that runs every fetch site taking a person-supplied URL through every private address class. A site that bypasses the one guard fails its rows. No production code changes.

The guard the issue asks for already exists. src/kernel/outbound.ts resolves the name, refuses if any answer is private, connects to the address it checked, and never follows a redirect. I did not add a second src/core/guard module, because a duplicate would have to be kept in step with this one.

None of the fetches in src/http/ take a URL from a request. They reach the forge's own socket, its own loopback port, or the parent issuer from configuration, and test/outbound-sweep.test.ts already lists each one with its reason. So none of them is a row; people's URLs reach the guard through the modules listed below.

What the test checks

  • Sites: webhook delivery, the notify URL, the parity probe, originFetch (which also covers origins/oauth.ts and origins/providers/http.ts), origin discovery, lineage lookup, the gateway door, the certificate probe, pack sources (source_guard and sourceOf), the git mirror and migrate's vetClone.
  • Address classes:
    • IPv4: loopback, unspecified, the three private ranges, 100.64/10, link-local and the metadata address.
    • IPv6 and wrapped forms: ::1, fe80::, fd00::, and the metadata address as IPv4-mapped and as NAT64.
  • Forms: each class is tried as a literal, and as a DNS answer where the site can be given a test resolver. Notify, the parity probe, originFetch and sourceOf can't, so only literals are tried there; for names they rely on the guard's own test. A name whose answers mix a public and a private address is also refused.
  • How a bypass shows: fetch is replaced for the whole file and connects to nothing. A site that skipped the guard would pass the private URL to it, and the recorded list fails the row.
  • Controls: each fetching site gets one public-host check, which proves the row really reaches fetch. The public host answers with a 302 to the metadata address, and the test checks it is never followed. Discovery follows redirects itself and checks each hop with the guard, so its control ends refused without ever contacting the metadata address.
  • New sites: the last test fails when a file in src calls the guard without having a row in the table.

To confirm the test catches a bypass, I temporarily switched the webhook and notify calls to a bare fetch: 28 rows went red. I reverted that before committing.

docs/SECURITY-RUNBOOK.md gains a section, "Someone points the forge at an internal address". It says what is refused and where, what a person sees, how an admin trusts an origin on their own network by name (/settings/origins; webhooks and notify URLs never get that trust), and which test checks all of this.

Egress declarations, the release workflow and the chart are untouched.

Checks run: bun scripts/gate.ts --fix (it rewrapped comments in the new test, which is committed) and bun x tsc --noEmit are clean. scripts/fast.ts named 3292 test files because docs are read repo-wide, so I ran the covering files instead: outbound-guard, outbound-sweep, outbound, shield, docs-index, docs-link, flake and webhooks. 323 pass, 0 fail.

The issue asks for keep_plan and estimate calls, but neither tool is available in this session, so no plan or estimate was recorded.

Try it: bun test test/outbound-guard.test.ts

🤖 Generated with Claude Code

Approved

Approved. A test-only change that holds every person-supplied fetch site to the one guard. It adds no dependency, no production code, and nothing to README. The runbook section is the right place for the how-to. I read the diff and could not run the new file here (the clone is at base), so I am relying on the reported 323 passing and the 28 red rows from the temporary bypass. Two things I would do next: (1) drop the per-site 'the member is not an admin' test, which repeats the same assertion 12 times and belongs once in beforeAll; (2) give the sites that have no resolver seam (notify, parity probe, originFetch, sourceOf) one, so name-based answers are tested there too instead of leaning on the guard's own test.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs