# CVE-2024-5206: Sensitive Data Leakage in sklearn.feature_extraction.text.TfidfVectorizer in scikit-learn/scikit-learn

> Attackers can access sensitive training data tokens stored in the TfidfVectorizer stop_words_ attribute, potentially exposing passwords or keys.

- **Severity:** Medium 4.7 (`CVSS:3.0/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:N/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 6 Jun 2024
- **Updated:** 1 Aug 2024
- **Also known as:** CLSA-2026-1787201491, DEBIAN-CVE-2024-5206, ECHO-bf4b-fb83-a5a9, GHSA-jw8x-6495-233v, MGASA-2024-0228, MINI-g5g6-3h3f-vw35, OESA-2024-1745, PYSEC-2024-110, SUSE-SU-2024:2029-1, UBUNTU-CVE-2024-5206, openSUSE-SU-2024:14043-1, openSUSE-SU-2026:11498-1

## What is CVE-2024-5206?

CVE-2024-5206 is a medium-severity vulnerability in scikit-learn/scikit-learn, published on 6 Jun 2024. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

A sensitive data leakage vulnerability was identified in scikit-learn's TfidfVectorizer, specifically in versions up to and including 1.4.1.post1, which was fixed in version 1.5.0. The vulnerability arises from the unexpected storage of all tokens present in the training data within the `stop_words_` attribute, rather than only storing the subset of tokens required for the TF-IDF technique to function. This behavior leads to the potential leakage of sensitive information, as the `stop_words_` attribute could contain tokens that were meant to be discarded and not stored, such as passwords or keys. The impact of this vulnerability varies based on the nature of the data being processed by the vectorizer.

Weakness: CWE-922 (Insecure Storage of Sensitive Information), CWE-921 (Storage of Sensitive Data in a Mechanism without Access Control)

## Which versions are affected by CVE-2024-5206?

3 open source packages ship an affected version, including scikit-learn. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `scikit-learn` | PyPI | All versions | 1.5.0 |
| `scikit-learn` | PyPI | All versions | 1.5.0 |
| `scikit-learn` | PyPI | All versions | 1.5.0 |
| `python-scikit-learn` | SUSE:Linux Enterprise Module for Package Hub 15 SP5 | All versions | 0.23.2-150300.3.3.1 |
| `python-scikit-learn` | SUSE:Linux Enterprise Module for Package Hub 15 SP6 | All versions | 0.23.2-150300.3.3.1 |
| `python-scikit-learn` | openSUSE:Leap 15.5 | All versions | 0.23.2-150300.3.3.1 |
| `python-scikit-learn` | openSUSE:Leap 15.6 | All versions | 0.23.2-150300.3.3.1 |
| `python-scikit-learn` | openSUSE:Tumbleweed | All versions | 1.5.0-1.1 |
| `python-scikit-learn` | openSUSE:Tumbleweed | All versions | 1.9.0-1.1 |

Products: Scikit-Learn Scikit-Learn.

## How do I fix CVE-2024-5206?

Upgrade scikit-learn to 1.5.0 or later.

## Is CVE-2024-5206 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-5206 exists.

## Other vulnerabilities in scikit-learn/scikit-learn

- [CVE-2020-13092](https://insights.sbomify.com/CVE-2020-13092/): scikit-learn Deserialization of Untrusted Data (critical 9.8)
- [CVE-2020-28975](https://insights.sbomify.com/CVE-2020-28975/): scikit-learn Denial of Service (high 7.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-5206 and fix it if it is affected.

What it is: CVE-2024-5206 is a medium-severity vulnerability in scikit-learn/scikit-learn, published on 6 Jun 2024. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-5206 exists.

Affected packages and fixed versions:
- scikit-learn (PyPI): affected all versions; fixed in 1.5.0
- scikit-learn (PyPI): affected all versions; fixed in 1.5.0
- scikit-learn (PyPI): affected all versions; fixed in 1.5.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-5206/ (Markdown: https://insights.sbomify.com/CVE-2024-5206/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-5206
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-5206
- OSV: https://osv.dev/vulnerability/CVE-2024-5206

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-5206/
Summaries are generated and may contain mistakes; the official description above is the record.
