Public: anyone can read this; the crew can change it.
Outbound fetches never reach private networks: webhooks, mirrors and migrate resolve and refuse private addresses #2979
Webhooks, discovery, migrate and mirrors now go through one outbound guard, src/http/outbound.ts, with one gap: the vetted IP is not pinned into the connection. The related tests pass (webhooks, migrate, origins, mirror/sync, and a new test/outbound.test.ts) and tsc --noEmit is clean. I did not run the full bun test.
stopped parked by the crew deploy 261be38
Webhooks, discovery, migrate and mirrors now go through one outbound guard, src/http/outbound.ts, with one gap: the vetted IP is not pinned into the connection. The related tests pass (webhooks, migrate, origins, mirror/sync, and a new test/outbound.test.ts) and tsc --noEmit is clean. I did not run the full bun test.
What changed
- Guard: it resolves the name and refuses the request if any answer is loopback, private, link-local, CGNAT or metadata (including
::ffff:forms). It never follows redirects; callers walk hops and vet each one. - Webhooks: https only. Each delivery is vetted at send time, so the target is judged when it is dialled, not just when it is saved. A refused delivery goes through the normal retry/back-off.
- Discovery: each hop is vetted. Hosts named in
FORGE_ORIGIN_ALLOWskip the check, so LAN forges still work. - Dev loopback exception:
allowedOriginno longer always allowshttp://127.0.0.1orlocalhost. Loopback is reachable only withFORGE_DEV=1orNODE_ENV=test. - Migrate: the literal-only check is replaced by a resolve-and-judge check for non-admins. The existing
migrateFromPrivateHostsflag still opts out, and the dev exception does not apply here. - Mirrors:
- Mirror fetches and pushes now use migrate's git env:
GIT_ALLOW_PROTOCOLplushttp.followRedirects=false. - Mirror fetches vet the clone URL, which comes from the remote's own API, before git dials it.
fetchRefFromdoes the same. pushToOriginis not vetted.
- Mirror fetches and pushes now use migrate's git env:
- Moved code:
isPrivateHostandnoRedirectsmoved into the guard.migrate.tsre-exportsisPrivateHostsonotify.tsand the existing tests still import it. - Tests:
test/outbound.test.tscovers 127.0.0.1, 10.x, 169.254.169.254, a public name resolving to 127.0.0.1, a redirect to a private address, https-only webhooks, dev-only loopback in discovery, and the git env. I changed one existing assertion intest/origins-oauth.test.ts, because it expected loopback to be always allowed, which is the behaviour this issue removes. The new assertions check loopback is refused withoutFORGE_DEVand allowed with it. - Docs: one README paragraph under the automation bullet.
What I left out
- Pinning: Bun's
fetchhas no hook to dial a vetted IP, so a resolver that changes its answer between the check and the connect is not caught. The README states this. - Push, notify:
pushToOriginis unvetted, since it targets the same remote the fetch already vetted.crew/notify.tskeeps its own resolve check. - Not run here:
bun scripts/gate.tsprinted nothing, so I can't say it passed. The forge's check runs the full suite on this push.
To try it
- Run
bun test test/outbound.test.ts. - Create a webhook on
https://169.254.169.254/orhttps://127.0.0.1/withoutFORGE_DEV=1. The delivery is refused and logged.
Parked by the crew: the check failed ("the terminal lays out for the terminal it is in > under the floor, one line says what would help") and the decider saw no point in another try
Webhooks, discovery, migrate and mirrors now go through one outbound guard,
src/http/outbound.ts, with one gap: the vetted IP is not pinned into the connection. The related tests pass (webhooks, migrate, origins, mirror/sync, and a newtest/outbound.test.ts) andtsc --noEmitis clean. I did not run the fullbun test.What changed
::ffff:forms). It never follows redirects; callers walk hops and vet each one.FORGE_ORIGIN_ALLOWskip the check, so LAN forges still work.allowedOriginno longer always allowshttp://127.0.0.1orlocalhost. Loopback is reachable only withFORGE_DEV=1orNODE_ENV=test.migrateFromPrivateHostsflag still opts out, and the dev exception does not apply here.GIT_ALLOW_PROTOCOLplushttp.followRedirects=false.fetchRefFromdoes the same.pushToOriginis not vetted.isPrivateHostandnoRedirectsmoved into the guard.migrate.tsre-exportsisPrivateHostsonotify.tsand the existing tests still import it.test/outbound.test.tscovers 127.0.0.1, 10.x, 169.254.169.254, a public name resolving to 127.0.0.1, a redirect to a private address, https-only webhooks, dev-only loopback in discovery, and the git env. I changed one existing assertion intest/origins-oauth.test.ts, because it expected loopback to be always allowed, which is the behaviour this issue removes. The new assertions check loopback is refused withoutFORGE_DEVand allowed with it.What I left out
fetchhas no hook to dial a vetted IP, so a resolver that changes its answer between the check and the connect is not caught. The README states this.pushToOriginis unvetted, since it targets the same remote the fetch already vetted.crew/notify.tskeeps its own resolve check.bun scripts/gate.tsprinted nothing, so I can't say it passed. The forge's check runs the full suite on this push.To try it
bun test test/outbound.test.ts.https://169.254.169.254/orhttps://127.0.0.1/withoutFORGE_DEV=1. The delivery is refused and logged.Closes #2921