CVE-2022-29217

7.4 HIGH

📋 TL;DR

This vulnerability in PyJWT allows attackers to forge JWT tokens by algorithm confusion when applications use the default algorithm list. It affects applications that use PyJWT with algorithms=jwt.algorithms.get_default_algorithms() for token verification, potentially enabling authentication bypass.

💻 Affected Systems

Products:
  • PyJWT
Versions: All versions before 2.4.0
Operating Systems: All operating systems running Python
Default Config Vulnerable: ✅ No
Notes: Only vulnerable when applications use algorithms=jwt.algorithms.get_default_algorithms() or similar broad algorithm lists during JWT decoding.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete authentication bypass allowing attackers to impersonate any user, access privileged data, or perform unauthorized actions.

🟠

Likely Case

Authentication bypass for some users, potentially leading to unauthorized access to sensitive functionality.

🟢

If Mitigated

No impact if applications explicitly specify allowed algorithms or use the patched version.

🌐 Internet-Facing: HIGH - JWT tokens are commonly used in web APIs and authentication systems exposed to the internet.
🏢 Internal Only: MEDIUM - Internal systems using PyJWT with vulnerable configurations could be compromised via internal attackers.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Attack requires submitting a malicious JWT token with algorithm confusion. Public exploit details exist in the advisory.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 2.4.0

Vendor Advisory: https://github.com/jpadilla/pyjwt/security/advisories/GHSA-ffqj-6fqr-9h24

Restart Required: No

Instructions:

1. Update PyJWT: pip install --upgrade pyjwt>=2.4.0
2. Verify installation: pip show pyjwt
3. Test JWT functionality remains working.

🔧 Temporary Workarounds

Explicit Algorithm Specification

all

Instead of using get_default_algorithms(), explicitly specify the exact algorithms your application expects.

Replace algorithms=jwt.algorithms.get_default_algorithms() with algorithms=['HS256'] or your specific algorithm

🧯 If You Can't Patch

  • Implement explicit algorithm validation in JWT decoding code
  • Add additional signature verification checks outside PyJWT

🔍 How to Verify

Check if Vulnerable:

Check if your Python code uses algorithms=jwt.algorithms.get_default_algorithms() or similar broad algorithm lists in JWT.decode() calls.

Check Version:

pip show pyjwt | grep Version

Verify Fix Applied:

Verify PyJWT version is 2.4.0 or higher and code uses explicit algorithm lists.

📡 Detection & Monitoring

Log Indicators:

  • Failed JWT validations with algorithm mismatch errors
  • Unusual authentication patterns

Network Indicators:

  • JWT tokens with unexpected algorithm headers
  • Authentication attempts with malformed tokens

SIEM Query:

Search for JWT decode errors or authentication failures in application logs

🔗 References

📤 Share & Export