Executive brief
datamodel-code-generator is a tool used by developers to automatically create Python code from data schemas like OpenAPI or JSON Schema. A security flaw allows an attacker to provide a malicious schema file that forces the tool to make unauthorized network requests to internal services or private data centers. If exploited, sensitive information from these internal systems—such as cloud credentials or private database records—could be leaked directly into the generated Python code, potentially exposing it to the developer or within automated build systems.
Technical details
A Server-Side Request Forgery (SSRF) vulnerability exists in datamodel-code-generator within the `_get_ref_body` function of `src/datamodel_code_generator/parser/jsonschema.py`. The tool silently dereferences HTTP/HTTPS URLs in JSON Schema `$ref` fields without validating the destination IP or host, even when the `--allow-remote-refs` gate is at its default setting (which only issues a deprecation warning). An attacker can craft a schema that points to internal metadata services (e.g., AWS IMDS) or private network endpoints; the tool will fetch the content and reflect the response body into the generated Python models. This affects users who have installed the `[http]` extra. The issue is fixed in version 0.61.0 by implementing strict validation of redirect targets and blocking non-public network ranges by default unless the new `--allow-private-network` flag is used.
Affected products
- koxudaxi datamodel-code-generator >= 0.9.1, < 0.61.0
Timeline
- 2026-06-08: patched: Version 0.61.0 released
- 2026-06-08: advisory: GitHub Security Advisory GHSA-954p-556p-r752 published
- 2026-07-28: disclosed: CVE-2026-54690 published to NVD