PyJWT: PyJWK accepts empty HMAC keys, bypassing PyJWT's empty-key validation
### Summary A service that verifies HS256 tokens using an empty oct JWK through PyJWK, including a PyJWK obtained from PyJWKSet, can therefore accept attacker-generated tokens as authenticated. PyJWT 2.13.0 rejects an empty HMAC key when it is supplied through the raw `str`/`bytes` key path, but accepts the same zero-length key when it is supplied as a symmetric `PyJWK`. An `oct` JWK containing an empty Base64URL key value: ```json {"kty":"oct","k":""} ``` is decoded to `b""`. During signature verification, the `PyJWK` path uses this decoded value directly and does not invoke the empty-key validation in `HMACAlgorithm.prepare_key`. With the default `enforce_minimum_key_length=False`, PyJWT emits a warning and proceeds with HMAC verification using the zero-length key. An attacker can independently calculate `HMAC-SHA256(b"", signing_input)` and create valid HS256 JWTs with arbitrary claims. A service that verifies HS256 tokens using an empty `oct` JWK through `PyJWK` or `PyJWKSet` can therefore accept attacker-generated tokens as authenticated. The application must already contain an empty HMAC JWK, for example because a missing Base64URL configuration or secret-manager value was serialized as `"k": ""`. The attacker does not need control of the JWK/JWKS source, a signing oracle, a private key, or a mixed algorithm allow-list. ### Details The vulnerability is caused by inconsistent validation of the same HMAC key material depending on whether it enters PyJWT as a raw key or th
GHSA-9j54-fg26-wv3r
Primary source · Revision 1
Imported from structured advisory data. Source references identify upstream records or fields; verify affected versions and your deployed configuration.
Security context
Source reference: osv:GHSA-9j54-fg26-wv3r
pyjwt
Source reference: /affected/0/package/name
- Affected versions
- 2.13.0
Source reference:
/affected/0/versions - Fixed versions
- 2.14.0
Source reference:
/affected/0/ranges - Prerequisites
- Not stated in this record
Structured affected-version data
Original package identities and version rules from this source.
[
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "2.13.0"
},
{
"fixed": "2.14.0"
}
]
}
],
"package": {
"name": "pyjwt",
"purl": "pkg:pypi/pyjwt",
"ecosystem": "PyPI"
},
"versions": [
"2.13.0"
],
"database_specific": {
"source": "https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-9j54-fg26-wv3r/GHSA-9j54-fg26-wv3r.json"
}
}
]- Related CVEs
- CVE-2026-102266
Source reference:
/aliases
Publisher severity
high
Source reference: /database_specific/severity
- Event
- #62564 · Revision 1
- Added to Heist Feed
- Publisher date