Critical Vulnerability in Python 3.8 and 3.9: IP Address Handling Flaw

python3.8 Updated 02 Oct 2025

Summary

06/05/2021
N/A
Yes i
Critical
9.8

UBUNTU-CVE-2021-29921: In Python before 3,9,5, the ipaddress library mishandles leading zero characters in the octets of an IP address string. Affects python3.8 versions < 3.8.0-3ubuntu1~18.04.2+esm2. Fixed in 3.8.0-3ubuntu1~18.04.2+esm2. 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 Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Python is a widely-used high-level programming language known for its readability and versatility. The affected packages, python3.8 and python3.9, are implementations of Python 3 for Ubuntu systems. They provide essential libraries and tools for developers to build applications. However, a vulnerability in the ipaddress library of these versions can lead to security risks, particularly in applications that rely on IP address validation.

Vulnerability Detail

In Python versions prior to 3.9.5, the ipaddress library mishandles leading zero characters in the octets of an IP address string. This flaw can allow attackers to bypass access control mechanisms that depend on IP address validation, potentially leading to unauthorized access to sensitive resources. The vulnerability is classified with a CVSS score of 9.8, indicating a critical level of severity.

How To Fix

Minimum fixed version

3.8.0-3ubuntu1~18.04.2+esm2

This is the first release that contains the fix.

sudo apt-get install --only-upgrade python3.8

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

Workaround

As a temporary workaround, consider implementing additional validation checks in your application to handle IP addresses correctly, ensuring that leading zeros are not accepted. This can be done by using regular expressions to validate the format of IP addresses before processing them.

Conclusion

The vulnerability in Python's ipaddress library poses significant security risks, particularly for applications relying on IP address validation. It is crucial to update to the patched versions of Python 3.8 and 3.9 to mitigate these risks. Additionally, utilizing tools like Vulert can help monitor and manage vulnerabilities effectively.

See every vulnerability recorded for python3.8 →

Share this vulnerability

FAQ

The vulnerability allows attackers to bypass IP address-based access controls due to improper handling of leading zeros in IP address strings.

Python versions prior to 3.9.5 and 3.8.10 are affected by this vulnerability.

You can use Vulert, which monitors and alerts for open-source vulnerabilities in real-time. Check your application using the Vulert playground at Vulert Scanner.

The CVSS score of this vulnerability is 9.8, indicating a critical severity level.

If immediate updates are not possible, implement additional validation checks for IP addresses in your application as a temporary workaround.

Related vulnerabilities

Recent vulnerabilities recorded for python3.8.

How To Fix

Minimum fixed version

3.8.0-3ubuntu1~18.04.2+esm2

This is the first release that contains the fix.

sudo apt-get install --only-upgrade python3.8

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