Skip to content

digest: flush proxy state on proxy or credential change#21951

Closed
alhudz wants to merge 2 commits into
curl:masterfrom
alhudz:digest-proxy-flush-state
Closed

digest: flush proxy state on proxy or credential change#21951
alhudz wants to merge 2 commits into
curl:masterfrom
alhudz:digest-proxy-flush-state

Conversation

@alhudz

@alhudz alhudz commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Repro: reuse one easy handle with CURLOPT_PROXYAUTH = CURLAUTH_DIGEST, drive a request through one digest proxy, then point CURLOPT_PROXY at a different proxy (or change CURLOPT_PROXYUSERPWD) and perform again.

Cause: Curl_output_digest() flushes data->state.digest when the host origin or credentials change, but the proxy branch reuses data->state.proxydigest unconditionally, so a stale nonce/nc/realm from the previous proxy is carried into the next Proxy-Authorization. 5c6b488 added the guard for the host branch only.

Fix: mirror that guard in the proxy branch, comparing the stored state against data->conn->http_proxy.peer and data->conn->http_proxy.creds and flushing on a mismatch.

Comment thread lib/http_digest.c Outdated
@bagder

bagder commented Jun 10, 2026

Copy link
Copy Markdown
Member

The proxy case is already handled differently, but I believe this take is the better and more robust take. It may however allow us to remove the other logic. See 5c22538, f59733b and c1cfdf5

@alhudz

alhudz commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Combined the two branches into a shared helper now. On removing the other logic: the setopt.c/url.c paths also reset data->state.authproxy (the picked mechanism), which this guard doesn't touch, so I left them in place here — the Curl_auth_digest_cleanup() calls there do look redundant with this in though. Verified locally: 1588, 1589 and 1686 pass with the combined helper, plus the full HTTP Digest auth keyword set (53/53). 1647 skips for me (no stunnel).

@bagder bagder left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

neat!

@bagder bagder closed this in 7ec2514 Jun 11, 2026
@bagder

bagder commented Jun 11, 2026

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants