Skip to content

fix(mpp): match auth-param names case-insensitively - #121

Open
memosr wants to merge 1 commit into
tempoxyz:mainfrom
memosr:fix/case-insensitive-auth-param-names
Open

fix(mpp): match auth-param names case-insensitively#121
memosr wants to merge 1 commit into
tempoxyz:mainfrom
memosr:fix/case-insensitive-auth-param-names

Conversation

@memosr

@memosr memosr commented Aug 16, 2026

Copy link
Copy Markdown

parseAuthParams keys the params map on the raw name token, so RFC 9110 §11.2 — which its own doc comment cites — is never applied:

Authentication parameters are name/value pairs, where the name token is matched case-insensitively, and each parameter name MUST only occur once per challenge.

Two consequences:

  • A fully valid mixed-case challenge is rejected with missing required challenge fields.
  • A duplicate hidden by case slips past the duplicate guard. Payment id="a", ID="b", ... parses and silently yields a, while a peer that normalizes names reads b.

The asymmetry sits inside one function: ParseChallenge already applies §11.1 with strings.EqualFold(scheme, "Payment"), then hands the rest to a parser that compares names byte for byte. The conformance suite pins both halves of the rule, case_insensitive_scheme for the scheme and error_duplicate_parameters for duplicate names; mpp-go passes both literally while the duplicate guard stays bypassable.

Only the name token is lowercased. Values are left verbatim so challenge IDs and base64url payloads keep their case, and uppercase method value is still rejected guards that boundary: lowercasing the whole pair would turn METHOD="Tempo" into a valid method name.

Written test first. Seven of the eight subtests fail against the current parser; duplicate name in the same case is still rejected passes before and after as a regression guard.

parseAuthParams keyed the params map on the raw auth-param name, so the
RFC 9110 §11.2 rule its own doc comment cites was never applied. A fully
valid mixed-case challenge was rejected with "missing required challenge
fields", and a duplicate hidden by case (id="a", ID="b") slipped past the
duplicate guard, silently yielding "a" while a normalizing peer reads "b".

Lowercase the name token only. Values are left verbatim, so case-sensitive
data such as challenge IDs and base64url payloads is preserved, and the
unescaped-quote tolerance now keys off the normalized "description" name.
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