Urllib connects to a wrong host
The urllib module parsed URLs inconsistently with how it fetched them, so a password containing a hash character caused the library to connect to a different host than the one the URL appeared to name. An attacker could use this to make a server-side request to an unintended host, an SSRF issue.
Originally disclosed on HackerOne
- Fixed in 3 months
- Paid in 3 months
- Disclosed after 22 months
Summary by the program
The urllib module doesn’t parse correctly password containing the # character.
- Disclosure date: 2017-05-29 (Python issue #30500 reported)
- Reported at: 2017-03-04 (Orange Tsai on the PSRT list)
The report
Description
The inconsistent of URL parsing and URL fetching are distinct
Original bug report
- https://bugs.python.org/issue30500
- http://python-security.readthedocs.io/vuln/bpo-30500_urllib_connects_to_a_wrong_host.html
Note
- None
Thanks :)
Impact
SSRF
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the URL parser and the URL fetcher disagreed about where the host ends when a password contains a hash character, so the fetched host differed from the parsed one.
What the attacker needed
Attacker controls a URL fetched by the app
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 report has not been written yet. The Original tab links to the source.
A URL can contain a username and password before the host name. The hash symbol normally marks the start of a fragment that browsers ignore, but here the library treated it differently when reading the URL than when connecting, so it ended up talking to the wrong server. That matters because a program that fetches a URL on a user's behalf could be tricked into contacting an internal machine.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.