How I Found And Fixed A Vulnerability In Python
Python's urlparse module treated semicolons as query parameter separators, while most proxies only use ampersands. An attacker could craft a request that the proxy caches as safe but the server interprets differently, potentially leading to cache poisoning and reflected XSS.
Published on systemweakness.com
This story was originally published in TLDR.Engineering, which is a blog for short engineering and security stories, for the busy and curious software engineers. You can subscribe to get a weekly email of bite-sized fascinating engineering stories!
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
Impact
An attacker could cause malicious requests to be cached as safe ones, potentially leading to cache poisoning and reflected XSS.
What the attacker needed
A caching proxy that only uses '&' as separator; a server using Python's urlparse
The fix
The vulnerability was fixed in Python by changing the URL parser to no longer treat semicolons as separators, and the fix was backported to older versions.
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.
When a web server receives a URL with parameters, it splits them using a separator character. Python's standard library used both '&' and ';' as separators, but most caching proxies only use '&'. This mismatch lets an attacker hide malicious content in a parameter that the proxy ignores but the server processes, so the proxy caches a harmful response.
What is Cache bugs?
A cache and the origin disagree about a request, so a poisoned response is served to everyone or a private page is stored as public.