safety
Affected
- introduced
0, fixed1.9.0(ecosystem)
Fixed versions
1.9.0
Fix
- Fixed version
1.9.0pip install --upgrade safety==1.9.0
Advisory
Also known as: CVE-2020-5252, PYSEC-2020-101
Malicious package may avoid detection in python auditing
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.
Run the check
safety checkYou 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.
setup.py settings installs a malicious.pth file to your site-packages directory.malicious.pth file gets loaded anytime Python starts, which in turn imports our malicious package.malicious/__init__.py patches the safety library with a custom function to avoid detection.Medium Basis: The source's own band: MODERATE
0, fixed 1.9.0 (ecosystem)1.9.0
1.9.0pip install --upgrade safety==1.9.0Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0