CVE-2026-102271: PyJWT HMAC token forgery via DER public key confusion

CVE-2026-102271 · Severity: high · CVSS 7.4 · Published 2026-09-28

PyJWT is a widely used Python library for handling JSON Web Tokens (JWTs), which are used to securely transmit claims in authentication and authorization systems. When an application accepts both HMAC and asymmetric signing algorithms and a DER-encoded public key is supplied as the HMAC secret, PyJWT incorrectly treats the public key bytes as an HMAC key, allowing an attacker with knowledge of the public key to forge valid authentication tokens and bypass security controls.

Technologies: Jpadilla PyJWT, pyjwt (PyPI). Vendors: Jpadilla, PyPI.

Quick answers

Is CVE-2026-102271 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-102271 being exploited in the wild.
How severe is CVE-2026-102271?
High severity, with a CVSS score of 7.4, published 28 September 2026.
Which products and versions are affected?
Jpadilla PyJWT 2.4.0 to 2.13.0; pyjwt (PyPI) >= 2.4.0, < 2.14.0, ECOSYSTEM:introduced=2.4.0,fixed=2.14.0.
Is there a fix for CVE-2026-102271?
Yes. pyjwt (PyPI): upgrade to 2.14.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-102271 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-102271?
Check whether you run Jpadilla PyJWT or pyjwt (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • pyjwt (PyPI): upgrade to 2.14.0 or later
    pip install "pyjwt>=2.14.0"

Technical details

PyJWT's HMACAlgorithm.prepare_key method relies on textual markers (such as PEM headers) to distinguish public keys from HMAC secrets, but DER-encoded keys lack these markers. When DER-encoded public keys are used as HMAC secrets in applications that support both HMAC and asymmetric algorithms, PyJWT uses the public key bytes directly for HMAC computation. An attacker who possesses the public key can compute valid HMAC tokens without knowing the original secret, leading to authentication bypass. The vulnerability was patched in version 2.14.0.

Affected products

  • jpadilla PyJWT 2.4.0 to 2.13.0

Identifiers

  • CVE-2026-102271
  • GHSA-p4g4-x82p-q773
  • PYSEC-2026-4149

Timeline

  • 2026-09-28: disclosed
  • 2026-09-11: patched: Fixed in version 2.14.0

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.