---
id: "CVE-2024-47081"
kind: "vulnerability"
aliases: ["CVE-2024-47081", "GHSA-9hjg-9r4m-mvj7"]
title: "Requests vulnerable to .netrc credentials leak via malicious URLs"
severity: "medium"
cvss: 5.300000190734863
epss: 0.009800000116229057
exploited: false
status: "open"
category: "package"
products: [{"name": "requests", "fixed": ["2.32.4"], "affected": "< 2.32.4", "ecosystem": "pypi"}]
ecosystems: ["pypi"]
tags: ["cwe-522", "package", "python", "requests", "self-hosted"]
not_affected_if: ["no-netrc-file", "no-untrusted-urls", "upgraded-to-2.32.4"]
published_at: "2025-06-09T18:15:24+00:00"
first_seen_at: "2026-10-23T19:11:32+00:00"
updated_at: "2026-10-23T23:44:52+00:00"
sources: [{"source": "ghsa", "url": "https://github.com/advisories/GHSA-9hjg-9r4m-mvj7", "first_seen_at": "2026-10-23T19:11:32+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-47081", "first_seen_at": "2026-10-23T23:44:52+00:00"}]
---

# Requests vulnerable to .netrc credentials leak via malicious URLs

The Python Requests library before 2.32.4 can send .netrc credentials to third-party hosts when given a specially crafted URL. An attacker who can get the application to fetch such a URL can capture the username and password stored for other hosts.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- pypi:requests affected < 2.32.4 fixed 2.32.4

## How to check

Run: pip show requests (version below 2.32.4 is affected)
Check whether a .netrc file exists in the home directory of the process user (for example ~/.netrc)
Search the lockfile for requests: grep -i 'requests' requirements*.txt poetry.lock uv.lock

## Fix

Upgrade requests to 2.32.4 or later.
If upgrading is not possible, set trust_env=False on the Requests Session so .netrc is not read.

## Timeline

- 2026-10-23T19:11:32+00:00 ghsa https://github.com/advisories/GHSA-9hjg-9r4m-mvj7
- 2026-10-23T23:44:52+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2024-47081

## From the sources

### Impact

Due to a URL parsing issue, Requests releases prior to 2.32.4 may leak .netrc credentials to third parties for specific maliciously-crafted URLs.

### Workarounds
For older versions of Requests, use of the .netrc file can be disabled with `trust_env=False` on your Requests Session ([docs](https://requests.readthedocs.io/en/latest/api/#requests.Session.trust_env)).

### References
https://github.com/psf/requests/pull/6965
https://seclists.org/fulldisclosure/2025/Jun/2

---

_Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai_
