LiveActive security incident?Get immediate response
CVE Record

CVE-2026-54653: `datamodel-code-generator` vulnerable to code injection in via attacker-controlled `default_factory` schema field

datamodel-code-generator generates Pydantic v2 models, dataclasses, TypedDict, and msgspec.Struct from OpenAPI, JSON Schema, GraphQL, Avro, Protobuf, and raw JSON, YAML, or CSV. From 0.17.0 until 0.60.2, datamodel-code-generator preserves attacker-controlled default_factory values in src/datamodel_code_generator/parser/jsonschema.py through JsonSchemaObject.init and get_field_extras and emits them into Field(default_factory=...) or field(default_factory=...), allowing Python expression execution when the generated model is imported. This issue is fixed in version 0.60.2.

HighCVSS 8.8Not KEV-listedUpdated
Glexia's TakeAutomated analysishigh

Security readout for executives and security teams

Plain-English summary

A crafted schema can cause this code-generation tool to place an attacker-controlled Python expression into generated models. When a developer, build system, or application imports that generated code, the expression may run with that process’s permissions, potentially compromising data, code, and service availability.

Executive priority

Prioritize immediate remediation for internet-facing schema services and automated build pipelines that consume external specifications. Other installations should patch promptly after determining whether untrusted schemas can enter generation workflows. Investigate suspicious generated files and related process activity if exposure existed.

Technical view

Versions 0.17.0 through 0.60.1 preserve untrusted default_factory values while parsing schemas and emit them into Pydantic or dataclass field declarations. Importing the generated Python module can evaluate the injected expression. CVE-2026-54653 is rated CVSS 8.8 and maps to code-injection weaknesses CWE-1336 and CWE-94. Version 0.60.2 fixes the issue.

Likely exposure

Exposure is highest where affected versions generate Python models from external, user-supplied, downloaded, or otherwise untrusted schemas, and those models are subsequently imported. Installations processing only controlled schemas have lower likelihood, but compromised dependencies or schema repositories remain relevant. Mere installation is insufficient; the vulnerable generation-to-import workflow must occur.

Exploitation context

A public exploit reference exists, demonstrating that technical details are available. However, the supplied sources do not establish active exploitation, and the CVE is not listed as KEV. Exploitation requires a victim workflow to process attacker-controlled schema content and later import the generated Python model.

Researcher notes

The vulnerable flow is JsonSchemaObject initialization through field extras into emitted Field(default_factory=...) or field(default_factory=...). Execution occurs when generated code is imported, explaining the user-interaction requirement. The supplied evidence supports affected versions from 0.17.0 inclusive to below 0.60.2; it does not document confirmed attacks.

Mitigation direction

  • Upgrade datamodel-code-generator to version 0.60.2 or later.
  • Stop processing untrusted schemas with affected versions until upgraded.
  • Quarantine generated models derived from external or unverified schemas.
  • Regenerate affected models from trusted inputs after upgrading.
  • Apply least privilege to build, generation, and application processes.

Validation and detection

  • Inventory datamodel-code-generator versions across developer systems, CI pipelines, and build images.
  • Identify workflows that accept schemas from users, partners, repositories, or network sources.
  • Trace whether generated Python modules are automatically imported, tested, packaged, or deployed.
  • Review generated models for unexpected default_factory expressions or unexplained changes.
  • Confirm upgraded pipelines reject or safely handle malicious default_factory content.
Prepared
Confidence
high
Sources
5

Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.

Potential ATT&CK relevance

Conservative CVE-to-ATT&CK context

These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.

ATT&CK lookup starting points

Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.

cwe · low confidence lookup

CWE-1336: Exact CWE lookup

Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.

Open ATT&CK lookup
cwe · medium confidence lookup

CWE-94: Code execution behavior lookup

Code execution and unsafe deserialization weaknesses often justify reviewing execution behavior and process telemetry. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.

Open ATT&CK lookup
cve · low confidence lookup

CVE-2026-54653 mapping review

Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.

Open ATT&CK lookup
Vulnerability profileCVE Program record
Severity
High
CVSS
8.8 (3.1)
Known Exploited
No
Published

Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

Official CVE source material

CNA and ADP enrichment extracted from CVE v5

These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.

1CVSS vectors
3Timeline events
1ADP providers
5Source links

SSVC decision data

CISA-ADPCISA Coordinator
Timestamp
Version
2.0.3
Exploitation: noneAutomatable: noTechnical Impact: total

CVSS vector scores

1 official score

We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.

ScoreVersionSeverityVectorExploitImpactSource
8.8CVSS 3.1HighCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H2.85.9GitHub_M

Vulnerability scoring details

Base CVSS 3.1 score

8.8High
CVSS 3.1 vector shape for CVE-2026-54653Attack VectorAttack ComplexityPrivileges RequiredUser InteractionScopeConfidentiality ImpactIntegrity ImpactAvailability Impact

Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

Attack Vector
NetworkAdjacentLocalPhysical
Attack Complexity
LowHigh
Privileges Required
NoneLowHigh
User Interaction
NoneRequired
Scope
ChangedUnchanged
Confidentiality Impact
HighLowNone
Integrity Impact
HighLowNone
Availability Impact
HighLowNone

Vulnerability timeline

Timeline events are normalized from CVE metadata, CNA source timelines, ADP timelines, and KEV metadata when present.

  1. CVE reservedCVE Program

    The CVE ID was reserved by the assigning CNA.

  2. CVE publishedCVE Program

    The CVE record was published.

  3. CVE updatedCVE Program

    The CVE record metadata indicates this as the latest update time.

ADP provider summaries

CISA-ADPCISA ADP Vulnrichment
other:ssvc
Affected products

Products and packages named in the record

VendorProductVersion / packageStatus
koxudaxidatamodel-code-generator>= 0.17.0, < 0.60.2Listed
Weakness

CWE details

CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.

CWE-1336 · source CWE mapping

Improper Neutralization of Special Elements Used in a Template Engine

Improper Neutralization of Special Elements Used in a Template Engine represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.

CWE-94 · source CWE mapping

Improper Control of Generation of Code ('Code Injection')

Improper Control of Generation of Code ('Code Injection') represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.