Skip to content

HTTP-CONNECT: do not react to 401 responses - #22817

Closed
icing wants to merge 1 commit into
curl:masterfrom
icing:HTTP-CONNECT-401-ignore
Closed

icing wants to merge 1 commit into
curl:masterfrom
icing:HTTP-CONNECT-401-ignore

Conversation

@icing

@icing icing commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

When a proxy answers with a 401 on a CONNECT, ignore Authentication headers and fail the connect.

Add test2173 to verify.

When a proxy answers with a 401 on a CONNECT, ignore Authentication
headers and fail the connect.

Add test2173 to verify.
@github-actions github-actions Bot added the tests label Sep 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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-Authenticate when inspecting CONNECT tunnel responses with status 401 (only handle proxy auth via 407 / Proxy-Authenticate).
  • Stop forwarding WWW-Authenticate headers from CONNECT response parsing in the HTTP/1 proxy CONNECT filter (only forward Proxy-authenticate for 407).
  • Add test2173 and 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.

@bagder bagder closed this in 2956af6 Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants