NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · PyPI

CVE-2026-114616: Authlib accepts an empty HMAC key, allowing JWS/JWT signature forgery (HS256/HS384/HS512)

highCVSS 3.1 7.4GHSA-8m4g-j4wp-wgcg

Authlib accepts an empty HMAC key (b'' or '') in authlib.jose, so HS256, HS384 and HS512 signatures made with no secret verify as valid. If your app's verification key can be empty at runtime, an attacker can forge any JWT or JWS. Versions below 1.9.1 are listed as vulnerable. Upgrade to Authlib 1.9.1.

Published Oct 27, 2026 · Analysis Nov 1, 2026

What an attacker can do

In authlib/jose/rfc7518/oct_key.py, OctKey.validate_raw_key only checks isinstance(key, bytes), and import_key rejects only keys that start with PEM or SSH prefixes. An empty key passes both. In jws_algs.py, HMACAlgorithm.prepare_key calls OctKey.import_key, and sign and verify then run hmac.new(b'', ...). The digest is a public function of the header and payload, so anyone can compute it.

The attacker cannot make the key empty. The deployment has to do that, for example when the secret comes from os.environ.get('JWT_SECRET', ''), a config column that defaults to an empty string, or a key resolver that returns '' on a miss. That is why the CVSS vector rates attack complexity high. When it happens, the attacker builds a token with alg HS256, any claims, and a signature computed with an empty key. Authlib accepts it. OAuth 2.0 resource servers and OIDC relying parties built on Authlib can then be tricked into granting elevated scopes or another user's identity.

The reporter notes this is a different bug from earlier Authlib JWT advisories (the JWK header injection, the alg none bypass and the public-key confusion). None of those rejects a zero-length key. PyJWT and joserfc already reject empty HMAC keys.

Who is affected

The advisory text was written against Authlib 1.7.2 and the current main at that time. The package data lists every version below 1.9.1 as vulnerable. Risk exists only in apps that verify or sign HS256, HS384 or HS512 tokens with authlib.jose and could end up with an empty key.

Check the version:

pip show Authlib

Then review where your HMAC secret comes from and whether a missing value falls back to an empty string.

Authlib

Ecosystem
PyPI
Affected
< 1.9.1
Fixed in
1.9.1
Check
pip show Authlib

How to fix it

Upgrade to Authlib 1.9.1.

pip install --upgrade "Authlib>=1.9.1"

The 1.9.1 release page only mentions a changelog tooling change, so the fix itself is in the linked commit 4ff30db. The advisory's suggested remedy is to reject empty oct key material in OctKey.import_key, as joserfc does.

Also fix the source of the empty key. Make the app fail at startup if the JWT secret is unset, and remove empty-string defaults from environment and config lookups.

How to tell if you were hit

Check config, environment and secret stores for JWT or HMAC secrets that are unset or empty in any environment, including staging and containers that start without their secrets. Search code for os.environ.get with an empty default near Authlib use. In logs, look for accepted HS256 tokens with claims your identity provider never issued, or tokens for subjects with no login event. A quick test is to sign a token with an empty key against a test deployment and see whether it verifies.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Reporter: Cavan Loughran, Celvex Group Inc.

Summary

Authlib's symmetric (oct) key handling accepts an empty key (empty bytes b'' / empty string '') as a valid HMAC signing and verification key. An empty HMAC key produces a deterministic digest that any party can reproduce, so an attacker who knows (or can cause) the application to verify a token with an empty key can forge arbitrary tokens that pass HS256/HS384/HS512 signature verification. This is the Authlib member of the cross-language empty-HMAC-key family already assigned CVE-2026-44351 (fast-jwt, npm) and CVE-2026-45363 (ruby-jwt, RubyGems).

This is DISTINCT from Authlib's existing recent JWT-verification advisories. It is not closed by CVE-2026-27962 / GHSA-wvwj-cvrp-7pv5 (JWS JWK header injection, the key=None case), nor by CVE-2026-28802 / GHSA-7wc2-qxgw-g8gg (alg:none blank-signature bypass), nor by GHSA-5357-c2jx-v7qh (algorithm confusion with asymmetric public keys). Those address header-driven key injection, the none algorithm, and asymmetric-vs-symmetric confusion respectively; none of them rejects a zero-length oct key.

Affected versions

Authlib <= 1.7.2 (latest release 1.7.2, 2026-05-06). Confirmed present at the v1.7.2 release tag and on the current main HEAD. The affected code is in authlib/jose/rfc7518/oct_key.py and authlib/jose/rfc7518/jws_algs.py.

