Intel

AIKIDO-2026-387198

datamodel-code-generator is vulnerable to Code Injection

Code InjectionCVE-2026-54621 Published 3 days ago

78

High Risk

This Affects:

PYTHONdatamodel-code-generator
0.25.0 - 0.60.0
Fixed in 0.60.1
Are you affected? Scan for Free

TL;DR

When generating Python models from a GraphQL schema, datamodel-code-generator renders a Union type description into a # comment using a filter that only normalizes newline characters. A bare carriage return in a regular-string description terminates the comment line, so text after it is emitted as module-level Python that executes when the generated model is imported. An attacker who controls the GraphQL schema can inject arbitrary code with no special CLI flags. The fix normalizes carriage returns in Union descriptions before rendering them as comments.

Who does this affect?

You are affected if you are using a version that falls within the vulnerable range and generate models from an untrusted GraphQL schema (--input-file-type graphql).

Background info

datamodel-code-generator is vulnerable to Code Injection in versions 0.25.0 - 0.60.0.

How to fix this

Upgrade the datamodel-code-generator library to the patch version.