GHSA-w2cx-738m-mc7w: High severity pip/PyJWT vulnerability

Published Sep 29, 2026
·
Updated

Summary

PyJWT 2.13.0 contains an incomplete defense against algorithm confusion when an application mixes symmetric and asymmetric algorithms in one verification path. A public RSA, EC, or OKP JWK can be accepted as an HMAC secret when it is wrapped in a JWKS object, nested in an array, or represented in another container form that does not expose a top-level kty member.

Impact

An attacker who knows the public key material can forge HS256/HS384/HS512 tokens if the application simultaneously:

allows both HS and asymmetric algorithms; passes raw public JWK/JWKS JSON as key=; and uses that same value as the HMAC secret.

This can allow forged JWT claims in affected application configurations. The issue does not affect applications that keep symmetric and asymmetric verification paths separate and follow PyJWT's algorithm-selection guidance.

Fix status

The fix is on master in commit 801cd12 (fix: reject public JWK container HMAC keys). HMACAlgorithm.preparekey now rejects public JWK members found in objects, arrays, nested containers, BOM/UTF variants, and recursion-limit inputs. It also recognizes escaped JSON member names without treating ordinary string values as JWKs. Ordinary JSON secrets remain accepted byte-for-byte.

The change was tested with focused regression tests and the full local tox matrix. Available Python 3.9, 3.12, and 3.13 crypto/no-crypto suites, mypy, package metadata, and coverage passed; unavailable interpreters were skipped by the project configuration. A fresh independent Astra/max security review accepted the final diff with no blocking findings.

The affected range is = 2.13.0. The fix is on the unreleased development branch; the patched version will be recorded when a released 2.x version containing the fix is available. This advisory is being moved to draft pending that release.

Reporter credit

Credit: Charles Vosburgh / Trilobyte.

Original report

The original report and reproduction package are retained in the private advisory record.

Maintainer update — 2026-09-11

The verified fix for this advisory is included in PyJWT 2.14.0, released on 2026-09-11 and available on PyPI. PyJWT 2.14.0 is the first release containing the fix. This advisory is now published with 2.14.0 recorded as the patched version.

Affected Software

1 affected componentFixes available
pip/PyJWT=2.13.0
2.14.0

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.14.0
  2. Upgrade

    Upgrade PyJWT to a version that resolves this vulnerability.

    Fixed in 2.14.0
  3. Compensating control

    Keep symmetric and asymmetric algorithm verification paths separate when configuring PyJWT.

Event History

Sep 29, 2026
Advisory Published
via GitHub·11:16 PM
Data Sourced
via GitHub·11:16 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which deployments are actually exposed to token forgery?

Exposure requires all of the following: the application permits both HMAC (HS256, HS384, or HS512) and asymmetric algorithms in one verification path, supplies raw public JWK or JWKS JSON through key=, and uses that same value as an HMAC secret. Applications with separate symmetric and asymmetric verification paths are not affected.

2

What does an attacker need to exploit this issue?

An attacker needs the public key material and a configuration that meets the affected conditions. They can then forge an HMAC-signed token using the public JWK/JWKS material as the secret, potentially controlling JWT claims.

3

How can we identify a vulnerable implementation?

Review JWT verification code for a single path that allows both HS* and asymmetric algorithms and passes raw JWK or JWKS JSON as key=. Pay particular attention to keys supplied as JWKS objects, arrays, nested containers, or other forms without a top-level kty member.

4

What mitigation is available if an updated fix is not yet deployed?

Keep symmetric and asymmetric verification paths separate and follow PyJWT algorithm-selection guidance. Do not allow HS256, HS384, or HS512 verification using raw public JWK/JWKS JSON or any value intended to represent an asymmetric public key.

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