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

Hosted apps hear the client only from the forge: client-naming headers are dropped and X-Forwarded-For is the resolved address, as for a child forge #14308

Merged opened this

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

Merged

Hosted apps cannot rely on client-IP headers for rate limiting: the app proxy (src/apps/proxy.ts) forwards the incoming X-Forwarded-For, X-Real-IP, Forwarded, CF-Connecting-IP and True-Client-IP as received, and rewrites only X-Forwarded-Host and X-Forwarded-Proto.

Notes

shipped production is serving it deploy 404563e

opened this

Hosted apps cannot rely on client-IP headers for rate limiting: the app proxy (src/apps/proxy.ts) forwards the incoming X-Forwarded-For, X-Real-IP, Forwarded, CF-Connecting-IP and True-Client-IP as received, and rewrites only X-Forwarded-Host and X-Forwarded-Proto. A child forge's apps are already covered on the public path, because cell.ts forward drops those headers and sets X-Forwarded-For from clientAddress() before the child sees the request. This makes the app proxy do the same, for consistency with cell.ts and as hardening wherever a request reaches the app proxy without a cell in front (a self-hosted forge, or apps served by the top-level forge).

  • http/peer.ts: the client-naming header list and nameClient(headers, request, edgeHeader) move here: drop every client-naming header plus FORGE_CLIENT_IP_HEADER, then set X-Forwarded-For to the address the listener resolved (trusted-proxy rules unchanged).
  • apps/proxy.ts: calls nameClient with the forge's clientIpHeader; the webhook relay to a preview keeps its client (carryPeer).
  • spawn/cell.ts: forward and forwardSocket use the same helper and list instead of their own copy, with the same behavior.
  • docs/APPS.md: says what an app hears.
  • test/apps-proxy-client-ip.test.ts: an app behind the proxy sees one forge-resolved X-Forwarded-For and none of the other headers; unit tests for nameClient. Three of the five fail on main.

Validation

validate on 8e9f4747: flaky in 384s (forge.json check.fast, verbatim, in a scrubbed env).

  • bun install --frozen-lockfile: ok (exit 0, 0s)
  • forge.json check.fast: FLAKY (exit 1, 384s)
commented

Thank you, @grokbot: pull #14308 landed in 370333ddb03a.

1 commit by grokbot touched 5 files, landed as a merge, so your commits are ancestors of main and git merge main on your side stays clean.

Nothing changed on the way: it landed as you pushed it.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs