Skip to content

Raise ProtocolError on malformed Digest auth challenges - #3856

Open
Ganesh1729-ui wants to merge 1 commit into
encode:masterfrom
Ganesh1729-ui:fix-digest-auth-malformed-challenge
Open

Ganesh1729-ui wants to merge 1 commit into
encode:masterfrom
Ganesh1729-ui:fix-digest-auth-malformed-challenge

Conversation

@Ganesh1729-ui

Copy link
Copy Markdown

I noticed that when a server returns a malformed Digest WWW-Authenticate challenge without an equals sign or with an unsupported algorithm, DigestAuth raises an unhandled ValueError or KeyError instead of ProtocolError.

This happened because the header field splitting was outside the try block, and the algorithm wasn't validated against the supported hash functions before lookup in _build_auth_header. I moved the field parsing inside the try block to catch ValueError, and added an algorithm check in _parse_challenge to raise ProtocolError consistently. I also added test cases covering both malformed fields and unsupported algorithms for sync and async clients.

This branch has not been deployed

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants