ZeroHour

CVE-2026-54690

PoC moderate

SSRF in datamodel-code-generator via attacker-controlled JSON Schema $ref URLs

CVSS 3.1
8.2 high
EPSS
<1%p17
Published
()
Modified
AI analysis

datamodel-code-generator versions 0.9.1 until 0.61.0 contain a server-side request forgery flaw (CWE-918): when generating Pydantic v2 models, dataclasses, TypedDict, or msgspec.Struct from JSON Schema or OpenAPI inputs, the tool silently dereferences $ref entries pointing to attacker-controlled HTTP or HTTPS URLs via _get_ref_body in src/datamodel_code_generator/parser/jsonschema.py. An attacker who supplies a crafted schema — for example a third-party API specification or JSON Schema document processed by a developer or a CI/CD pipeline — can make the tool issue arbitrary HTTP(S) requests from the machine running it through src/datamodel_code_generator/http.py, and the --allow-remote-refs gate can merely warn instead of blocking the fetch. A successful attacker can reach internal network resources and cloud instance-metadata endpoints (high confidentiality impact) and, because fetched $ref bodies become part of the generated schema, can inject attacker-influenced content into the generated code (low integrity impact). Anyone running an affected version against untrusted schemas — developer workstations, CI runners, and automated spec-ingestion pipelines — is affected; the tool is a code-generation utility, not an internet-facing service. No in-the-wild exploitation is known, with a low EPSS (0.3%) and one public advisory reference with proof-of-concept detail (GHSA-954p-556p-r752).

What to do: Upgrade datamodel-code-generator to version 0.61.0 or later. Until then, avoid running affected versions against untrusted or third-party JSON Schema/OpenAPI documents, or confine runs to environments with restricted outbound network access, and do not rely on --allow-remote-refs warnings alone since they may warn rather than block. Review developer and CI/CD logs for unexpected outbound HTTP requests to internal or metadata endpoints originating from model-generation jobs.

Affected
koxudaxi datamodel-code-generator>= 0.9.1 and < 0.61.0 (fixed in 0.61.0)
Estimated exposure
moderate≈ tens of thousands of developer and CI/CD installations (estimate) — The package is a widely adopted PyPI code-generation tool in the Pydantic/FastAPI ecosystem and generating models from third-party API specs in CI pipelines is a common deployment pattern, so plausibly affected environments are estimated…

Order-of-magnitude estimate by the model from install counts, market share and public scan data it knows; verify before quoting.

Description

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.

Vendors
koxudaxi
Products
datamodel-code-generator
Weakness
CWE-918
Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N

In the news

No ingested article mentions this CVE yet.