Attacker Value
Moderate
(1 user assessed)
Exploitability
Moderate
(1 user assessed)
User Interaction
None
Privileges Required
High
Attack Vector
Local
0

CVE-2020-5252

Disclosure Date: March 23, 2020
Add MITRE ATT&CK tactics and techniques that apply to this CVE.

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.

Add Assessment

2
Ratings
  • Attacker Value
    Medium
  • Exploitability
    Medium
Technical Analysis

Description

This is more of a bad configuration and practice from the user that allows an attacker to infect the command-line Safety package’s detection routines by disguising, or obfuscating, other malicious or non-secure packages.

Vulnerable configurations

  • 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.
    This can easily be fixed.

Exploitation

A malicious package can avoid detection by Safety on load by running code in init.py such as seen in https://github.com/akoumjian/python-safety-vuln/blob/master/malicious/__init__.py which contains a patch.
This results in the package not to be flagged as malicious.

PoC

A great PoC and explanation is available at https://github.com/akoumjian/python-safety-vuln

CVSS V3 Severity and Metrics
Base Score:
4.1 Medium
Impact Score:
3.6
Exploitability Score:
0.5
Vector:
CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:N/I:H/A:N
Attack Vector (AV):
Local
Attack Complexity (AC):
High
Privileges Required (PR):
High
User Interaction (UI):
None
Scope (S):
Unchanged
Confidentiality (C):
None
Integrity (I):
High
Availability (A):
None

General Information

Vendors

  • pyup

Products

  • safety

Additional Info

Technical Analysis