Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessAttacker crafts JSON Schema with internal $ref URL
-
DeliveryVictim developer/CI runs datamodel-codegen on it
-
ExploitTool silently dereferences ref via _get_ref_body
-
ExecutionSSRF fetch hits internal host, redirects followed
-
ImpactResponse reflected into generated Python code, internal data leaked
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A01:2025 - Broken Access Control
ASVS 5.0
V4 - API and Web Service URL allowlisting, SSRF prevention
MITRE ATT&CK
2 techniques across 2 tactics: Initial Access, Credential Access The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Requires the optional HTTP extra to be installed (pip install 'datamodel-code-generator[http]'); without it there is no network fetcher and the flaw is not reachable. The tool must be run on a JSON Schema / OpenAPI / other supported document that the attacker controls or influenced (a $ref containing an attacker-chosen HTTP/HTTPS URL). Exploitation fires under the default configuration where --allow-remote-refs is unset (None), which only warns and then fetches; it is blocked only by explicitly passing --allow-remote-refs=false. Note --url implies remote-ref fetching. The primary limiting factor is required user interaction (UI:R): a developer or automated codegen/CI step must actually invoke datamodel-codegen against the malicious document - there is no standalone network-listening service to attack. |
| Impact | Signals are consistent and point to a real-but-moderate priority rather than an emergency. The CVSS 3.1 vector (AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N, base 8.2 High) reflects a network-reachable, low-complexity, unauthenticated SSRF whose severity is inflated by S:C and C:H. EPSS is low at 0.21% (11th percentile) and there is no CISA KEV listing, so no active exploitation is indicated - SSVC confirms this with exploitation:poc, automatable:no, technical-impact:partial. Public exploit code exists (two gists plus a vuldb advisory), so weaponization is trivial once a target is reachable, but the automatable:no and UI:R factors mean this cannot be sprayed at scale - it requires a developer to run the tool on an attacker-influenced schema. The vendor's C:H is arguably overstated: SSVC rates technical impact only 'partial' and the leak is limited to schema-shaped fields (title/description/properties) reflected into generated code, so C:L is more defensible. A key limiting factor not captured in the base score is that the flaw only affects installations that added the optional [http] extra. Net: prioritize patching in CI/codegen pipelines that fetch third-party schemas, but this is not a mass-exploitation internet threat. |
| Exploit ScenarioDerived | A developer or CI pipeline runs datamodel-codegen (installed with the [http] extra) against a JSON Schema or OpenAPI document of uncertain provenance that contains a |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Sep 16, 2026
Server-side request forgery in datamodel-code-generator 0.9.1 through 0.60.x lets a malicious JSON Schema, OpenAPI, or GraphQL document cause the code generator to silently fetch attacker-chosen HTTP/HTTPS $ref URLs - including internal, loopback, and link-local addresses - and reflect the fetched content into the generated Python source. Exploitation requires the optional HTTP extra (pip install 'datamodel-code-generator[http]') and a developer or automated codegen/CI job to run datamodel-codegen against the tainted document; the default configuration (--allow-remote-refs unset) only emits a deprecation warning before fetching, and only an explicit --allow-remote-refs=false blocks the request. Publicly available exploit code exists (a Gist proof-of-concept), and EPSS is low at 0.21% (11th percentile), with no confirmed active exploitation (not in CISA KEV); fixed in 0.61.0.
RemediationAI
Upgrade to datamodel-code-generator 0.61.0 or later (pip install --upgrade 'datamodel-code-generator[http]'); this is the vendor-released patch containing commit 5fdba4a, which adds the --allow-private-network gate defaulting to False and blocks non-public network targets. If immediate upgrade is not possible, the most effective compensating control is to invoke the tool with an explicit --allow-remote-refs=false, which raises an Error instead of warning and fetching - note this will break legitimate workflows that intentionally resolve remote $refs, so any needed remote schemas should be vendored locally first. Because the vulnerable behavior only triggers with the network-capable extra, uninstalling it (reinstalling the package without [http]) removes the fetcher entirely at the cost of losing remote-URL support. Running codegen only on schemas of trusted provenance, and executing datamodel-codegen inside a sandbox or CI container with egress restricted to the public internet (blocking RFC1918, 127.0.0.0/8, 169.254.0.0/16, and cloud metadata endpoints) limits both the SSRF reach and the leakage of responses into generated source; this is a defense-in-depth measure and not a substitute for patching. References: https://github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-954p-556p-r752, https://github.com/koxudaxi/datamodel-code-generator/releases/tag/0.61.0, and https://github.com/koxudaxi/datamodel-code-generator/commit/5fdba4a09f2d7a9996a504975b7ef7d63e3715bb.
Affected VersionsENISA
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in pypi
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
The flaw is a classic SSRF (CWE-918) rooted in the JSON Schema $ref resolution logic of src/datamodel_code_generator/parser/jsonschema.py. In the affected range, _get_ref_body() checks is_url(resolved_ref) and, when allow_remote_refs is False, raises an error - but when allow_remote_refs is None (the default added in 0.56.0), it merely calls warn_deprecated() and falls through to _get_ref_body_from_url(), which routes the URL through _get_text_from_url()/get_body() in src/datamodel_code_generator/http.py. That fetcher performs no IP or host validation, applies no scheme allow-list, and follows HTTP redirects unconditionally, so a $ref such as "$ref": "http://169.254.169.254/latest/meta-data/" or an internal service URL will be dereferenced. The retrieved body is then parsed as a sub-schema and merged into the model graph, so attacker-influenced fields (title, description, properties) are rendered verbatim into the emitted .py file - turning the SSRF into a data-exfiltration path into generated code. The fix commit 5fdba4a adds a new --allow-private-network flag (default False) to docs, __init__.py, __main__.py, and _types, blocking private/loopback/link-local targets unless explicitly allowed, and tightens the interaction between --url and --allow-remote-refs. Only installations with the [http] extra are reachable, since without it there is no network fetcher.
Know when Datamodel Code Generator gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N
Unauthenticated attacker supplies a schema but a developer must run the tool (UI:R); SSRF pivots to internal systems (S:C); only reflected schema fields leak (C:L) and generated code is tainted (I:L), no availability impact.
Primary rating from Vendor (GitHub_M).
CVSS VectorVendor: GitHub_M
Lifecycle Timeline
2DescriptionCVE.org
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.9.1 until 0.61.0, datamodel-code-generator silently dereferences attacker-controlled JSON Schema $ref HTTP or HTTPS URLs in src/datamodel_code_generator/parser/jsonschema.py through _get_ref_body, and the --allow-remote-refs gate can warn instead of blocking, allowing server-side request forgery through src/datamodel_code_generator/http.py. This issue is fixed in version 0.61.0.
Latest POC
1 PoC candidate from github (unverified)
Sign in to open the public PoC links collected for this CVE.
Executive ViewAI
A server-side request forgery flaw in datamodel-code-generator (versions 0.9.1 through 0.60.x) lets a malicious JSON Schema, OpenAPI, or GraphQL document cause developer workstations and CI/CD code-generation jobs to fetch attacker-chosen URLs - including internal, loopback, and cloud metadata endpoints - and silently embed the responses into generated Python source. Any engineering team running datamodel-codegen with the optional HTTP extra against third-party or untrusted API specifications is exposed to internal network reconnaissance and possible credential or secret theft from build environments. Because this tool typically executes inside pipelines with broad network reach, leadership should treat it as a software supply-chain and CI/CD exposure rather than a routine library update.
Apply vendor patch.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Server-Side Request Forgery exploits applications that fetch remote resources based on user-supplied URLs.
More in Datamodel Code Generator
View allCode injection via unescaped validator entries in datamodel-code-generator's --extra-template-data feature allows arbitr
Processing an attacker-controlled Protobuf schema with datamodel-code-generator 0.59.0 through 0.80.0 lets a crafted wea
Arbitrary local file read in datamodel-code-generator before 0.62.0 lets unauthenticated attackers who control or can su
A DNS rebinding flaw in datamodel-code-generator's SSRF guard allows unauthenticated remote attackers to bypass the defa
Code injection in datamodel-code-generator 0.17.0–0.60.1 allows attackers who control a schema’s default_factory value t
Code injection in datamodel-code-generator allows an attacker who controls a JSON Schema to embed arbitrary Python code
Code injection in datamodel-code-generator versions before 0.60.1 allows an attacker who provides a malicious GraphQL sc
We are generating a synthetic analysis for CVE-2026-54654. We have a lot of data: description, CVSS, CWE, tags, referenc
Remote code execution in datamodel-code-generator prior to version 0.70.0 allows attackers who control input schemas to
Arbitrary local file read in datamodel-code-generator versions 0.59.0 to 0.61.0 via path traversal in XSD parsing allows
Code injection via unsanitized schema extensions in datamodel-code-generator allows arbitrary Python code execution when
Sensitive header disclosure in datamodel-code-generator allows Authorization, Cookie, and Proxy-Authorization headers to
EUVD-2026-50074
GHSA-954p-556p-r752
NVD
CVE.org
EPSS
Vulnrichment
VulDB
Exploit-DB