CVE-2026-54621
HighCVSS 7.8Exploitation Probability (EPSS)
Low risk4th percentile - higher than 4% of all known CVEs
Summary
The datamodel-code-generator tool before version 0.60.1 renders GraphQL Union description values into Python comments without neutralizing carriage returns, allowing Python code injection into generated models.
Risk Assessment
An attacker can inject malicious Python code via controlled GraphQL schema content, which executes upon model import.
Recommendation
Update datamodel-code-generator to version 0.60.1 or later.
Other vulnerabilities in datamodel-code-generator
See all- CVE-2026-107377High
datamodel-code-generator from 0.59.0 until 0.81.0 has a vulnerability where an attacker-controlled Protobuf schema can supply absolute or parent-directory paths captured by WEAK_IMPORT_PATTERN and consumed by _write_missing_weak_imports. Exploitation requires a victim or automated job to process the schema with Protobuf input support (grpcio-tools). The paths escape the weak_imports temporary directory, allowing creation of directory trees, new files, or overwrite of existing writable files with a generated Protobuf syntax declaration.
- CVE-2026-55415High
In datamodel-code-generator from 0.11.6 to 0.64.0, attacker-controlled x-python-import or customTypePath schema extensions can reach the JSON Schema parser and generate imports that allow newline injection into import statements, executing Python code when the generated model is imported.
- CVE-2026-55403Low
In datamodel-code-generator prior to version 0.63.0, the get_body function reuses Authorization, Cookie, and Proxy-Authorization headers when following cross-origin redirects while fetching remote schemas, potentially leaking credentials to external servers. This issue has been fixed in version 0.63.0.
- CVE-2026-55391High
In datamodel-code-generator before version 0.63.0, URL host validation checks the host once but then allows httpx to resolve the host again for the connection, enabling DNS rebinding to bypass allow_private_network=False and reach internal services.
- CVE-2026-55390High
In datamodel-code-generator from 0.59.0 to 0.62.0, XML Schema parsing resolves schemaLocation values in xs:include, xs:import, xs:redefine, and xs:override outside the input base path, allowing arbitrary local files to be read and reflected into generated models.
- CVE-2026-55389High
The datamodel-code-generator tool before version 0.62.0 improperly handles JSON Schema $ref references, allowing arbitrary local file reads. The vulnerability is in jsonschema.py, which does not block file:// or ../ paths outside the input directory.
- CVE-2026-54691High
The datamodel-code-generator tool from version 0.9.1 to 0.61.0 does not validate hosts/IPs in URL targets and redirects, enabling SSRF attacks against internal resources. The vulnerability is in the http.get_body function.
- CVE-2026-54690High
The datamodel-code-generator tool from version 0.9.1 to 0.61.0 automatically dereferences JSON Schema $ref references from HTTP/HTTPS without proper blocking, enabling SSRF attacks. The --allow-remote-refs flag only warns instead of blocking.
- CVE-2026-54656High
The datamodel-code-generator tool from version 0.52.1 to 0.60.2 interpolates validators from --extra-template-data without safe validation, allowing Python code execution when the generated Pydantic v2 model is imported.
- CVE-2026-54655High
The datamodel-code-generator tool from version 0.51.0 to 0.60.2 inserts x-python-type values into field annotations without sufficient validation, allowing Python code execution when the generated module is imported.
Original NVD description (English source)
datamodel-code-generator generates Python data models from schema definitions. Prior to 0.60.1, GraphQL Union description values in src/datamodel_code_generator/model/template/UnionTypeStatement.jinja2 and src/datamodel_code_generator/model/template/UnionTypeStatement.py312.jinja2 are rendered into Python comments without neutralizing carriage returns in Python # comments, allowing attacker-controlled GraphQL schema content to inject Python code into generated models that runs when imported. This issue is fixed in version 0.60.1.
Vulnerability data from NVD (NIST) · CISA KEV · EPSS

