digest: escape control codes too#21915
Closed
bagder wants to merge 4 commits into
Closed
Conversation
Since the username is decoded when used and control codes are accepted in HTTP usernames in general, the username encoding for the Digest auth needs to percent encode such bytes. Verified by test 3221 Reported-by: Trail of Bits
There was a problem hiding this comment.
Pull request overview
This PR hardens HTTP Digest authentication header construction by ensuring decoded usernames containing control bytes are safely re-encoded when emitted in the Authorization: Digest ... header, preventing raw control characters from being placed into quoted-string fields.
Changes:
- Add percent-encoding for non-printable bytes when quoting Digest auth fields.
- Add new regression test covering CRLF in the URL username for Digest auth (
test3221). - Register the new test case in the test suite makefile.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
lib/vauth/digest.c |
Extends Digest quoted-string escaping to percent-encode additional bytes when building Authorization parameters. |
tests/data/test3221 |
New test verifying CRLF in decoded username is percent-encoded in Digest Authorization header. |
tests/data/Makefile.am |
Adds test3221 to the test case list so it runs in CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since the username is decoded when used and control codes are accepted in HTTP usernames in general, the username encoding for the Digest auth needs to percent encode such bytes.
Verified by test 3221
Reported-by: Trail of Bits