Skip to content

fix(proxy): forward whitelisted headers in WebSocket proxy upstream handshake (#865)#866

Merged
Issac-Newton merged 3 commits intoalibaba:masterfrom
Issac-Newton:fix/websocket-origin-proxy-spec
Apr 22, 2026
Merged

fix(proxy): forward whitelisted headers in WebSocket proxy upstream handshake (#865)#866
Issac-Newton merged 3 commits intoalibaba:masterfrom
Issac-Newton:fix/websocket-origin-proxy-spec

Conversation

@Issac-Newton
Copy link
Copy Markdown
Collaborator

Summary

  • Add whitelist-based header forwarding for WebSocket proxy upstream handshake
  • Forward Origin via websockets.connect(origin=...) and other whitelisted headers via additional_headers
  • Whitelist covers: Authorization, Cookie, X-Forwarded-*, X-Real-IP, X-Request-Id, Traceparent, Tracestate, EagleEye-*
  • Update spec docs (01_requirement.md, 03_implementation.md) with header forwarding design

fixes #865

Test plan

  • Unit tests: TestBuildUpstreamWsHeaders — pure function tests for header extraction/filtering (3 cases)
  • E2E tests: TestWebSocketHeaderForwardingE2E — real WebSocket server verifying headers arrive downstream (4 cases)
  • Existing test_websocket_proxy_subprotocol.py tests still pass (no regression)

🤖 Generated with Claude Code

Issac-Newton and others added 3 commits April 21, 2026 17:43
…andshake (alibaba#865)

WebSocket proxy was losing client Origin, Authorization, Cookie, and
tracing headers when initiating the second-hop handshake to downstream
services. Add whitelist-based header forwarding via build_upstream_ws_headers()
and pass origin=/additional_headers= to websockets.connect().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…s to rock/sandbox/utils/proxy.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… blacklist

Whitelist strategy blocked user-defined custom headers from reaching
downstream services. Blacklist strategy forwards all headers by default,
only filtering out WebSocket handshake headers and hop-by-hop headers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Issac-Newton Issac-Newton merged commit e5301c5 into alibaba:master Apr 22, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(proxy): WebSocket proxy loses Origin and auth headers during upstream handshake

2 participants