GHSA-7Q25-QRJW-6FG2
Vulnerability from github – Published: 2020-03-24 15:07 – Updated: 2024-10-21 21:06Python Auditing Vulnerability
Demonstrates how a malicious package can insert a load-time poison pill to avoid detection by tools like Safety.
Tools that are designed to find vulnerable packages can not ever run in the same python environment that they are trying to protect.
Usage
Install safety, insecure-package, and this package with pip in the same python environment. Order doesn't matter.
- pip install safety
- pip install insecure-package
- pip install dist/malicious-0.1-py3-none-any.whl
Run the check
safety check
You should see both Running my modified safety.check and that insecure-package is not listed in the results!
How it Works
Everything in Python is mutable. The trick is getting some code to run at interpreter load time in order to do some patching.
- When you install this package, the
setup.pysettings installs amalicious.pthfile to yoursite-packagesdirectory. - The
malicious.pthfile gets loaded anytime Python starts, which in turn imports ourmaliciouspackage. - The
malicious/__init__.pypatches the safety library with a custom function to avoid detection.
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "safety"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "1.9.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2020-5252"
],
"database_specific": {
"cwe_ids": [
"CWE-807"
],
"github_reviewed": true,
"github_reviewed_at": "2020-03-23T23:07:41Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "# Python Auditing Vulnerability\n\nDemonstrates how a malicious package can insert a load-time poison pill to avoid detection by tools like Safety.\n\nTools that are designed to find vulnerable packages can not ever run in the same python environment that they are trying to protect.\n\n## Usage\n\nInstall `safety`, `insecure-package`, and this package with pip in the same python environment. Order doesn\u0026amp;#39;t matter.\n\n1. pip install safety\n2. pip install insecure-package\n3. pip install dist/malicious-0.1-py3-none-any.whl\n\nRun the check\n\n4. `safety check`\n\nYou should see both `Running my modified safety.check` and that `insecure-package` is not listed in the results!\n\n\n## How it Works\n\nEverything in Python is mutable. The trick is getting some code to run at interpreter load time in order to do some patching.\n\n1. When you install this package, the `setup.py` settings installs a `malicious.pth` file to your `site-packages` directory.\n2. The `malicious.pth` file gets loaded anytime Python starts, which in turn imports our `malicious` package.\n3. The `malicious/__init__.py` patches the safety library with a custom function to avoid detection.",
"id": "GHSA-7q25-qrjw-6fg2",
"modified": "2024-10-21T21:06:25Z",
"published": "2020-03-24T15:07:56Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/pyupio/safety/security/advisories/GHSA-7q25-qrjw-6fg2"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-5252"
},
{
"type": "WEB",
"url": "https://github.com/akoumjian/python-safety-vuln"
},
{
"type": "WEB",
"url": "https://github.com/pypa/advisory-database/tree/main/vulns/safety/PYSEC-2020-101.yaml"
},
{
"type": "PACKAGE",
"url": "https://github.com/pyupio/safety"
},
{
"type": "WEB",
"url": "https://mulch.dev/blog/CVE-2020-5252-python-safety-vuln"
},
{
"type": "WEB",
"url": "https://pyup.io/posts/patched-vulnerability"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:C/C:N/I:H/A:N",
"type": "CVSS_V3"
}
],
"summary": "Malicious package may avoid detection in python auditing"
}
Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline
Sightings and recorded dates, grouped by day · UTC
Loading timeline…
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.