Skip to content

fix(jwt): reject repeated names at every depth with Json.unique.keys - #495

Merged
paymog merged 1 commit into
mainfrom
fix/jwt-unique-keys
Oct 19, 2026
Merged

paymog merged 1 commit into
mainfrom
fix/jwt-unique-keys

Conversation

@paymog

@paymog paymog commented Oct 19, 2026

Copy link
Copy Markdown
Owner

jwt checked repeated member names with its own dup, which looked only at the top level of the header and claims and compared every pair of names. This switches parse (header and claims), sign, and each JWK in jwks.parse to Json.unique.parsed, which checks decoded names in every nested object at O(n log n) per object (json 0.6.1.1, #482). dup is deleted.

Behaviour change: a token whose claims repeat a name inside a nested object, such as {"cnf":{"k":1,"k":2}}, now fails with Malformed before the signature is checked, and sign of such claims fails with BadClaim. RFC 7515 §5.2 allows rejecting repeated names. A JWK with a repeated name is still skipped on its own, so the rest of the set still loads.

Checks:

  • scripts/check.sh jwt passes, including the header_dup law and two new cases (verify and sign with a nested repeated name). On main, the verify case gives BadSig and the sign case succeeds.
  • jwt/jwks-check.sh passes.

jwt goes to 0.7.1.0; no package imports jwt.

Closes #494
Refs #481

@paymog
paymog merged commit bc0e388 into main Oct 19, 2026
4 checks passed
@paymog
paymog deleted the fix/jwt-unique-keys branch October 19, 2026 01:11
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.

jwt: check repeated names with Json.unique.keys

1 participant