Security context
UnratedPYSEC-2015-17 CVE-2015-2296Published Mar 18, 2015

The resolve_redirects function in sessions.py in requests 2.1.0 through 2.5.3 allows remote attackers to conduct session fixation attacks via a cookie without a host value in a redirect.

Research this vulnerability

Research is free — Hunters explains how the bug works, the root-cause code pattern, how the fix addresses it, and how to test whether a target is affected, in chat. Investigate & write exploit is a paid run — the engine reads the advisory and fix commits, then builds and validates a working proof-of-concept exploit with reproduction steps.

Affected versions

2.1.0 → fixed in 2.6.0

Details

The resolve_redirects function in sessions.py in requests 2.1.0 through 2.5.3 allows remote attackers to conduct session fixation attacks via a cookie without a host value in a redirect.

The fix

Don't ascribe cookies to the target domain.

Cory Benfield· Mar 14, 2015, 08:49 AM+113bd8afbff2
requests/sessions.py+1 1
@@ -171,7 +171,7 @@ def resolve_redirects(self, resp, req, stream=False, timeout=None,
except KeyError:
pass
- extract_cookies_to_jar(prepared_request._cookies, prepared_request, resp.raw)
+ extract_cookies_to_jar(prepared_request._cookies, req, resp.raw)
prepared_request._cookies.update(self.cookies)
prepared_request.prepare_cookies(prepared_request._cookies)

References