Repository navigation
Conversation
When a proxy answers with a 401 on a CONNECT, ignore Authentication headers and fail the connect. Add test2173 to verify.
bagder
approved these changes
Sep 4, 2026
There was a problem hiding this comment.
🟢 Approval recommended
The changes are narrowly scoped to CONNECT tunnel auth handling, align with the stated goal, and include a focused regression test covering the reported behavior.
Pull request overview
This PR updates curl’s HTTP proxy tunnel handling so that a proxy returning 401 to a CONNECT is treated as a hard tunnel failure (i.e., curl no longer interprets WWW-Authenticate from that CONNECT response as an authentication challenge to act on). It also adds a regression test to ensure curl does not retry CONNECT with auth in this scenario.
Changes:
- Stop extracting/forwarding
WWW-Authenticatewhen inspecting CONNECT tunnel responses with status 401 (only handle proxy auth via 407 / Proxy-Authenticate). - Stop forwarding
WWW-Authenticateheaders from CONNECT response parsing in the HTTP/1 proxy CONNECT filter (only forwardProxy-authenticatefor 407). - Add
test2173and register it in the test suite to verify behavior when a proxy “tricks” curl with a 401 during CONNECT.
File summaries
| File | Description |
|---|---|
| tests/data/test2173 | Adds a new regression test ensuring a 401 on CONNECT does not trigger auth handling and results in a connect failure. |
| tests/data/Makefile.am | Registers test2173 in the testcases list. |
| lib/http_proxy.c | Removes 401-based WWW-Authenticate handling during CONNECT tunnel response inspection; keeps 407 proxy auth handling. |
| lib/cf-h1-proxy.c | Removes forwarding of WWW-Authenticate for 401 in CONNECT response header parsing; keeps forwarding of Proxy-authenticate for 407. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
When a proxy answers with a 401 on a CONNECT, ignore Authentication headers and fail the connect.
Add test2173 to verify.