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

A cell child never receives the edge token or x-plat-* headers: forward and forwardSocket strip them #15236

Merged opened this

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

Merged

A cell child no longer receives the forge's x-plat- headers, including the edge token and x-plat-user. Before, forward() and forwardSocket() in src/spawn/cell.ts passed them through to the child. The visitor's authorization and cookies still reach the child, so signing in on a child forge keeps working.

Notes

shipped production is serving it deploy cfe12e4

opened this

A cell child no longer receives the forge's x-plat-* headers, including the edge token and x-plat-user. Before, forward() and forwardSocket() in src/spawn/cell.ts passed them through to the child. The visitor's authorization and cookies still reach the child, so signing in on a child forge keeps working.

I could not carry mason's code over. The fork commit 3c866cdb6 from pull #14938 could not be fetched from here. So I wrote the change myself from the issue's spec on today's main instead of copying it. The commit still credits mason with Co-authored-by. A reviewer who can open #14938 should compare the two.

  • Code: both functions now build their headers through two plain functions, forwardHeaders (plain requests) and socketHeaders (websocket handshakes). Both drop every header starting with x-plat-, the same rule stripForgeCredentials in src/apps/proxy.ts uses. Unlike that function, they leave authorization and cookies alone. Everything else they already removed or rewrote is unchanged: hop-by-hop headers, the forwarded host and scheme, the client-address headers and the visitor's sec-websocket-* headers.
  • Tests: test/spawn-cell.test.ts sends requests carrying x-plat-edge-token, x-plat-user, authorization and a cookie.
    • The plain-request test goes through forward() to a real loopback server.
    • The websocket test checks the output of socketHeaders. It does not open a socket through forwardSocket().
    • In both, the child sees neither x-plat-* header and does get the sign-in headers. With the stripping turned off, both tests fail.
  • Threats doc: the new row went in docs/threats/child-forge.md, not directly in docs/THREATS.md. THREATS.md is now assembled from the files in docs/threats/, and this is the child-forge section. The row names test/spawn-cell.test.ts.

Checks: scripts/gate.ts --fix changed nothing and bun x tsc --noEmit passes. scripts/fast.ts said the change reaches 3227 test files, too many to run here. So I ran the two that cover it, test/spawn-cell.test.ts and test/threats-enforced.test.ts: 48 pass, 0 fail. One test was skipped because this sandbox cannot run cells; the forge's check runs it.

I did not update the plan on the issue: the keep_plan and estimate tools were not available in this run.

🤖 Generated with Claude Code

Closes #15234

commented

A cell child no longer receives the forge's x-plat-* headers, including the edge token and x-plat-user. Before, forward() and forwardSocket() in src/spawn/cell.ts passed them through to the child. The visitor's authorization and cookies still reach the child, so signing in on a child forge keeps working.

I could not carry mason's code over. The fork commit 3c866cdb6 from pull #14938 could not be fetched from here. So I wrote the change myself from the issue's spec on today's main instead of copying it. The commit still credits mason with Co-authored-by. A reviewer who can open #14938 should compare the two.

  • Code: both functions now build their headers through two plain functions, forwardHeaders (plain requests) and socketHeaders (websocket handshakes). Both drop every header starting with x-plat-, the same rule stripForgeCredentials in src/apps/proxy.ts uses. Unlike that function, they leave authorization and cookies alone. Everything else they already removed or rewrote is unchanged: hop-by-hop headers, the forwarded host and scheme, the client-address headers and the visitor's sec-websocket-* headers.
  • Tests: test/spawn-cell.test.ts sends requests carrying x-plat-edge-token, x-plat-user, authorization and a cookie.
    • The plain-request test goes through forward() to a real loopback server.
    • The websocket test checks the output of socketHeaders. It does not open a socket through forwardSocket().
    • In both, the child sees neither x-plat-* header and does get the sign-in headers. With the stripping turned off, both tests fail.
  • Threats doc: the new row went in docs/threats/child-forge.md, not directly in docs/THREATS.md. THREATS.md is now assembled from the files in docs/threats/, and this is the child-forge section. The row names test/spawn-cell.test.ts.

Checks: scripts/gate.ts --fix changed nothing and bun x tsc --noEmit passes. scripts/fast.ts said the change reaches 3227 test files, too many to run here. So I ran the two that cover it, test/spawn-cell.test.ts and test/threats-enforced.test.ts: 48 pass, 0 fail. One test was skipped because this sandbox cannot run cells; the forge's check runs it.

I did not update the plan on the issue: the keep_plan and estimate tools were not available in this run.

🤖 Generated with Claude Code

Approved

Both builders strip every x-plat-* header and leave authorization and cookies. Hop-by-hop, forwarded-host, client-address and sec-websocket handling is unchanged. The plain-request test goes through forward() to a real server. The two things I would do next: (1) have the websocket test drive forwardSocket against a loopback upstream, since it now only checks socketHeaders, so a future call site that skips the helper would not be caught; (2) make stripForgeCredentials in apps/proxy.ts and forgeOnly share one predicate so the rule lives in one place. I opened the preview: / answers 200 with 15.5 KB of server-rendered HTML and the viewport meta; the change adds no page, so nothing visual moved.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs