fix(proxy): forward whitelisted headers in WebSocket proxy upstream handshake (#865)#866
Merged
Issac-Newton merged 3 commits intoalibaba:masterfrom Apr 22, 2026
Conversation
…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>
StephenRi
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Originviawebsockets.connect(origin=...)and other whitelisted headers viaadditional_headersAuthorization,Cookie,X-Forwarded-*,X-Real-IP,X-Request-Id,Traceparent,Tracestate,EagleEye-*01_requirement.md,03_implementation.md) with header forwarding designfixes #865
Test plan
TestBuildUpstreamWsHeaders— pure function tests for header extraction/filtering (3 cases)TestWebSocketHeaderForwardingE2E— real WebSocket server verifying headers arrive downstream (4 cases)test_websocket_proxy_subprotocol.pytests still pass (no regression)🤖 Generated with Claude Code