fix(mpp): reject invalid credential header names - #147
Open
mehmetkr-31 wants to merge 1 commit into
Open
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Problem
WithHeadernormalizes the implicitAuthorizationdefault but does not validate custom HTTP field names. As a result, bothNewChallengeWithErrorandGenerateChallengeIDWithErroraccept values such as"Payment Authorization"and bind them into a challenge ID.ToAuthenticateStrictalso serializes the value, even though this SDK's ownParseChallengerejects the resulting challenge as an invalid HTTP header name.That leaves the public challenge APIs able to produce an HMAC-bound challenge that cannot complete a serialize/parse round trip.
Fix
GenerateChallengeIDWithError, which also coversNewChallengeWithError.Challengevalues fail closed.The lenient
FormatAuthenticatebehavior is unchanged.Cross-SDK check
Challenge.headerwith the HTTP token regex inChallenge.Schema.Challenge.__post_init__throughadvertised_credential_header.Testing
The new creation and ID tests fail on
mainand pass with this change.go mod verifygofmt -l .go vet ./...go build ./examples/...go test -race -count=1 ./...