`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.
- Published
- Jul 28, 2026
- Updated
- Aug 6, 2026
- EPSS
- 0.7% · 52th percentile
- CWE
- CWE-94
Sign in to follow · You’ll be notified if a followed record enters KEV, gets an exploit or is updated.
Report tools
Action score
35
Monitor
Low priority for now.
- CVSS
- 35 / 40 · 8.8 / 10
- CISA KEV
- 0 / 30 · Not listed
- EPSS
- 0 / 30 · 0.7%
CISA SSVC decision
- Exploitation
- none
- Automatable
- no
- Technical impact
- total
Vulnrichment: CISA's decision-tree inputs.
CNA vs NVD score
- NVD
- —
- CNA · GitHub_M
- 8.8
- NVD has not scored this yet; the score shown is the CNA’s.
The score given by the assigning authority versus NVD’s independent score. A gap means the severity is contested.
Noroxi analysis
No Noroxi analysis for this record yet
We don't hand-write analysis for the hundreds of thousands of vulnerabilities in the database; that wouldn't be honest. For notable, high-impact vulnerabilities our team writes the mechanism, detection and remediation steps.
We use this product, ask for helpAffected systems
| Vendor | Product | CPE |
|---|---|---|
| koxudaxi | datamodel-code-generator | cpe:2.3:a:koxudaxi:datamodel-code-generator |
Affected versions
NVD version ranges (for catalog products). Add the product to your stack with a version and matching uses these.
- koxudaxi datamodel-code-generator0.17.0 and later · before 0.60.2
Versions reported by the vendor
Affected version ranges reported by the assigning authority (GitHub_M). Independent of NVD's CPE analysis and usually ahead of it.
koxudaxi datamodel-code-generator
- >= 0.17.0, < 0.60.2affected
Package-level exposure
OSV and GitHub Advisory data: ecosystem, package and range. SBOM matching uses this table.
| Ecosystem | Package | Affected range | Fix |
|---|---|---|---|
| PyPI | datamodel-code-generator | from 0.17.0 · before 0.60.2 | 0.60.2 |
Same product
koxudaxi: all recordsOther highest-scoring records for the same primary product.
- CVE-2026-54691datamodel-code-generator vulnerable to SSRF via --url: no host/IP validation, follows redirects32Monitor
- CVE-2026-54690datamodel-code-generator vulnerable to SSRF via JSON-Schema `$ref` to HTTP URL (silent by default)32Monitor
- CVE-2026-54656`datamodel-code-generator` vulnerable to code execution on import via unescaped `validators` entries in --extra-template-data31Monitor
- CVE-2026-54655`datamodel-code-generator` vulnerable to code execution on import via `x-python-type` JSON-Schema extension in datamodel-code-generator31Monitor
- CVE-2026-54654`datamodel-code-generator` vulnerable to code injection via unescaped carriage return in `--extra-template-data` `comment` field31Monitor
- CVE-2026-54621`datamodel-code-generator` vulnerable to code injection via unescaped carriage return in GraphQL Union description31Monitor
Remediation
Which version to upgrade to
Fix versions compiled from the vendor, package registries and Microsoft. Verify the vendor's note before upgrading.
| Product / package | Fixed version | Source |
|---|---|---|
| koxudaxi datamodel-code-generator | 0.60.2 · description | Vendor (CNA) |
| PyPI:datamodel-code-generator | 0.60.2 | Package registry (OSV) |
Exploit status
No known public exploit
No public exploit has been observed yet. That doesn't mean you're safe, only that the bar is a little higher.
Research context
For pentesters and researchers: attack profile, score disagreement, timeline, patch commits, credits, variant and chain candidates, bug bounty scope. All derived from existing data; no exploit code.
Timeline
From publication to today: proof of concept, Metasploit module, CISA KEV and fix record. Dates are as reported by the sources.
No dated events beyond publication.
FIRST EPSS daily score; only changes of 0.01 or more are recorded (step chart).
Patch and commit links
Commit, PR and diff links among the references. A starting point for patch-diffing and variant hunting; fixes, not exploits.
Credits
All researchersFinders, reporters and analysts named in the CNA record. Click a name for that researcher’s other records.
No credits in the CNA record.
Variant candidates
Same product, same weakness class, within 18 months. If the patch missed the root cause, the sibling bug is here.
- CVE-2026-546210 days apart`datamodel-code-generator` vulnerable to code injection via unescaped carriage return in GraphQL Union description31Monitor
- CVE-2026-546540 days apart`datamodel-code-generator` vulnerable to code injection via unescaped carriage return in `--extra-template-data` `comment` field31Monitor
- CVE-2026-546550 days apart`datamodel-code-generator` vulnerable to code execution on import via `x-python-type` JSON-Schema extension in datamodel-code-generator31Monitor
- CVE-2026-546560 days apart`datamodel-code-generator` vulnerable to code execution on import via unescaped `validators` entries in --extra-template-data31Monitor
- CVE-2026-554150 days apartdatamodel-code-generator vulnerable to code injection via `x-python-import` / `customTypePath` in generated import statements30Monitor
- CVE-2026-637202 days apartdatamodel-code-generator Code Injection via Unvalidated customBasePath Schema Field30Monitor
Chain candidates
An authentication bypass and a privilege-requiring bug in the same product, published close together: combined they may become an unauthenticated path.
—
Bug bounty scope
No known public program.
Source: bounty-targets-data (public HackerOne, Bugcrowd, Intigriti, YesWeHack listings).
Technical details
Attack conditions
- Anyone who can reach it over the internet can trigger it.
- No account or password is required.
- A user must open a link or visit a page.
- No special conditions are required; it is repeatable.
If successful
- Confidentiality
- high · data can be read
- Integrity
- high · data or configuration can be modified
- Availability
- high · the service can be disrupted
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- Required
- Scope
- Unchanged
- Confidentiality impact
- High
- Integrity impact
- High
- Availability impact
- High
Weakness class (CWE)
CWE-94 · Improper Control of Generation of Code ('Code Injection')CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
nvd-secondary
Attack context
MITRE CAPEC attack patterns and ATT&CK techniques for this weakness class (CWE). A starting point for detection rules and threat hunting.
Attack patterns (CAPEC)
Change log
- Fix✗ → ✓
For records you follow, these changes also arrive as notifications. →
References
- github.com/koxudaxi/datamodel-code-generator/commit/17fc235e234cbcfaaadef8c74cb72c9687db0d1d
- github.com/koxudaxi/datamodel-code-generator/releases/tag/0.60.2
- gist.github.com/thegr1ffyn/9648b0fe4fcf7d569ac8e61dd11eebaf
Vendor advisories and official records. Exploit/PoC links are deliberately left out.