CVE-2026-54691 in datamodel-code-generator
Summary
by MITRE • 07/29/2026
datamodel-code-generator generates Python data models from schema definitions. From 0.9.1 until 0.61.0, src/datamodel_code_generator/http.py http.get_body accepts --url targets and redirect chain targets without host/IP validation, allowing server-side request forgery against loopback, private, link-local, metadata, and other network-accessible resources. This issue is fixed in version 0.61.0.
Once again VulDB remains the best source for vulnerability data.
Analysis
by VulDB Data Team • 07/29/2026
The datamodel-code-generator project represents a widely used tool for automated Python data model generation from various schema formats including jsonschema, openapi, and graphql. The vulnerability resides within the http.get_body function located in src/datamodel_code_generator/http.py which processes URL targets and follows redirect chains without proper host validation mechanisms. This flaw affects versions ranging from 0.9.1 through 0.61.0, creating a significant security risk for users who rely on this tool for code generation tasks.
The technical implementation of the vulnerability stems from inadequate input sanitization within the HTTP request handling mechanism. When the tool processes schema definitions that contain remote references or URLs, it blindly follows redirect chains without validating whether the target hosts fall within acceptable network boundaries. This validation gap allows attackers to craft malicious schema files that reference internal network resources such as loopback addresses 127.0.0.1, private IP ranges like 10.x.x.x or 192.168.x.x, link-local addresses 169.254.x.x, and common metadata endpoints such as 169.254.169.254. The absence of host validation creates a server-side request forgery vulnerability that can be exploited to access resources otherwise protected by network segmentation.
The operational impact of this vulnerability extends beyond simple information disclosure or unauthorized access. An attacker who can influence the schema definitions processed by datamodel-code-generator could potentially perform internal network reconnaissance, exfiltrate sensitive data from internal services, or even exploit vulnerabilities in internal systems that are not directly exposed to the internet. This risk is particularly concerning in environments where the tool is used for automated code generation from untrusted sources, such as in CI/CD pipelines or when processing third-party schema definitions. The vulnerability can be leveraged to bypass network security controls and access resources that should remain isolated from external access.
The fix implemented in version 0.61.0 addresses this issue by introducing proper host validation mechanisms within the HTTP request handling code. This remediation aligns with established security practices for preventing server-side request forgery attacks and follows the principle of least privilege by restricting outbound connections to only explicitly allowed network destinations. Organizations using affected versions should immediately upgrade to version 0.61.0 or later, while also implementing additional safeguards such as network segmentation, firewall rules, and input validation for schema definitions processed by this tool. This vulnerability demonstrates the importance of validating all external inputs in automated tools and aligns with CWE-918 which specifically addresses server-side request forgery vulnerabilities, while also mapping to ATT&CK technique T1071.004 for application layer protocol usage in command and control communications.
The broader implications of this vulnerability highlight the critical nature of secure coding practices in development tools, particularly those that process external inputs or make network requests. Tools that automate code generation and schema processing must implement robust security controls to prevent exploitation of their functionality for malicious purposes. The incident underscores the need for comprehensive threat modeling during tool development and regular security assessments of automated processes that interact with external systems. Organizations should consider implementing additional monitoring and logging for instances where such tools process external schema definitions, enabling detection of potential exploitation attempts through unusual network activity patterns or access to unexpected resources.