Skip to content
SSRF Write-up Beginner

Understanding Cve 2023 24329 Python Urlparse Function

Python's urllib.parse did not strip leading blank characters from a URL before a blocklist check, so a URL with a leading space bypassed the blocklist and was still fetched. An attacker could use this to bypass domain or protocol filtering, which the text says can lead to arbitrary file reads, command execution or SSRF.

Hanzala Ghayas Abbasi Follow

Published on infosecwriteups.com

An issue in the urllib.parse component of Python before 3.11.4 allows attackers to bypass blocklisting methods by supplying a URL that starts with blank characters.

Hanzala Ghayas Abbasi, on infosecwriteups.com

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 URL parser did not strip leading whitespace before the blocklist comparison, so the checked string differed from the URL actually fetched.

Impact

Attackers could bypass any domain or protocol blocklist, which the text says can lead to arbitrary file reads, arbitrary command execution, SSRF and other problems.

What the attacker needed

Python before 3.11.4; application uses a URL blocklist

The fix

Python was fixed in version 3.11.4 according to the text, which states the issue affects versions before that release.

How it was found

  1. Write a small Python script that blocks example.com and calls the URL opener with the blocked URL.
  2. Call the same opener with the same URL but with a space at the start.
  3. Observe that the second call still returns the response from example.com.

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.

A blocklist is a list of things a program refuses to do, here refusing to open certain web addresses. The URL parser in Python did not remove spaces at the start of an address before the check, so a blocked address with a space in front looked different to the check but still reached the same site. That means a safety check could be skipped.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.