Skip to main content

CVE-2022-36069: CWE-94: Improper Control of Generation of Code ('Code Injection') in python-poetry poetry

Medium
Published: Wed Sep 07 2022 (09/07/2022, 18:30:19 UTC)
Source: CVE
Vendor/Project: python-poetry
Product: poetry

Description

Poetry is a dependency manager for Python. When handling dependencies that come from a Git repository instead of a registry, Poetry uses various commands, such as `git clone`. These commands are constructed using user input (e.g. the repository URL). When building the commands, Poetry correctly avoids Command Injection vulnerabilities by passing an array of arguments instead of a command string. However, there is the possibility that a user input starts with a dash (`-`) and is therefore treated as an optional argument instead of a positional one. This can lead to Code Execution because some of the commands have options that can be leveraged to run arbitrary executables. If a developer is exploited, the attacker could steal credentials or persist their access. If the exploit happens on a server, the attackers could use their access to attack other internal systems. Since this vulnerability requires a fair amount of user interaction, it is not as dangerous as a remotely exploitable one. However, it still puts developers at risk when dealing with untrusted files in a way they think is safe, because the exploit still works when the victim tries to make sure nothing can happen, e.g. by vetting any Git or Poetry config files that might be present in the directory. Versions 1.1.9 and 1.2.0b1 contain patches for this issue.

AI-Powered Analysis

AILast updated: 06/21/2025, 23:40:23 UTC

Technical Analysis

CVE-2022-36069 is a code injection vulnerability identified in python-poetry, a popular dependency manager for Python projects. The vulnerability arises when Poetry handles dependencies sourced from Git repositories rather than standard package registries. Specifically, Poetry constructs commands such as 'git clone' using user-supplied input, for example, the repository URL. While Poetry mitigates command injection risks by passing command arguments as arrays instead of concatenated strings, it does not adequately handle cases where user input begins with a dash ('-'). Such inputs are interpreted as optional command-line arguments rather than positional parameters. This misinterpretation can be exploited because some Git or Poetry commands accept options that allow execution of arbitrary executables. Consequently, an attacker who crafts a malicious repository URL or related input starting with a dash can cause Poetry to execute unintended code during dependency installation or updates. This code execution could lead to credential theft, unauthorized persistence, or lateral movement within an organization's internal network if exploited on a server. The vulnerability requires user interaction, such as a developer explicitly installing or updating dependencies from a malicious Git repository, which reduces its risk compared to fully remote exploits. However, it remains dangerous because it can bypass typical vetting processes, including inspection of Git or Poetry configuration files, giving a false sense of security to developers. Versions of Poetry prior to 1.1.9 are affected, while versions 1.1.9 and 1.2.0b1 include patches addressing this issue. No known exploits have been reported in the wild to date. The underlying weakness corresponds to CWE-94, improper control of code generation, specifically code injection via command argument parsing.

Potential Impact

For European organizations, especially those heavily reliant on Python development and continuous integration/deployment pipelines, this vulnerability poses a moderate risk. Developers who incorporate dependencies from Git repositories without strict validation could inadvertently execute malicious code, leading to credential compromise or unauthorized access. In enterprise environments, compromised developer machines or build servers could serve as entry points for attackers to infiltrate internal networks, potentially affecting confidential data and critical infrastructure. The impact is heightened in sectors with stringent data protection requirements, such as finance, healthcare, and government, where unauthorized code execution could lead to data breaches or operational disruptions. However, the requirement for user interaction and the need for a malicious Git repository to be introduced limits the scope of immediate widespread exploitation. Nonetheless, supply chain attacks leveraging this vulnerability could target European software projects, increasing risk to organizations that consume or produce open-source Python packages. The vulnerability also undermines trust in dependency management processes, which are integral to modern software development.

Mitigation Recommendations

1. Upgrade Poetry to version 1.1.9 or later immediately to ensure the vulnerability is patched. 2. Implement strict validation and sanitization of all Git repository URLs and related inputs before use in dependency management commands, explicitly rejecting inputs starting with dash characters or other suspicious patterns. 3. Enforce policies restricting the use of dependencies from untrusted or unverified Git repositories, favoring official package registries when possible. 4. Integrate automated scanning tools in CI/CD pipelines to detect and flag potentially malicious or malformed dependency sources. 5. Educate developers about the risks of installing dependencies from untrusted sources and encourage manual review of dependency manifests and lock files. 6. Use containerization or sandboxing for build environments to limit the impact of any code execution during dependency installation. 7. Monitor developer and build environments for unusual process executions or network activity that could indicate exploitation attempts. 8. Maintain up-to-date backups and incident response plans to quickly recover from potential compromises stemming from this vulnerability.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
GitHub_M
Date Reserved
2022-07-15T00:00:00.000Z
Cisa Enriched
true

Threat ID: 682d9849c4522896dcbf68f4

Added to database: 5/21/2025, 9:09:29 AM

Last enriched: 6/21/2025, 11:40:23 PM

Last updated: 7/26/2025, 4:44:27 AM

Views: 18

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats