Categories
CVE-2026-102271 high CVSS 7.4

Vulnerability in pyjwt (CVE-2026-102271)

Summary

Vulnerability in pyjwt (CVE-2026-102271). Confidential information can be exposed externally. Exploitable via HMACAlgorithm.prepare_key. Mitigation: upgrade to 2.14.0 or later.

Original description

The description as published by the source.

Summary

HMACAlgorithm.prepare_key blocks asymmetric keys from being used as HMAC secrets by searching for text markers only. It looks for -----BEGIN and for an ssh- prefix. The same key in DER form is binary ASN.1 and has neither marker, so it passes the check and is used as an HMAC secret.

An application that verifies tokens with an RSA or EC public key, and also allows HS256 with that same key, can be given a forged token. The attacker signs it with the public key, which is public. This is the key confusion problem CVE-2022-29217 was filed for, reachable again through a different encoding.

The reach is smaller than the original CVE. The application must already be in that misconfiguration, and it must hold its public key as DER bytes rather than PEM.

Details

The guard is at jwt/algorithms.py:331:

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."
    )

Both helpers are text matchers. Neither one parses the key.

  • jwt/utils.py:126, is_pem_format, runs a regex for ----[- ]BEGIN ...----.
  • jwt/utils.py:141, is_ssh_key, checks startswith against a list of ssh- and ecdsa-sha2- prefixes.

A DER encoded public key starts with the bytes 0x30 0x82. It matches neither, so prepare_key returns it unchanged and it becomes the HMAC secret.

There is no DER handling anywhere in the…

Source: NIST National Vulnerability Database NVD GitHub Advisory

Auto-generated summary

Assembled by SecPulse from the source data (CVSS, CWE, affected versions) using templates — no AI involved. Check the original description and references below for exact details.

A vulnerability tracked as CVE-2026-102271 has been found in pyjwt.
Attackers can target a specific entry point like HMACAlgorithm.prepare_key over the network to misuse the product.
Confidential information can be exposed externally. CVSS score: 7.4/10.
What to do: upgrade pyjwt to 2.14.0 or later.
If unsure, ask your IT team or search "pyjwt CVE-2026-102271" on the vendor's site.

CVE-2026-102271 (pyjwt) — CWE-347 / CVSS v3 7.4
Attack vector: remote (network-reachable) / unauthenticated / no user interaction
Attack surface: HMACAlgorithm.prepare_key / is_pem_format / is_ssh_key / startswith
Patched: 2.14.0 — apply immediately
Plan: 1) Audit SBOM/dependencies, 2) Stage→prod upgrade, 3) Add WAF/proxy monitoring on affected endpoints, 4) Hunt IOCs in logs.
Refs: see the GHSA / vendor advisory / patched release linked on this page.

❓ What is the problem

A vulnerability (CWE-347) exists in pyjwt. Attackers reach the vulnerable code path via HMACAlgorithm.prepare_key without authentication.

📍 Affected scope

Check the vendor advisory for the affected versions of pyjwt. Attack surface: HMACAlgorithm.prepare_key / is_pem_format / is_ssh_key / startswith.

🔥 Severity

Severity: High (CVSS 7.4/10). Confidential information can be exposed externally.

🔧 How to fix

Update to 2.14.0.

🛡️ Workaround

Until the patch is applied: disable the affected feature, apply WAF rules, or restrict access via network ACLs.

🔍 Detection

Search webserver/proxy logs for unusual request patterns matching this CVE's known IOCs. Run grep -r 'pyjwt' . against your dependency files (package-lock.json, requirements.txt, go.sum) to find affected services.

Response actions

Concrete steps and command examples for SOC/SRE teams to execute in order

  1. 1
    Identify exposure identify
    grep -r 'pyjwt' . | grep -v node_modules

    リポジトリと本番環境の依存ファイル (package-lock.json / requirements.txt / go.sum / Gemfile.lock 等) で pyjwt を grep し、稼働しているサービス・バージョンを把握する。

  2. 2
    Apply patch patch
    Upgrade pyjwt to 2.14.0

    ステージング環境で 2.14.0 に上げて回帰テスト → 本番反映。回帰テストはアプリの主要ハッピーパスを含めること。

  3. 3
    Post-deployment verification verify
    Confirm patched version is live in production

    パッチ適用後、ステージングで PoC または同等の悪用パターンを再現して脆弱性が閉じたことを確認。本番ではアクセスログ・WAF でアラート再発が無いか継続監視。

Affected packages

pip pyjwt
[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"2.14.0"}]}]

References

We use cookies for analytics and ad measurement. This setting applies to all Game co., Ltd. sites. Details