GHSA-pxh4-856f-4h89: PyJWT: HS256/384/512 verify accepts empty HMAC key via oct JWK (PyJWK/PyJWKClient) enabling token forgery
HMACAlgorithm.from_jwk accepts a symmetric (kty=oct) JWK whose k value is
the empty string and returns a zero-length key without raising. When a token is
then verified with that key object (a PyJWK, or a PyJWK resolved by
PyJWKSet / PyJWKClient), the HMAC verifier computes
HMAC(key=b"", signing_input) and accepts any token an attacker forged with the
same empty key. The attacker needs no secret knowledge: they reproduce the digest
locally with an empty key and set the token’s kid to the empty-k JWK.
The empty-key rejection that HMACAlgorithm.prepare_key performs for
string/bytes secrets (added in 2.13.0) was never propagated to the sibling
from_jwk code path, so the JWK/JWKS verification route stays exploitable. Under
default decode options this path only emits an InsecureKeyLengthWarning, not an
error, so verification still succeeds. This is the same “empty/nil HMAC key is
accepted by verify” defect the JWT ecosystem is currently closing library-side:
fast-jwt CVE-2026-44351 (CVSS 9.1) and ruby-jwt CVE-2026-45363 both added a
library-side reject-empty-HMAC-key precondition.
References
Code Behaviors & Features
Detect and mitigate GHSA-pxh4-856f-4h89 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →