Sensitive Data Leakage in scikit-learn's TfidfVectorizer
Summary
DEBIAN-CVE-2024-5206: 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. Affects scikit-learn versions 0.23.2-5 – 1.4.2+dfsg-8. No fix is published. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
scikit-learn is a widely used machine learning library in Python that provides simple and efficient tools for data mining and data analysis. It offers various algorithms for classification, regression, clustering, and dimensionality reduction. The TfidfVectorizer is a key component that transforms text data into a format suitable for machine learning models by converting a collection of raw documents to a matrix of TF-IDF features. However, a vulnerability has been identified in this component that could lead to the unintended exposure of sensitive information.
Vulnerability Detail
A sensitive data leakage vulnerability was identified in scikit-learn's TfidfVectorizer, specifically in versions up to and including 1.4.1.post1. 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.
How To Fix
No fixed version is published for this vulnerability.
Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →
Workaround
As a temporary workaround, avoid using the TfidfVectorizer with sensitive data until you can update to the patched version. Additionally, consider manually filtering out sensitive tokens before passing data to the vectorizer.
Conclusion
The scikit-learn library's TfidfVectorizer has a vulnerability that can lead to sensitive data leakage. Users are advised to update to version 1.5.0 or later to mitigate this risk. Until then, it is recommended to avoid using the affected component with sensitive data.
See every vulnerability recorded for scikit-learn →
FAQ
The vulnerability involves the unintended storage of all tokens in the 'stop_words_' attribute, which may include sensitive information.
Versions up to and including 1.4.1.post1 are affected by this vulnerability.
You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without any signup.
If you cannot update immediately, avoid using the TfidfVectorizer with sensitive data and manually filter out sensitive tokens.
More information can be found in the official CVE report for DEBIAN-CVE-2024-5206.
References
Related vulnerabilities
Recent vulnerabilities recorded for scikit-learn.