fix(oidc): pass raw 32-byte Ed25519 key, not SPKI-wrapped DER (LC-22) #351
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
psa-systems/lets-chat!351
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/lc-22-ed25519-spki-verify"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
jsonwebtoken::DecodingKey::from_ed_deris misleadingly named: it doesNOT parse SPKI DER. It stores its byte slice verbatim into the
DecodingKey, andverify_ringeventually callsring::signature::UnparsedPublicKey::new(ED25519, key)which expectsraw 32-byte Ed25519 public key bytes - not the SPKI envelope
(
SEQUENCE(SEQUENCE(OID 1.3.101.112), BIT STRING(...))) thated25519_raw_to_derwas constructing.Result post-cutover deploy: every id_token verify failed with
InvalidSignaturebecause the lookup key handed to ring was 44 bytes ofSPKI DER while bunyip's actual signature was over the raw 32-byte key.
The unit test path never caught it because we have no integration test
against a live OIDC OP yet (parked in v2 backlog).
Fix: keep the 32 raw bytes off the JWK
xparameter unchanged, storethem under
EdKey.raw(renamed fromEdKey.der), and pass themstraight through to
DecodingKey::from_ed_der. Verify length is 32during JWKS fetch so a malformed JWK fails loud at fetch time instead
of mysteriously failing every callback. The helper that built the SPKI
wrapper is deleted entirely.
#LC-22
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com