urllib.request.HTTPDigestAuthHandler crashes on a malformed WWW-Authenticate digest challenge
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug description:
urllib.request.AbstractDigestAuthHandler.retry_http_digest_auth parses a
server-controlled WWW-Authenticate: Digest ... challenge without guarding the
parse, so a malformed challenge raises a bare ValueError or IndexError out
of urlopen() instead of being declined:
import urllib.request
h = urllib.request.HTTPDigestAuthHandler(None)
req = urllib.request.Request("http://example.invalid/")
h.retry_http_digest_auth(req, "Digest realm") # ValueError
h.retry_http_digest_auth(req, "Digest realm=") # IndexError
h.retry_http_digest_auth(req, "Digest") # ValueError
Digest realm / Digest realm= fail in parse_keqv_list; Digest fails in
auth.split(' ', 1). The handler should decline a challenge it cannot
parse (return None), as it already does for a 40x it cannot handle.
CPython versions tested on:
3.12, 3.13, 3.14, 3.15
Operating systems tested on:
macOS
Linked PRs
- gh-153793
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at urllib.request.AbstractDigestAuthHandler.retry_http_digest_auth and reproduce the three malformed WWW-Authenticate challenges shown in the issue. Done means malformed Digest challenges return None instead of raising ValueError or IndexError; linked PR gh-153793 indicates work is already underway.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100