# CVE-2020-5252: Malicious package may avoid detection in python auditing

> Attackers can bypass Safety package detection by exploiting Python environment characteristics, requiring users to run the tool in isolated environments.

- **Severity:** Medium 5.0 (`CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:C/C:N/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** An administrator
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 23 Mar 2020
- **Updated:** 4 Aug 2024
- **Also known as:** GHSA-7q25-qrjw-6fg2, PYSEC-2020-101

## What is CVE-2020-5252?

CVE-2020-5252 is a medium-severity vulnerability in pyupio safety, published on 23 Mar 2020. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

The command-line "safety" package for Python has a potential security issue. There are two Python characteristics that allow malicious code to “poison-pill” command-line Safety package detection routines by disguising, or obfuscating, other malicious or non-secure packages. This vulnerability is considered to be of low severity because the attack makes use of an existing Python condition, not the Safety tool itself. This can happen if: You are running Safety in a Python environment that you don’t trust. You are running Safety from the same Python environment where you have your dependencies installed. Dependency packages are being installed arbitrarily or without proper verification. Users can mitigate this issue by doing any of the following: Perform a static analysis by installing Docker and running the Safety Docker image: $ docker run --rm -it pyupio/safety check -r requirements.txt Run Safety against a static dependencies list, such as the requirements.txt file, in a separate, clean Python environment. Run Safety from a Continuous Integration pipeline. Use PyUp.io, which runs Safety in a controlled environment and checks Python for dependencies without any need to install them. Use PyUp's Online Requirements Checker.

Weakness: CWE-807 (Reliance on Untrusted Inputs in a Security Decision)

## Which versions are affected by CVE-2020-5252?

3 open source packages ship an affected version, including safety. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `safety` | PyPI | All versions | 1.8.7 |
| `safety` | PyPI | All versions | 1.9.0 |
| `safety` | PyPI | All versions | 1.9.0 |

Products: Pyup Safety.

## How do I fix CVE-2020-5252?

Upgrade safety to a fixed version for your release line: 1.8.7 or 1.9.0.

## Is CVE-2020-5252 being exploited?

There is no known exploitation of CVE-2020-5252 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2020-5252 and fix it if it is affected.

What it is: CVE-2020-5252 is a medium-severity vulnerability in pyupio safety, published on 23 Mar 2020. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2020-5252 in the wild and no public exploit code.

Affected packages and fixed versions:
- safety (PyPI): affected all versions; fixed in 1.8.7
- safety (PyPI): affected all versions; fixed in 1.9.0
- safety (PyPI): affected all versions; fixed in 1.9.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-2020-5252/ (Markdown: https://insights.sbomify.com/CVE-2020-5252/index.md)
```

## Sources

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

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