GHSA-7q25-qrjw-6fg2

Source
https://github.com/advisories/GHSA-7q25-qrjw-6fg2
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2020/03/GHSA-7q25-qrjw-6fg2/GHSA-7q25-qrjw-6fg2.json
Aliases
Published
2020-03-24T15:07:56Z
Modified
2024-02-16T08:05:14.412542Z
Details

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

Affected packages

PyPI / safety

Package

Name
safety

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0The exact introduced commit is unknown
Fixed
1.9.0

Affected versions

0.*

0.1.0
0.2.0
0.2.1
0.2.2
0.3.0
0.4.0
0.5.0
0.5.1
0.6.0

1.*

1.0.0
1.0.1
1.0.2
1.1.0
1.1.1
1.2.0
1.3.0
1.4.0
1.4.1
1.5.0
1.5.1
1.6.0
1.6.1
1.7.0
1.8.0
1.8.1
1.8.2
1.8.3b0
1.8.3
1.8.4
1.8.5
1.8.6
1.8.7