Skip to content

fix(auth): pin JWT validation algorithms to an allowlist#148

Open
SVilgelm wants to merge 1 commit into
rust-mcp-stack:mainfrom
SVilgelm:fix/jwt-pin-algorithms
Open

fix(auth): pin JWT validation algorithms to an allowlist#148
SVilgelm wants to merge 1 commit into
rust-mcp-stack:mainfrom
SVilgelm:fix/jwt-pin-algorithms

Conversation

@SVilgelm
Copy link
Copy Markdown
Contributor

📌 Summary

The JWKS verifier selected the validation algorithm from the token's own header, which lets an attacker choose alg (RS256 → HS256 algorithm confusion). The verifier now rejects any token whose header advertises an algorithm outside an asymmetric-only allowlist before key lookup.

🔍 Related Issues

✨ Changes Made

  • Add default_jwks_algorithms() (asymmetric only, no HS*) and re-export Algorithm.
  • JsonWebKeySet::verify now takes an allowed-algorithms slice and rejects disallowed alg.
  • GenericOauthTokenVerifier passes the default allowlist; unit tests cover HMAC rejection.

Reject tokens whose header advertises an algorithm outside an asymmetric-only allowlist, preventing RS256->HS256 confusion.

Assisted-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Sergey Vilgelm <sergey@vilgelm.com>
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