<?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.14.1 to 0.60.1) - CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/datamodel-code-generator-0.14.1-to-0.60.1/</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:52:07 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/datamodel-code-generator-0.14.1-to-0.60.1/feed.xml" rel="self" type="application/rss+xml"/><item><title>datamodel-code-generator Vulnerable to Code Injection via Unescaped Carriage Return</title><link>https://feed.craftedsignal.io/briefs/2026-07-datamodel-code-generator-code-injection/</link><pubDate>Tue, 28 Jul 2026 21:52:07 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2026-07-datamodel-code-generator-code-injection/</guid><description>The `datamodel-code-generator` Python package is vulnerable to code injection (CVE-2026-54654) when a developer uses the `--extra-template-data` option with a file whose `comment` value contains an unescaped carriage return, leading to arbitrary Python code execution during the import process of the generated code.</description><content:encoded><![CDATA[<p>The <code>datamodel-code-generator</code> Python package, specifically versions between <code>0.14.1</code> and <code>0.60.1</code> inclusive, contains a critical code injection vulnerability, CVE-2026-54654. This flaw allows arbitrary Python code execution during the import of generated code when a developer utilizes the <code>--extra-template-data</code> command-line option with an input file containing a maliciously crafted <code>comment</code> field. If this <code>comment</code> field includes an unescaped carriage return (<code>\r</code>), Python's tokenizer treats it as a line terminator, allowing subsequent text to be parsed as executable Python code instead of remaining within a comment block. This poses a significant risk to developers and CI/CD pipelines that process untrusted or attacker-controlled input in their <code>--extra-template-data</code> files, potentially leading to supply chain compromises and remote code execution in development environments.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An attacker crafts a malicious <code>--extra-template-data</code> file.</li>
<li>The malicious file's <code>comment</code> field contains a literal carriage return (<code>\r</code>) followed by arbitrary Python code.</li>
<li>A developer or CI/CD pipeline invokes <code>datamodel-code-generator</code> (versions <code>0.14.1</code> to <code>0.60.1</code>) with the <code>--extra-template-data</code> option pointing to the malicious file.</li>
<li>The <code>datamodel-code-generator</code> uses Jinja2 templates, which interpolate the <code>comment</code> value directly without escaping line terminators.</li>
<li>The generated Python code file will contain the unescaped carriage return within what should be a comment line.</li>
<li>When this generated Python file is subsequently imported by a Python interpreter, the bare <code>\r</code> acts as a physical line terminator.</li>
<li>The Python interpreter ceases treating the line as a comment after the <code>\r</code> and parses the attacker-controlled Python code that follows.</li>
<li>This results in arbitrary Python code execution within the context of the importing process, achieving code injection.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>This vulnerability (CVE-2026-54654) affects any developer or CI pipeline that uses <code>datamodel-code-generator</code> versions between <code>0.14.1</code> and <code>0.60.1</code> and processes <code>--extra-template-data</code> files influenced by attacker-controlled input. Successful exploitation grants attackers arbitrary Python code execution within the developer's or build system's environment during the import phase of the generated code. This can lead to severe consequences, including intellectual property theft, unauthorized access to source code repositories, injection of malicious dependencies, and compromise of build artifacts, potentially affecting an organization's entire software supply chain. The vulnerability does not require the schema itself to be malicious, only the <code>comment</code> field in the extra template data.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade <code>datamodel-code-generator</code> to version <code>0.60.2</code> or later immediately to remediate CVE-2026-54654.</li>
<li>Implement strict input validation for all <code>--extra-template-data</code> files, particularly the <code>comment</code> field, to prevent the inclusion of unescaped carriage returns (<code>\r</code>), vertical tabs (<code>\x0b</code>), or form feeds (<code>\x0c</code>) before invoking <code>datamodel-code-generator</code>.</li>
<li>Review CI/CD pipelines and developer workflows that use <code>datamodel-code-generator</code> and process external or untrusted data sources to ensure such inputs are properly sanitized.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>code-injection</category><category>supply-chain</category><category>rce</category><category>python</category><category>vulnerability</category></item></channel></rss>