<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Datamodel-Code-Generator (0.9.1 - 0.60.2) - CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/datamodel-code-generator-0.9.1---0.60.2/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata. Fed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Tue, 28 Jul 2026 21:34:03 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/datamodel-code-generator-0.9.1---0.60.2/feed.xml" rel="self" type="application/rss+xml"/><item><title>Datamodel Code Generator Vulnerable to SSRF via URL Parameter</title><link>https://feed.craftedsignal.io/briefs/2026-07-datamodel-code-generator-ssrf/</link><pubDate>Tue, 28 Jul 2026 21:34:03 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2026-07-datamodel-code-generator-ssrf/</guid><description>The `datamodel-code-generator` tool, specifically versions from `0.9.1` up to `0.60.2`, is vulnerable to Server-Side Request Forgery (SSRF) when using the `--url` argument with the `[http]` extra installed, allowing attackers to access internal network resources and exfiltrate sensitive data into generated Python files.</description><content:encoded><![CDATA[<p>Versions <code>0.9.1</code> through <code>0.60.2</code> of the <code>datamodel-code-generator</code> tool are susceptible to Server-Side Request Forgery (SSRF) when the optional <code>[http]</code> extra is installed. This vulnerability arises because the tool's built-in HTTP fetcher, utilized when the <code>--url</code> command-line argument is supplied, lacks critical validation for host and IP addresses and unconditionally follows HTTP redirects. An attacker can craft a malicious URL that redirects to internal network resources, loopback addresses, private IP ranges, or cloud metadata services like <code>169.254.169.254</code>. If successfully exploited, the tool will fetch content from these internal destinations and embed any sensitive information (e.g., IAM credentials, internal API responses) directly into the generated <code>.py</code> source code. This poses a significant risk of internal network reconnaissance, sensitive data disclosure, and credential exfiltration, particularly if the generated files are committed to a public or attacker-accessible repository. Organizations using <code>datamodel-code-generator</code> should upgrade to version <code>0.61.0</code> or later to mitigate this risk.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An attacker crafts a malicious external URL (e.g., <code>https://attacker.com/schema.json</code>) that issues an HTTP 302 redirect to an internal network resource, a private IP address, or a cloud metadata service (e.g., <code>http://169.254.169.254/latest/meta-data/iam/security-credentials/&lt;role&gt;</code>).</li>
<li>A victim executes the <code>datamodel-code-generator</code> tool, providing the attacker-controlled external URL via the <code>--url</code> command-line argument.</li>
<li>The <code>datamodel-code-generator</code> tool, specifically its <code>http.get_body</code> function, initiates an HTTP GET request to the provided external URL.</li>
<li>The external server responds with an HTTP 302 redirect to the internal target specified by the attacker.</li>
<li>Due to the <code>follow_redirects=True</code> setting and absence of host/IP validation, <code>datamodel-code-generator</code> transparently follows the redirect and fetches content from the sensitive internal resource, effectively bypassing network boundaries.</li>
<li>The response body from the internal resource (e.g., IAM role credentials, confidential internal API responses, or system information) is processed and interpreted as a schema.</li>
<li>Sensitive information extracted from this internal response body is subsequently embedded into the generated Python <code>.py</code> source file, for example, as docstrings, class attributes, or field descriptions.</li>
<li>The generated <code>.py</code> file, now containing the exfiltrated sensitive data, is potentially committed to a version control system, making the internal information accessible to the attacker or a wider audience.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>This SSRF vulnerability can have significant consequences, primarily affecting organizations that use <code>datamodel-code-generator</code> with unverified URLs or within environments where internal services are accessible from development workstations or CI/CD pipelines. The observed damages include internal network reconnaissance through port scanning localhost or private IP ranges, and the disclosure of highly sensitive information. This can involve the exfiltration of cloud IAM credentials from metadata services (e.g., AWS EC2), internal API keys, or proprietary data from intranet applications. If the generated Python files containing this sensitive data are then committed to a repository, it constitutes a direct exfiltration channel, potentially granting attackers access to cloud infrastructure or other critical internal systems.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade <code>datamodel-code-generator</code> to version <code>0.61.0</code> or higher immediately to patch CVE-2026-54691.</li>
<li>Deploy the <code>Detect datamodel-code-generator SSRF attempts to internal IPs</code> Sigma rule to your SIEM to identify suspicious invocations of the tool targeting internal or private IP addresses.</li>
<li>Review existing codebases for <code>datamodel-codegen</code> invocations that use the <code>--url</code> parameter, especially in automated CI/CD pipelines, to ensure URLs are trusted and do not point to attacker-controlled domains or could redirect to internal resources.</li>
<li>Implement source code analysis tools to scan generated <code>.py</code> files for embedded sensitive information (e.g., API keys, credentials, private IPs) that may have resulted from past exploitation of this vulnerability.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>ssrf</category><category>supply-chain</category><category>code-generation</category><category>python</category><category>vulnerability</category></item></channel></rss>