Skip to content

gh-53089: Send uri="/" in Digest auth for URLs with an empty path - #161009

Merged
orsenthil merged 1 commit into
python:mainfrom
orsenthil:issues/53089
Oct 31, 2026
Merged

orsenthil merged 1 commit into
python:mainfrom
orsenthil:issues/53089

Conversation

@orsenthil

@orsenthil orsenthil commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

For a URL such as http://example.com, the request selector is empty. AbstractDigestAuthHandler.get_authorization() used it as-is, sending uri="" and hashing "GET:" whereas http.client sends "GET /" on the request line (see https://github.com/python/cpython/blob/main/Lib/http/client.py#L1248-L1250) , so servers rejected the request or failed the digest check.

This is an internal consistency within urllib and URI via http.client. This is long standing bug and should be fixed.

Normalize an empty selector to '/', as http.client does, for both the uri field and A2.

Also replace the long-standing "XXX selector: what about proxies and full urls" note with a comment explaining that the digest-uri is the request-target as sent (absolute-form through an HTTP proxy), which RFC 7616 allows, and add a test pinning that behavior.

For a URL such as http://example.com, the request selector is empty.
AbstractDigestAuthHandler.get_authorization() used it as-is, sending
uri="" and hashing "GET:" while http.client sends "GET /" on the
request line, so servers rejected the request or failed the digest
check.  Normalize an empty selector to '/', as http.client does, for
both the uri field and A2.

Also replace the long-standing "XXX selector: what about proxies and
full urls" note with a comment explaining that the digest-uri is the
request-target as sent (absolute-form through an HTTP proxy), which
RFC 7616 allows, and add a test pinning that behavior.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@orsenthil orsenthil added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 31, 2026
@orsenthil
orsenthil enabled auto-merge (squash) October 31, 2026 15:28
@orsenthil
orsenthil merged commit 663e99d into python:main Oct 31, 2026
59 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @orsenthil for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Oct 31, 2026

Copy link
Copy Markdown

GH-161013 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 31, 2026
@bedevere-app

bedevere-app Bot commented Oct 31, 2026

Copy link
Copy Markdown

GH-161014 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 31, 2026
orsenthil added a commit that referenced this pull request Oct 31, 2026
…ath (GH-161009) (#161014)

gh-53089: Send uri="/" in Digest auth for URLs with an empty path (GH-161009)

For a URL such as http://example.com, the request selector is empty.
AbstractDigestAuthHandler.get_authorization() used it as-is, sending
uri="" and hashing "GET:" while http.client sends "GET /" on the
request line, so servers rejected the request or failed the digest
check.  Normalize an empty selector to '/', as http.client does, for
both the uri field and A2.

Also replace the long-standing "XXX selector: what about proxies and
full urls" note with a comment explaining that the digest-uri is the
request-target as sent (absolute-form through an HTTP proxy), which
RFC 7616 allows, and add a test pinning that behavior.
(cherry picked from commit 663e99d)

Co-authored-by: Senthil Kumaran <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
orsenthil added a commit that referenced this pull request Oct 31, 2026
…ath (GH-161009) (#161013)

gh-53089: Send uri="/" in Digest auth for URLs with an empty path (GH-161009)

For a URL such as http://example.com, the request selector is empty.
AbstractDigestAuthHandler.get_authorization() used it as-is, sending
uri="" and hashing "GET:" while http.client sends "GET /" on the
request line, so servers rejected the request or failed the digest
check.  Normalize an empty selector to '/', as http.client does, for
both the uri field and A2.

Also replace the long-standing "XXX selector: what about proxies and
full urls" note with a comment explaining that the digest-uri is the
request-target as sent (absolute-form through an HTTP proxy), which
RFC 7616 allows, and add a test pinning that behavior.
(cherry picked from commit 663e99d)

Co-authored-by: Senthil Kumaran <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant