Skip to content

Accept EdDSA tokens in the token validator - #7253

Merged
rdimitrov merged 2 commits into
mainfrom
rdimitrov/eddsa-token-validator
Nov 23, 2026
Merged

rdimitrov merged 2 commits into
mainfrom
rdimitrov/eddsa-token-validator

Conversation

@rdimitrov

@rdimitrov rdimitrov commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Why: the embedded auth server accepts an Ed25519 signing key and signs access tokens with EdDSA. The token validator that the proxy and vMCP use only allowed RSA and ECDSA, so every token from an Ed25519-keyed server got a 401 with unexpected signing method: EdDSA. The server started fine, and nothing pointed at the key type.
  • What: validateTokenHeader in pkg/auth/token.go now also allows *jwt.SigningMethodEd25519. This fixes both key paths:
    • the in-process WithKeyProvider path, which already returns the auth server's ed25519.PublicKey;
    • remote JWKS, where jwx exports an OKP crv: Ed25519 key as ed25519.PublicKey, the type golang-jwt's EdDSA verifier expects.
  • Discovery already advertises EdDSA in id_token_signing_alg_values_supported, because the list comes from the signing key's alg. The JWKS serves the key as kty: OKP, crv: Ed25519. A new handler test pins both.

This adds real support (option 1 in the issue) instead of refusing Ed25519 at startup. Every path that checks these tokens can handle Ed25519 keys, so there was no path to fall back on.

Closes #7250

Type of change

  • Bug fix

Test plan

  • Unit tests (task test): ran go test on ./pkg/auth/..., ./pkg/authserver/server/... and ./pkg/vmcp/auth/...
  • Linting (task lint-fix): task lint-fix is broken locally on Go 1.27, so I ran the CI-pinned golangci-lint v2.15.0 on the touched packages, with 0 issues

TestTokenValidator_SigningAlgorithms runs each case through ValidateToken and Middleware (200 vs 401), on both the JWKS lookup (OKP key served over TLS) and the local key provider:

  • accepted: RS256 with an RSA key, ES256 with an ECDSA key, EdDSA with an Ed25519 key;
  • refused: an EdDSA header whose kid resolves to an RSA key, RS256 and ES256 headers whose kid resolves to an Ed25519 key, and alg: none.

Without the fix, the two EdDSA cases fail on both paths.

Does this introduce a user-facing change?

Yes.

  • Before: with an Ed25519 signing key, the embedded auth server issued EdDSA access tokens, and the proxy and vMCP refused every one with 401 (unexpected signing method: EdDSA).
  • After: those tokens validate the same way RS256 and ES256 tokens do. Tokens from an external IdP that signs with EdDSA (OKP keys in its JWKS) are now accepted too. docs/middleware.md now lists the accepted algorithms.

Special notes for reviewers

  • Algorithm confusion: the allowlist still contains only asymmetric methods, so a public key can never be used as an HMAC secret. Matching key type to alg is enforced by golang-jwt's Verify for each method: RS* needs *rsa.PublicKey, ES* needs *ecdsa.PublicKey, and EdDSA needs an ed25519.PublicKey of the right length. golang-jwt doesn't check the ECDSA curve, so a key on the wrong curve fails signature verification instead. The validator doesn't check this separately, the same as for RSA and ECDSA today. The negative tests pin this for both lookup paths.
  • Client keys are unaffected: EdDSA stays excluded from client key algorithms (SupportedClientKeyAlgorithms), because fosite can't verify EdDSA client assertions. That limit is on fosite's side. This PR only touches the resource-server validator.
  • Untested end to end: there's no integration test that has the auth server itself issue an EdDSA token, because the pkg/authserver integration harness is hard-wired to RSA (testKeyProvider, testServer.PrivateKey). The issue's reproduction shows the server already issues these tokens.

🤖 Generated with Claude Code

The embedded auth server signs access tokens with EdDSA when given an
Ed25519 key, but validateTokenHeader allowed only RSA and ECDSA, so the
proxy and vMCP refused every such token with "unexpected signing
method: EdDSA".

Allow *jwt.SigningMethodEd25519 as well. Only asymmetric methods are
allowed, and golang-jwt's Verify refuses a key of the wrong Go type for
the header's alg, so the key resolved for the kid must still match.

Closes #7250

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the size/S Small PR: 100-299 lines changed label Nov 23, 2026
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.69%. Comparing base (443b23f) to head (0d77994).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7253      +/-   ##
==========================================
- Coverage   81.69%   81.69%   -0.01%     
==========================================
  Files         904      904              
  Lines       91829    91838       +9     
==========================================
+ Hits        75023    75029       +6     
- Misses      16801    16804       +3     
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

List the algorithms the authentication middleware accepts in
docs/middleware.md, correct the validateTokenHeader comment (golang-jwt
does not check the ECDSA curve; a wrong-curve key fails signature
verification), and restore the doc comment above
TestDiscoveryHandlers_ConfidentialAuthMethods.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Nov 23, 2026

@jhrozek jhrozek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, the fix is right and everything still fails closed. Two things you might want to look at before merging, neither is blocking:

The local key provider subtests in TestTokenValidator_SigningAlgorithms can pass without the local provider doing anything. The mock is AnyTimes() and JWKSURL points at a server with the same keys, so if getKeyFromLocalProvider ever returned (nil, nil) the lookup would just fall back to HTTP and the test would stay green. Since the issue is about the embedded auth server, that's the path I'd most like pinned. Leaving JWKSURL empty in those cases (or requiring PublicKeys to be called) would do it.

The new comment on validateTokenHeader says a key on a different curve than the alg names fails signature verification. I don't think that holds: golang-jwt's ECDSA Verify only checks the key type, the signature length for the alg, and ecdsa.Verify, so whoever holds a P-256 key can sign the SHA-384 hash, pad r and s to 48 bytes, and it verifies as ES384. Not exploitable since you need the private key, but I'd drop that sentence or just say the curve isn't checked, so nobody leans on it later.

@rdimitrov
rdimitrov merged commit 48a829b into main Nov 23, 2026
47 of 48 checks passed
@rdimitrov
rdimitrov deleted the rdimitrov/eddsa-token-validator branch November 23, 2026 16:27
@github-actions github-actions Bot mentioned this pull request Nov 24, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embedded auth server signs with an Ed25519 key, but ToolHive's token validator refuses EdDSA tokens

2 participants