Skip to content
Info disclosure Write-up Intermediate

CVE-2024-47081: Netrc credential leak in PSF requests library

The Python requests library mishandles URLs containing an empty username and password, causing it to send .netrc credentials for the intended host to a different host. An attacker who can influence the URL could steal those credentials.

seclists.org

Published on seclists.org

Assuming .netrc credentials are configured for example.com, they are leaked to evil.com by the call.

The author, on seclists.org

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 parsing logic treats the empty username and password as absent, so it falls back to .netrc credentials for the host in the URL, which is the attacker's host.

Impact

Credentials stored in .netrc for one host could be sent to an attacker-controlled host.

What the attacker needed

.netrc credentials configured for a host; attacker can influence the URL

The fix

No fix is available; as a workaround, clients should explicitly specify credentials on every API call to disable .netrc access.

How it was found

  1. Configure .netrc credentials for example.com.
  2. Call requests.get with a URL that has an empty username and password before the attacker's host.

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 requests library can automatically use saved passwords from a file called .netrc. A specially crafted web address tricks it into sending those saved passwords to the wrong website.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.