Stop chasing patch dates. Learn to check, fix, and mitigate critical Python 3.10 vulnerabilities (tar injection, cookie bypass, XML stack overflow) on Ubuntu, Rocky, and SUSE. Includes automation scripts and alternative firewalls. Secure your code today.
If you run Python 3.10 on Linux, you are responsible for five specific failure points in the standard library. A recent SUSE update (2026-1376-1) fixed:
1. Tarfile confusion (CVE-2025-13462): A malicious .tar file can fool Python into writing files where it shouldn't.
2. Path traversal in pkgutil (CVE-2026-3479): get_data() can be tricked into reading files outside its intended directory.
3. Cookie injection (CVE-2026-3644): Incomplete validation in http.cookies lets an attacker bypass input checks.
4. XML stack crash (CVE-2026-4224): Deeply nested DTDs in an XML document can crash your Python process (C stack overflow).
5. Browser command injection (CVE-2026-4519): The webbrowser.open() API fails to sanitize leading dashes (-), allowing attackers to pass dangerous flags to the browser.
You don't need to memorize CVEs. You need a repeatable process to find, fix, or block these problems. Here is that process.
1. How to check if you are vulnerable
# Check your Python version python3.10 --version # For tarfile vulnerability: try to import and extract a crafted tar (safe test) python3.10 -c "import tarfile; print('Vulnerable' if hasattr(tarfile, '_GNU_NAME_IS_DIR') is False else 'Check patch level')" # For the XML crash: test if your Python is patched against deep DTDs python3.10 -c "import xml.parsers.expat; print('Check CVE-2026-4224 manually via changelog')" # Better: check package changelog dpkg -l | grep python3.10 apt changelog python3.10 | grep -i CVE-2026-4224
# Check installed version rpm -q python3.10 # Look for the specific bug fixes rpm -q --changelog python3.10 | grep -E "CVE-2026-4224|CVE-2026-4519"
# Check if the specific patch is installed zypper patches | grep python310 rpm -q --changelog python310 | grep -i "bsc#1260026" # browser injection bug
python3.10 -c "import webbrowser; print('Test manually: run webbrowser.open(\"-version\") in a sandbox')"Do not actually run webbrowser.open("-version") on a production machine. That is the vulnerability itself.
2. Automation script to apply the fix (bash, major distros)
Save this as fix_python310.sh and run it as root on Ubuntu, Rocky Linux, or SUSE.
#!/bin/bash # Evergreen fix for Python 3.10 vulnerabilities (tar, cookie, XML, browser injection) set -e if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" exit 1 fi # Detect distro if [[ -f /etc/os-release ]]; then . /etc/os-release OS=$ID VER=$VERSION_ID fi case $OS in ubuntu|debian) apt update apt install -y python3.10 python3.10-full ;; rocky|almalinux|rhel|centos) dnf update -y python3.10 ;; suse|opensuse-leap|opensuse) zypper refresh # The exact patch name from April 2026. Replace with current if needed. zypper patch -y --cve=CVE-2026-4519 --cve=CVE-2026-4224 ;; *) echo "Unsupported OS: $OS" exit 1 ;; esac echo "Python 3.10 updated. Verify with: python3.10 -c 'import tarfile; print(tarfile.__version__)'"
How to use:
chmod +x fix_python310.sh sudo ./fix_python310.sh
3. Alternative mitigation if you can't update now
# /etc/apparmor.d/usr.bin.python3.10 /usr/bin/python3.10 { # ... your existing rules ... deny /usr/lib/python3.10/webbrowser.py r, deny /usr/lib/python3.10/webbrowser.pyc r, }ML from the internet, put nginx or haproxy in front and reject requests with deeply nested elements.
For the XML stack overflow (CVE-2026-4224) – use a proxy to filter XML
location /xml-endpoint { # Only allow POST with small body client_max_body_size 10k; # Use a Lua script or external module to check nesting depth # Simpler: block XML altogether if you don't need it if ($content_type ~* "application/xml") { return 403; } }
import tarfile with tarfile.open('untrusted.tar') as tf: for member in tf.getmembers(): if member.name.startswith('/') or '..' in member.name: raise ValueError("Bad path in tar") tf.extract(member, path="/safe/dir")
pip install itsdangerous
# Instead of: from http.cookies import SimpleCookie from itsdangerous import Signer # This is a breaking change, but it closes the bypass.
Suggested reading
Offensive Security Using Python: A Hands-on Guide to Offensive Tactics and Threat Mitigation Using Practical Strategies . by Rejah Rehim -Amazon

Nenhum comentário:
Postar um comentário