CVE-2026-102271: PyJWT Vulnerability Allows Public Keys in DER Form as HMAC Secrets

pyjwt Updated 30 Sep 2026

Summary

29/09/2026
Yes i
High
7.4

CVE-2026-102271: PyJWT: Public keys in DER form are accepted as HMAC secrets, bypassing the CVE-2022-29217 guard. Affects pyjwt versions >= 2.4.0, < 2.14.0. Fixed in 2.14.0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

Background

PyJWT is a Python library used for encoding and decoding JSON Web Tokens (JWT). It supports various algorithms for signing and verifying tokens, including HMAC and asymmetric algorithms like RSA and EC. The library is widely used in applications for secure token-based authentication. However, it has a vulnerability that allows public keys in DER format to be incorrectly accepted as HMAC secrets, leading to potential security risks.

Vulnerability Detail

The vulnerability arises from the HMACAlgorithm.prepare_key method, which incorrectly allows DER-encoded public keys to be used as HMAC secrets. This occurs because the method only checks for specific text markers to identify PEM and SSH keys, failing to account for binary DER format. An attacker can exploit this by signing a forged token with a public key, allowing them to impersonate users and gain unauthorized access. This issue is a variant of the key confusion problem identified in CVE-2022-29217, where improper verification of cryptographic signatures can lead to serious security breaches.

How To Fix

Latest published version: 2.15.1 as of 23 Oct 2026

pip install --upgrade "pyjwt==2.15.1"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

2.14.0

This is the first release that contains the fix.

pip install --upgrade "pyjwt==2.14.0"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, ensure that your application does not mix HS* and RS* algorithms and avoid passing public keys as DER bytes to the jwt.decode method. Instead, use PEM-encoded keys or ensure proper key management practices are in place.

Conclusion

The PyJWT vulnerability CVE-2026-102271 poses a significant risk by allowing public keys in DER format to be used as HMAC secrets. It is crucial for developers to update to the patched version 2.14.0 or later and to follow best practices for key management to mitigate this risk.

See every vulnerability recorded for pyjwt →

Share this vulnerability

FAQ

The vulnerability allows attackers to forge tokens using public keys, potentially granting them unauthorized access to user accounts.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

The CVSS score of this vulnerability is 7.4, indicating a high severity level.

Yes, the application must be misconfigured to allow HS* algorithms with an asymmetric public key passed as DER bytes.

If immediate updates are not possible, implement the suggested workaround by avoiding the use of DER public keys as HMAC secrets.

Related vulnerabilities

Recent vulnerabilities recorded for pyjwt.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Latest published version: 2.15.1 as of 23 Oct 2026

pip install --upgrade "pyjwt==2.15.1"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

2.14.0

This is the first release that contains the fix.

pip install --upgrade "pyjwt==2.14.0"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback