Repository navigation
Accept EdDSA tokens in the token validator - #7253
Conversation
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]>
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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]>
jhrozek
left a comment
There was a problem hiding this comment.
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.
Summary
unexpected signing method: EdDSA. The server started fine, and nothing pointed at the key type.validateTokenHeaderinpkg/auth/token.gonow also allows*jwt.SigningMethodEd25519. This fixes both key paths:WithKeyProviderpath, which already returns the auth server'sed25519.PublicKey;crv: Ed25519key ased25519.PublicKey, the type golang-jwt's EdDSA verifier expects.EdDSAinid_token_signing_alg_values_supported, because the list comes from the signing key'salg. The JWKS serves the key askty: 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
Test plan
task test): rango teston./pkg/auth/...,./pkg/authserver/server/...and./pkg/vmcp/auth/...task lint-fix):task lint-fixis broken locally on Go 1.27, so I ran the CI-pinned golangci-lint v2.15.0 on the touched packages, with 0 issuesTestTokenValidator_SigningAlgorithmsruns each case throughValidateTokenandMiddleware(200 vs 401), on both the JWKS lookup (OKP key served over TLS) and the local key provider:alg: none.Without the fix, the two EdDSA cases fail on both paths.
Does this introduce a user-facing change?
Yes.
unexpected signing method: EdDSA).docs/middleware.mdnow lists the accepted algorithms.Special notes for reviewers
algis enforced by golang-jwt'sVerifyfor each method: RS* needs*rsa.PublicKey, ES* needs*ecdsa.PublicKey, and EdDSA needs aned25519.PublicKeyof 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.SupportedClientKeyAlgorithms), because fosite can't verify EdDSA client assertions. That limit is on fosite's side. This PR only touches the resource-server validator.pkg/authserverintegration harness is hard-wired to RSA (testKeyProvider,testServer.PrivateKey). The issue's reproduction shows the server already issues these tokens.🤖 Generated with Claude Code