Skip to content

Commit b701089

Browse files
authored
python3Packages.requests: fix netrc credential leak vulnerability (#413942)
2 parents 46edfcf + 1d22f98 commit b701089

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
From 57acb7c26d809cf864ec439b8bcd6364702022d5 Mon Sep 17 00:00:00 2001
2+
From: Nate Prewitt <nate.prewitt@gmail.com>
3+
Date: Wed, 25 Sep 2024 08:03:20 -0700
4+
Subject: [PATCH] Only use hostname to do netrc lookup instead of netloc
5+
6+
---
7+
src/requests/utils.py | 8 +-------
8+
1 file changed, 1 insertion(+), 7 deletions(-)
9+
10+
diff --git a/src/requests/utils.py b/src/requests/utils.py
11+
index 699683e5d9..8a307ca8a0 100644
12+
--- a/src/requests/utils.py
13+
+++ b/src/requests/utils.py
14+
@@ -236,13 +236,7 @@ def get_netrc_auth(url, raise_errors=False):
15+
return
16+
17+
ri = urlparse(url)
18+
-
19+
- # Strip port numbers from netloc. This weird `if...encode`` dance is
20+
- # used for Python 3.2, which doesn't support unicode literals.
21+
- splitstr = b":"
22+
- if isinstance(url, str):
23+
- splitstr = splitstr.decode("ascii")
24+
- host = ri.netloc.split(splitstr)[0]
25+
+ host = ri.hostname
26+
27+
try:
28+
_netrc = netrc(netrc_path).authenticators(host)

pkgs/development/python-modules/requests/default.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ buildPythonPackage rec {
3333
# https://github.com/psf/requests/issues/6730
3434
# https://github.com/psf/requests/pull/6731
3535
./ca-load-regression.patch
36+
37+
# https://seclists.org/fulldisclosure/2025/Jun/2
38+
./CVE-2024-47081.patch
3639
];
3740

3841
dependencies = [

0 commit comments

Comments
 (0)