You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JWKSet.import_keyset raises on an unknown kty, failing the whole set (RFC 7517 §5) #385
JWKSet.import_keyset() raises InvalidJWKValue when any key in the set has a kty it does not recognise, so the entire set fails to import. Per RFC 7517 section 5 an unrecognised key should be ignored, not fatal, so one post-quantum key in a published JWKS takes down the classical keys with it.
Reproduction
A JWK Set with a classical RSA key, an EC key, and one post-quantum ML-DSA key (kty: "AKP", RFC 9964):
fromjwcrypto.jwkimportJWKSetJWKSet.from_json(mixed_jwks) # or JWKSet().import_keyset(mixed_jwks)# jwcrypto.jwk.InvalidJWKValue
Measured against jwcrypto 1.5.8. The set imports fine once the AKP key is removed. Fixture and probe available on request.
Why this matters
RFC 7517 section 5: "Implementations SHOULD ignore JWKs within a JWK Set that use kty values that are not understood by them." ML-DSA (FIPS 204 / RFC 9964, kty: "AKP") is starting to appear in published key sets as post-quantum migration begins. When an issuer adds one to a JWKS that jwcrypto consumers read, those consumers stop verifying every signature from that issuer, including classical RS256/ES256, on a spec-compliant key publication they do not control. jwcrypto is widely used in enterprise and identity Python stacks, so the blast radius is significant.
Suggested fix
In import_keyset, skip a member whose kty is not recognised (optionally warn) rather than raising InvalidJWKValue, so the rest of the set still loads. This implements the RFC section 5 SHOULD and leaves recognised keys unchanged. A lenient default matches the RFC; a strict opt-in could be retained for callers who want it.
Offer
Happy to share the reproduction harness (mixed classical + AKP JWKS plus a control) and to open a PR with the per-key tolerance and a test.
One thing worth surfacing before any change: test_import_keyset_invalid currently asserts that a set containing {"kty": "invalid"} raises InvalidJWKValue, so strict rejection of an unknown kty looks like a deliberate choice rather than an oversight. RFC 7517 §5 is a SHOULD, so both positions are defensible.
The reason I would still suggest reconsidering: as post-quantum keys (ML-DSA, kty:"AKP", RFC 9964) start appearing in published JWKS, a set that mixes a key type a given deployment does not recognise with ordinary RSA/EC keys fails to import entirely, taking down verification of the classical keys too. jwcrypto has added AKP itself, but the whole-set-fatal behaviour remains for any other unrecognised type.
If you would be open to import_keyset skipping keys whose kty is not in JWKTypesRegistry (per §5), I have a one-line change plus an updated test ready to PR. I did not send it unsolicited, since it flips behaviour you currently test for. Happy either way.
Activity
RalphBragg commentedon Jul 24, 2026
One thing worth surfacing before any change:
test_import_keyset_invalidcurrently asserts that a set containing{"kty": "invalid"}raisesInvalidJWKValue, so strict rejection of an unknownktylooks like a deliberate choice rather than an oversight. RFC 7517 §5 is a SHOULD, so both positions are defensible.The reason I would still suggest reconsidering: as post-quantum keys (ML-DSA,
kty:"AKP", RFC 9964) start appearing in published JWKS, a set that mixes a key type a given deployment does not recognise with ordinary RSA/EC keys fails to import entirely, taking down verification of the classical keys too. jwcrypto has added AKP itself, but the whole-set-fatal behaviour remains for any other unrecognised type.If you would be open to
import_keysetskipping keys whosektyis not inJWKTypesRegistry(per §5), I have a one-line change plus an updated test ready to PR. I did not send it unsolicited, since it flips behaviour you currently test for. Happy either way.simo5 commentedon Jul 24, 2026
You have a good point, although we just added AKP support, so perhaps we can avoid a potential surprising behavior change here ...
@rjeffman do you ant to take this bug ?
@RalphBragg can you share a keyset that trigger this?
rjeffman commentedon Jul 24, 2026
@simo5 I'll be unavailable for a couple (3) of weeks, but if time is not an issue, I can take this one.
Skip unknown kty in JWKSet import per RFC 7517 §5