Skip to content

Sign the forged token of the key confusion test without JWT.encode - #725

Merged
koic merged 1 commit into
modelcontextprotocol:mainfrom
koic:sign_the_forged_token_of_the_key_confusion_test_without_jwt_encode
Nov 28, 2026
Merged

koic merged 1 commit into
modelcontextprotocol:mainfrom
koic:sign_the_forged_token_of_the_key_confusion_test_without_jwt_encode

Conversation

@koic

@koic koic commented Nov 28, 2026

Copy link
Copy Markdown
Member

Motivation and Context

test_rejects_hs256_key_confusion presents the verifier with a token signed with HS256, using the RSA public key as the HMAC secret, and expects it to be refused. It built that token with JWT.encode. jwt 3.3.2 refuses to sign with a public key or a certificate as an HMAC secret, so the test now errors with JWT::EncodeError before it reaches the verifier, and CI fails on every Ruby version that resolves jwt 3.3.2.

The test now computes the HMAC itself, so it keeps checking the verifier with every jwt version. The verifier is unchanged.

How Has This Been Tested?

test/mcp/server/oauth/jwt_verifier_test.rb, run with jwt 3.3.0 and with jwt 3.3.2. Before the change it errors with jwt 3.3.2.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

## Motivation and Context

`test_rejects_hs256_key_confusion` presents the verifier with a token signed with HS256, using the RSA public key
as the HMAC secret, and expects it to be refused. It built that token with `JWT.encode`. jwt 3.3.2 refuses to sign
with a public key or a certificate as an HMAC secret, so the test now errors with `JWT::EncodeError` before it reaches
the verifier, and CI fails on every Ruby version that resolves jwt 3.3.2.

The test now computes the HMAC itself, so it keeps checking the verifier with every jwt version. The verifier is unchanged.

## How Has This Been Tested?

`test/mcp/server/oauth/jwt_verifier_test.rb`, run with jwt 3.3.0 and with jwt 3.3.2. Before the change it errors with jwt 3.3.2.

## Breaking Changes

None.
@koic
koic force-pushed the sign_the_forged_token_of_the_key_confusion_test_without_jwt_encode branch from bc0d2b9 to 88cdb52 Compare November 28, 2026 15:42
@koic
koic merged commit 88d9781 into modelcontextprotocol:main Nov 28, 2026
13 checks passed
@koic
koic deleted the sign_the_forged_token_of_the_key_confusion_test_without_jwt_encode branch November 28, 2026 15:47
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