PyJWT: HS256/384/512 verify accepts empty HMAC key via oct JWK (PyJWK/PyJWKClient) enabling token forgery
Description
PyJWT versions up to 2.13.0 and the current master branch contain a vulnerability where the HMACAlgorithm.from_jwk method accepts an empty HMAC key from a symmetric oct JWK without raising an error. This allows an attacker to forge tokens by exploiting the verification process that uses this empty key, bypassing signature verification when the key is sourced from a JWK with an empty 'k' value. The issue affects verification paths using PyJWK, PyJWKSet, or PyJWKClient. The vulnerability requires no authentication but depends on the verifier trusting a JWKS containing an empty key entry, which can happen due to misconfiguration or unset environment variables. A fix is available.
CVSS v3.1
Score 7.4high
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The vulnerability arises because the PyJWT library's HMACAlgorithm.from_jwk method does not reject empty keys in symmetric (kty=oct) JWKs, returning a zero-length key. When verifying JWTs using such keys via PyJWK, PyJWKSet, or PyJWKClient, the library computes HMAC with an empty key and accepts any token forged with this empty key. This bypasses signature verification without requiring secret knowledge. The string/bytes secret verification path was fixed in version 2.13.0 to reject empty keys, but the JWK/JWKS verification path remains vulnerable. The vulnerability is exploitable if the JWKS contains an oct key with an empty 'k' value, which can result from misconfiguration such as unset environment variables or fallback mechanisms. The issue is tracked as CWE-347 (Improper Verification of Cryptographic Signature).
Potential Impact
An unauthenticated attacker who can send tokens to an application verifying JWTs using PyJWT with a JWK/JWKS containing an empty HMAC key can forge tokens with arbitrary claims. This compromises the integrity and authenticity of JWT-based authentication or authorization, potentially allowing privilege escalation or unauthorized access. The vulnerability does not affect the string/bytes secret verification path in PyJWT 2.13.0 and later, only the JWK/JWKS path. There are no known exploits in the wild at this time.
Mitigation Recommendations
A patch is available that addresses this vulnerability by rejecting empty HMAC keys in the JWK/JWKS verification path. Users should upgrade PyJWT to a version later than 2.13.0 where this issue is fixed. Until patched, ensure that JWKS used for verification do not contain oct keys with empty 'k' values, and verify configuration to avoid unset or empty secrets being published in JWKS. The default decode options emit a warning but do not fail verification, so relying on warnings is insufficient mitigation.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-pxh4-856f-4h89
- Osv Schema Version
- 1.4.0
- Ecosystems
- ["PyPI"]
- Database Specific Severity
- HIGH
- Cvss Version
- 3.1
Threat ID: 6ada44af4d27ba8daa6a2f94
Added to database: 10/22/2026, 17:15:27 UTC
Last enriched: 10/22/2026, 17:17:35 UTC
Last updated: 10/22/2026, 17:17:35 UTC
Views: 5
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.