Quick Intro & Historical Context
On May 9, 2026, the maintainers of the popular JSON Web Token (JWT) Python library, PyJWT, released a critical fix.
The vulnerability (CVE-2026-32597, CVSS score 7.5) allows attackers to bypass verification by simply adding a "crit" (critical) section with unknown extensions inside a token header.
From an operational standpoint, this means any token—even those using unknown or unsupported features—would be accepted without error. Attackers can silently disable important security policies (MFA, token binding, scopes) if the backend does not enforce a strict allowlist.
How to Check if You Are Vulnerable (Debian & Ubuntu)
1. Check which version of python3-jwt is installed.
# Check installed version via APT dpkg -l | grep python3-jwt # Or, check via pip (if installed via pip, not apt) pip3 show pyjwt | grep Version
2. Identify vulnerable versions.
- Vulnerable versions: < 2.12.0
- Patched Debian fixed versions (as of May 2026):
- Debian oldstable (bookworm) → 2.6.0-1+deb12u1 or higher
- Debian stable (trixie) → 2.10.1-2+deb13u1 or higher
If your version is lower than any of the above, your system is at immediate risk.
Automation Script to Apply the Fix (Bash for Debian)
Save the following as fix-pyjwt.sh, then run it with root privileges:
#!/bin/bash # fix-pyjwt.sh - Secure PyJWT on Debian Linux set -e echo "[INFO] Starting PyJWT security update script" # Update package indices apt update # Check if python3-jwt is installed if dpkg -l | grep -q python3-jwt; then echo "[INFO] python3-jwt found. Upgrading package." apt upgrade -y python3-jwt else echo "[INFO] python3-jwt not installed via APT. Checking pip..." if pip3 show pyjwt &>/dev/null; then echo "[INFO] PyJWT found via pip. Upgrading via pip." pip3 install --upgrade pyjwt else echo "[WARN] PyJWT not found. Installation may not be needed." fi fi # Final verification echo "[INFO] Verifying installed version..." if dpkg -l | grep -q python3-jwt; then dpkg -l | grep python3-jwt fi if pip3 show pyjwt &>/dev/null; then pip3 show pyjwt | grep Version fi echo "[SUCCESS] PyJWT upgrade completed. Consider restarting dependent services."
Buid you own Laboratory
I earn a comission with you make a purchase.
Alternative Mitigation (If You Cannot Update Now)
from jwt.exceptions import InvalidTokenError ALLOWED_CRIT = {"b64", "http://openid.net/specs/openid-connect-core-1_0.html#CriticalMetadata"} def validate_crit(headers): crit = headers.get("crit") if crit: for ext in crit: if ext not in ALLOWED_CRIT: raise InvalidTokenError(f"Unsupported critical extension: {ext}") # Call validate_crit before jwt.decode()
SecRule REQUEST_HEADERS:Authorization "@contains crit" \
"id:1001,phase:1,deny,status:403,log,msg:'PyJWT crit header blocked'"
3. Use an application proxy or sidecar filter
4. Isolate vulnerable services in a sandbox
# Example: Enforce an AppArmor profile for your Python service sudo aa-genprof /path/to/your/app.py sudo aa-enforce /path/to/your/app.py

Nenhum comentário:
Postar um comentário