Vulnerabilities in pkg:pypi/safety
PACKAGECVE-2020-5252 is a MODERATE (CVSS 5.0) malicious package may avoid detection vulnerability (CWE-807: Reliance on Untrusted Inputs in a Security Decision) affecting Safety libraries in the PyPI ecosystem. The issue involves malicious package may avoid detection in python auditing. Remediation is available by upgrading affected packages to version 1.9.0.
pkg:pypi/safety
Vulnerability advisories affecting package pkg:pypi/safety. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-7q25-qrjw-6fg2 | CVE-2020-5252 | MODERATE | Malicious package may avoid detection in python auditing |
CVE-2020-5252 at a Glance
Security Impact
CVSS: 5.0
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:C/C:N/I:H/A:N).
How to Fix CVE-2020-5252
To remediate this vulnerability, upgrade all affected Safety dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install safety>=1.9.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show safety
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2020-5252, inspect your installed packages using pip:
pip show safety
Analyze the terminal output to locate any version of Safety in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.9.0), your application is affected.
Note: The pip show safety command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-807: Reliance on Untrusted Inputs in a Security Decision, where the product uses a protection mechanism that relies on the existence or values of an input, but the input can be modified by an untrusted actor in a way that bypasses the protection mechanism. In Safety, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2020-5252 Affected Safety Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
safety
|
PyPI |
< 1.9.0
|
1.9.0
|
References
Frequently Asked Questions
What is CVE-2020-5252?
Which Safety versions are affected?
What version fixes CVE-2020-5252?
Is safety affected?
What is the CVSS score of CVE-2020-5252?
What CWE is associated with CVE-2020-5252?
How can I check PyPI dependencies for CVE-2020-5252?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-7q25-qrjw-6fg2",
"modified" : "2024-10-21T21:06:25Z",
"published" : "2020-03-24T15:07:56Z",
"aliases" : [ "CVE-2020-5252" ],
"summary" : "Malicious package may avoid detection in python auditing",
"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&#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.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:C/C:N/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "safety"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.9.0"
} ]
} ]
} ],
"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"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-807" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2020-03-23T23:07:41Z",
"nvd_published_at" : null
}
}