CVE-2024-35195: Requests `Session` object does not verify requests after making first request with verify=False
Medium CVSS 5.6
- OSV id
- GHSA-9wx4-h78v-vm56
- Also known as
- CVE-2024-35195, PYSEC-2026-1873
- Published
- Last modified
Affected packages
| Package | Affected versions | Fixed in |
|---|---|---|
| requests PyPI |
< 2.32.0 | 2.32.0 |
Versions we track that it affects: requests 2.31.0, requests 2.28.1
How to fix it
Upgrade requests to 2.32.0 or later.
# in requirements.txt: change the line to requests==2.32.0
pip install -r requirements.txt
- If it is an indirect dependency, upgrade the package that depends on it, or add a minimum version constraint for it (e.g. in constraints.txt, or as a dependency in pyproject.toml).
- Check the changelog for breaking changes (especially across major versions), update the lockfile with the package manager, and run your tests.
Not sure whether your project uses an affected version? Check your lockfile below for free.
Details
When using a requests.Session, if the first request to a given origin is made with verify=False, TLS certificate verification may remain disabled for all subsequent requests to that origin, even if verify=True is explicitly specified later.
This occurs because the underlying connection is reused from the session's connection pool, causing the initial TLS verification setting to persist for the lifetime of the pooled connection. As a result, applications may unintentionally send requests without certificate verification, leading to potential man-in-the-middle attacks and compromised confidentiality or integrity.
This behavior affects versions of requests prior to 2.32.0.
References
- GHSA-9wx4-h78v-vm56 on OSV.dev
- Web: https://github.com/psf/requests/security/advisories/GHSA-9wx4-h78v-vm56
- Advisory: https://nvd.nist.gov/vuln/detail/CVE-2024-35195
- Web: https://github.com/psf/requests/pull/6655
- Web: https://github.com/psf/requests/commit/a58d7f2ffb4d00b46dca2d70a3932a0b37e22fac
- Package: https://github.com/psf/requests
- Web: https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/IYLSNK5TL46Q6XPRVMHVWS63MVJQOK4Q
- Web: https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/N7WP6EYDSUOCOJYHDK5NX43PYZ4SNHGZ
Am I affected?
Upload or paste your lockfile. We check every package version in it against OSV.dev, this advisory included, and email you the vulnerable ones with the version that fixes them. Free, and no account needed.
About this data
Source: GitHub Advisory Database via OSV.dev (CC-BY 4.0). Severity comes from the advisory's own rating when it has one, else from its CVSS score.