CVSS Score
Python's ipaddress module mishandled IPv4 addresses with leading zeros, treating them as decimal rather than octal, so an address like 010.8.8.8 was parsed as [redacted] instead of 8.8.8.8. An attacker could exploit this discrepancy to cause SSRF, RFI, or LFI in applications that rely on the module for validation.
sick.codes
Published on sick.codes
python stdlib “ipaddress” – Improper Input Validation of octal literals in python 3.8.0 thru v3.10 results in indeterminate SSRF & RFI vulnerabilities. — “ipaddress leading zeros in IPv4 address”
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the module stopped rejecting ambiguous octal octets and instead stripped leading zeros, causing a parsing discrepancy with other systems.
Impact
Applications relying on the module could be vulnerable to SSRF, RFI, or LFI, though the text does not demonstrate a specific exploit against a real application.
What the attacker needed
Application uses Python ipaddress for validation; attacker can supply an IP address string
The fix
The issue was to be addressed in a future release; the text does not state that a fix was available at the time.
How it was found
- Import the ipaddress module and define a suspect address with a leading zero.
- Parse the address with ipaddress.ip_network and ipaddress.ip_address.
- Observe that the parsed address differs from the intended address.
- Pass the original string and the parsed address to a shell command to show the discrepancy.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
The ipaddress module is meant to check whether a string is a valid IP address. It wrongly accepted addresses with leading zeros and interpreted them differently from other software, so a web app could be tricked into connecting to an unintended server. This mismatch can let an attacker reach internal systems or include remote files.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.