CVE-2024-6345: setuptools vulnerable to Command Injection via package URL
8.8
Basic Information
Technical Details
Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
---|---|---|---|
setuptools | pip | < 70.0.0 | 70.0.0 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability was a command injection in the package_index
module of setuptools, specifically within its download functions for VCS repositories. The analysis of the provided commit 88807c7062788254f654ea8c03427adc859321f0
shows that the methods _download_git
and _download_hg
within the PackageIndex
class were responsible for handling git
and hg
repository URLs, respectively. These methods constructed shell commands using os.system
and incorporated parts of the user-supplied URL (like the repository URL itself and revision identifiers) directly into these commands. This is a classic command injection pattern. The patch removed these specific methods and refactored the VCS handling into a new _download_vcs
method which uses subprocess.check_call
with a list of arguments, a safer alternative that prevents command injection by properly handling arguments. The _download_url
method, which was a caller of _download_git
and _download_hg
, was also modified as part of this refactoring. The primary vulnerable functions were _download_git
and _download_hg
due to their direct use of os.system
with unsanitized input from the URL.