Skip to content

fix(mpp): reject invalid credential header names - #147

Open
mehmetkr-31 wants to merge 1 commit into
tempoxyz:mainfrom
mehmetkr-31:fix/reject-invalid-credential-header
Open

fix(mpp): reject invalid credential header names#147
mehmetkr-31 wants to merge 1 commit into
tempoxyz:mainfrom
mehmetkr-31:fix/reject-invalid-credential-header

Conversation

@mehmetkr-31

Copy link
Copy Markdown

Problem

WithHeader normalizes the implicit Authorization default but does not validate custom HTTP field names. As a result, both NewChallengeWithError and GenerateChallengeIDWithError accept values such as "Payment Authorization" and bind them into a challenge ID. ToAuthenticateStrict also serializes the value, even though this SDK's own ParseChallenge rejects 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

  • Reuse the existing advertised-header parser in GenerateChallengeIDWithError, which also covers NewChallengeWithError.
  • Apply the same validation in strict challenge formatting so manually constructed Challenge values fail closed.
  • Add regression coverage for challenge creation, direct ID generation, and strict formatting.

The lenient FormatAuthenticate behavior is unchanged.

Cross-SDK check

  • Canonical mppx validates Challenge.header with the HTTP token regex in Challenge.Schema.
  • pympp validates the same field from Challenge.__post_init__ through advertised_credential_header.
  • mpp-rs does not yet expose the credential-header parameter, so it has no corresponding input surface.
  • mpp-go already applied this validation while parsing; this change closes the creation/formatting side of that internal mismatch.

Testing

The new creation and ID tests fail on main and pass with this change.

  • go mod verify
  • formatting check with gofmt -l .
  • go vet ./...
  • go build ./examples/...
  • go test -race -count=1 ./...

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

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