Intel

AIKIDO-2026-778122

datamodel-code-generator is vulnerable to Code Injection

CVE-2026-54653Published Jun 18, 2026
June 18, 2026

88

CVE Score

High

Code Injection

Are you affected? Scan for Free

TL;DR

When generating Python models from attacker-controlled JSON Schema, OpenAPI, or related schema input, schema-provided default_factory values are interpolated verbatim into generated Field(default_factory=...) or field(default_factory=...) calls without validation. The expression is evaluated at class-definition time when the generated module is imported, enabling arbitrary code execution in the developer or CI process. Default invocation against a malicious schema reaches this sink without special CLI flags. The fix whitelists only dict, list, and set as allowed factory names and rejects other values before code generation.

How do I fix this?

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

Who does this affect?

You are affected if you are using a version that falls within the vulnerable range.

Versions

0.17.0 - 0.60.1

Fixed in 0.60.2

Background info

datamodel-code-generator is vulnerable to Code Injection in versions 0.17.0 - 0.60.1.

Get secure today,
quickly and for free.

Secure your code, cloud, and runtime in one central system. Connect a repo to discover what the reasoning agents find in your codebase.

No credit card required | Scan results in 32 seconds.

Trusted by 150k+ orgs
  • Revolut
  • n8n
  • Lovable
  • Deel
  • Prove
  • Omnea