LiveActive security incident?Get immediate response
CVE Record

CVE-2026-54621: `datamodel-code-generator` vulnerable to code injection via unescaped carriage return in GraphQL Union description

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.

HighCVSS 7.8Not KEV-listedUpdated
Glexia's TakeAutomated analysishigh

Security readout for executives and security teams

Plain-English summary

A malicious GraphQL schema can turn generated model code into a delivery path for attacker-controlled Python. The injected code executes only when someone generates models from the crafted schema and later imports them, but successful exploitation could compromise confidentiality, integrity, and availability.

Executive priority

Prioritize remediation for build systems accepting partner, customer, repository, or internet-sourced GraphQL schemas. Upgrade promptly and examine previously generated artifacts. Lower urgency is reasonable only after confirming affected versions are absent or schema inputs are fully trusted.

Technical view

Versions 0.25.0 through 0.60.0 fail to neutralize carriage returns in GraphQL Union descriptions rendered into Python comments. A carriage return can escape the intended comment context and inject Python into generated models. Importing the generated module executes that code. Version 0.60.1 fixes both affected UnionTypeStatement templates.

Likely exposure

Exposure is most likely in development, CI/CD, or automation workflows using affected versions to process GraphQL schemas from untrusted or externally influenced sources. Systems that neither generate from GraphQL schemas nor import resulting models are unlikely to reach the vulnerable execution path.

Exploitation context

Exploitation requires attacker-controlled GraphQL Union description content, model generation, and subsequent import of the generated Python. User or workflow interaction is therefore required. The supplied record is not in KEV, and the provided sources do not establish active exploitation.

Researcher notes

The affected range is 0.25.0 through 0.60.0. The weakness is template-context code injection involving carriage returns inside Python comment output, mapped to CWE-1336 and CWE-94. Evidence supports arbitrary Python execution upon import, but the bundle provides no evidence of exploitation in the wild.

Mitigation direction

  • Upgrade datamodel-code-generator to version 0.60.1 or later.
  • Restrict schema inputs to trusted, authenticated sources until upgrading.
  • Regenerate affected models with the fixed version before importing or deploying them.
  • Review previously generated Python before continued use where schema provenance is uncertain.

Validation and detection

  • Inventory installed and CI-pinned datamodel-code-generator versions.
  • Identify workflows that generate Python models from GraphQL schemas.
  • Verify whether external parties can influence GraphQL Union descriptions.
  • Confirm regenerated models use version 0.60.1 or later.
  • Review historical generated files and build artifacts from untrusted schemas.
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-54621 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
7.8 (3.1)
Known Exploited
No
Published

Vector: CVSS:3.1/AV:L/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
4Source 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
7.8CVSS 3.1HighCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H1.85.9GitHub_M

Vulnerability scoring details

Base CVSS 3.1 score

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

Vector: CVSS:3.1/AV:L/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.25.0, < 0.60.1Listed
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.