Root cause (exact code location, release tag v1.7.2)

  • authlib/jose/rfc7518/oct_key.py, class OctKey:
  • validate_raw_key is a type-only check: return isinstance(key, bytes). An empty bytes object passes.
  • import_key rejects only keys whose material starts with known unsafe prefixes (if raw_key.startswith(POSSIBLE_UNSAFE_KEYS): raise ValueError(...), i.e. PEM/SSH prefixes). Empty bytes do not match any unsafe prefix, so b'' is accepted.
  • get_op_key loads the raw key without validating its length.
  • No check anywhere rejects a zero-length key, so an empty key b'' passes every gate.
  • authlib/jose/rfc7518/jws_algs.py, class HMACAlgorithm:
  • prepare_key: return OctKey.import_key(raw_data).
  • sign / verify call key.get_op_key(...) then hmac.new(op_key, msg, self.hash_alg) / hmac.compare_digest(...). With an empty op key this becomes hmac.new(b'', ...): a deterministic, publicly reproducible digest. There is no empty-key or minimum-length check.

Why this is a real signature bypass

An empty HMAC key makes the signature a public, deterministic function of the header and payload, so anyone can compute a valid signature and forge tokens. The realistic trigger matches the sibling CVEs: the deploying application sources the verification key from a place that can be empty at runtime, for example os.environ.get('JWT_SECRET', ''), a database/config column whose default is '', or a key-resolver that returns '' on a miss. Authlib is widely used to BUILD token verifiers (OAuth 2.0 resource servers, OIDC relying parties), and Authlib's own recent advisory history shows the JWS/JWT verify path is the live attack surface, so a key-resolution path that can yield '' is a realistic exposure.

Reproduction (prose, no weaponized exploit)

  1. In an application that uses Authlib to verify JWS/JWT, arrange for the verification key to be an empty value (e.g. an unset environment variable defaulted to '').
  2. An attacker constructs a token with header {alg: HS256} and an arbitrary payload, and computes the HS256 signature using an empty key (a value any party can reproduce because the key is empty).
  3. Authlib's HMAC verification accepts the token as validly signed, because OctKey.import_key did not reject the empty key and hmac.compare_digest matches the attacker-computable digest. The forged token is treated as authentic.

No live system was probed; the above describes the class. The vulnerable code path and the absent guard are confirmed by direct reading of the public source at the v1.7.2 tag and on current main.

Proof the fix is known-good (no novelty risk)

The same maintainer's newer JOSE library, joserfc, ALREADY rejects empty oct key material outright. In src/joserfc/_rfc7518/oct_key.py, import_key raises a ValueError on empty oct material, with an explicit note that an empty oct key produces a deterministic HMAC digest that any party can reproduce, allowing trivial signature forgery in JWS HS256/HS384/HS512 verification. (joserfc additionally warns on keys below 112 bits.) The same guard is simply absent from the older, far more widely deployed Authlib rfc7518 package. The flagship Python JOSE libraries also guard: PyJWT raises InvalidKeyError('HMAC key must not be empty.') for zero-length keys, and jwcrypto enforces an RFC 7518 minimum key length.

Impact

Token forgery / authentication bypass in OAuth 2.0 resource servers and OIDC relying parties built on Authlib whenever the HMAC verification key can be empty at runtime. An attacker can mint tokens with arbitrary claims (for example elevated scopes or another user's subject) that pass signature verification.

Suggested remediation

Reject empty oct key material in OctKey.import_key (and/or validate_raw_key), exactly as the maintainer's joserfc library already does, before the key can reach hmac.new in HMACAlgorithm.sign / verify. Consider also adopting joserfc's sub-112-bit minimum-length warning/rejection for HMAC keys.

Disclosure

Reporter: Cavan Loughran, Celvex Group Inc.

Credited to clzoom, tonghuaroot, ksanjeev284.

Questions

Can anyone exploit CVE-2026-114616 on any Authlib install?

No. The deployment must end up using an empty HMAC key, for instance through an unset environment variable with an empty default. With a real secret, the flaw does not let an attacker forge tokens.

Which Authlib version fixes the empty-key bug?

Authlib 1.9.1. The package data lists all versions below 1.9.1 as vulnerable, though the reporter verified the code only on 1.7.2 and main at the time.

Is this the same as the earlier Authlib algorithm confusion bug?

No. The advisory says it is distinct from the JWK header injection, the alg none bypass and the public-key HMAC confusion advisories. Those do not reject a zero-length key.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More PyPI vulnerabilities

All PyPI entries