Advisory Database
  • Advisories
  • Dependency Scanning
  1. pypi
  2. ›
  3. safety
  4. ›
  5. CVE-2020-5252

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

March 24, 2020 (updated October 21, 2024)

Python 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.

  1. pip install safety
  2. pip install insecure-package
  3. pip install dist/malicious-0.1-py3-none-any.whl

Run the check

  1. 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.

  1. When you install this package, the setup.py settings installs a malicious.pth file to your site-packages directory.
  2. The malicious.pth file gets loaded anytime Python starts, which in turn imports our malicious package.
  3. The malicious/__init__.py patches the safety library with a custom function to avoid detection.

References

  • github.com/advisories/GHSA-7q25-qrjw-6fg2
  • github.com/akoumjian/python-safety-vuln
  • github.com/pypa/advisory-database/tree/main/vulns/safety/PYSEC-2020-101.yaml
  • github.com/pyupio/safety
  • github.com/pyupio/safety/security/advisories/GHSA-7q25-qrjw-6fg2
  • mulch.dev/blog/CVE-2020-5252-python-safety-vuln
  • nvd.nist.gov/vuln/detail/CVE-2020-5252
  • pyup.io/posts/patched-vulnerability

Code Behaviors & Features

Detect and mitigate CVE-2020-5252 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 1.9.0

Fixed versions

  • 1.9.0

Solution

Upgrade to version 1.9.0 or above.

Impact 4.1 MEDIUM

CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:N/I:H/A:N

Learn more about CVSS

Weakness

  • CWE-807: Reliance on Untrusted Inputs in a Security Decision

Source file

pypi/safety/CVE-2020-5252.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 14 May 2025 12:15:19 +0000.