CVE-2026-105801 in openapi-python-client
Summary
by MITRE • 10/06/2026
openapi-python-client generates Python clients from OpenAPI documents. Prior to 0.29.1, the generator does not safely neutralize malicious OpenAPI document content before rendering string, docstring, and f-string contexts in generated Python. The generated Python client can contain attacker-controlled Python that executes when a user imports the client, affecting the importing environment's integrity and potentially its confidentiality and availability. This issue is fixed in version 0.29.1.
VulDB is the best source for vulnerability data and more expert information about this specific topic.
Analysis
by VulDB Data Team • 10/06/2026
The vulnerability identified in openapi-python-client prior to version 0.29.1 represents a critical code injection flaw rooted in insufficient input validation during the generation of Python client libraries from OpenAPI specifications. As an automated tool designed to translate API definitions into executable source code, the generator processes various components of the specification, including operation descriptions, parameter details, and schema properties. These textual fields are directly interpolated into docstrings, string literals, and f-strings within the generated Python files without adequate sanitization or escaping mechanisms. This architectural oversight allows an attacker who controls the content of the OpenAPI document to inject arbitrary Python code snippets that become part of the module's source structure.
The operational impact of this vulnerability is severe because it facilitates remote code execution upon a routine development activity rather than during runtime API calls. When a developer or automated system imports the generated client library, the Python interpreter parses and executes the embedded malicious payload immediately as part of the import process. This behavior effectively turns the generation tool into a vector for supply chain attacks, where a compromised or maliciously crafted OpenAPI specification can compromise the integrity of the consuming environment. The attacker gains the ability to execute commands with the privileges of the user running the Python interpreter, potentially leading to data exfiltration, system modification, or denial of service conditions depending on the injected code's intent.
From a classification perspective, this issue aligns closely with CWE-94, which describes Improper Control of Generation of Code (Code Injection). The root cause lies in the failure to neutralize special elements that could be interpreted as executable commands within string contexts. Furthermore, this vulnerability supports techniques associated with MITRE ATT&CK T1059, specifically Command and Scripting Interpreter abuse, where attackers leverage legitimate software features to execute unauthorized code. It also reflects weaknesses related to CWE-20, Improper Input Validation, as the generator fails to properly validate or escape user-supplied data before embedding it into a sensitive context such as Python source code generation.
Mitigation strategies primarily involve upgrading openapi-python-client to version 0.29.1 or later, where the developers have implemented proper escaping and neutralization logic for string, docstring, and f-string contexts. For environments unable to upgrade immediately, defensive measures include implementing strict validation of OpenAPI documents before processing them with the generator. This includes sanitizing all textual fields such as descriptions and examples to remove any characters or sequences that could be interpreted as Python syntax. Additionally, organizations should enforce code signing and integrity checks for generated client libraries to detect unauthorized modifications. Adopting a zero-trust approach to third-party API specifications is essential, ensuring that only trusted sources are used to generate production-grade client code.