Harden CONNECT header handling against injection and spoofing - #24
Merged
Conversation
Reject CR/LF/NUL in outbound proxy CONNECT headers and copy only X-ProxyMesh-* CONNECT response headers onto origin responses without overwriting existing origin values. Co-authored-by: ProxyMesh AI <proxymeshai@users.noreply.github.com>
proxymesh
marked this pull request as ready for review
September 1, 2026 17:22
Drop the ProxyMesh-only allowlist. Copy any CONNECT response header that is not hop-by-hop or security-sensitive, and never overwrite origin values. Pin GitHub Actions to commit SHAs. Co-authored-by: ProxyMesh AI <proxymeshai@users.noreply.github.com>
proxymesh
approved these changes
Sep 1, 2026
Merged
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.


Reject CR/LF/NUL in outbound proxy CONNECT headers, and stop copying arbitrary CONNECT response headers onto origin HTTPS responses.
Outbound:
proxy_headersnames and values are validated before they are written into CONNECT (urllib3/requests/cloudscraper/autoscraper and pycurl). httpx and aiohttp already rejected control characters.Inbound: Only
X-ProxyMesh-*CONNECT headers are merged intoresponse.headers, and they never overwrite an origin header. Sensitive headers such asSet-Cookie,Location, andContent-Typeare not copied. The full CONNECT set is available onresponse.proxy_headers.Adds
test_header_security.pyand a CI unit-test job that does not needPROXY_URL.