<?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 &lt;= 0.61.0 - CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/datamodel-code-generator--0.61.0/</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:53:14 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/datamodel-code-generator--0.61.0/feed.xml" rel="self" type="application/rss+xml"/><item><title>datamodel-code-generator Arbitrary Local File Read Vulnerability</title><link>https://feed.craftedsignal.io/briefs/2026-07-datamodel-code-generator-file-read/</link><pubDate>Tue, 28 Jul 2026 21:53:14 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2026-07-datamodel-code-generator-file-read/</guid><description>The `datamodel-code-generator` library (versions &lt;= 0.61.0) is vulnerable to an unauthenticated path traversal and arbitrary local file read (CVE-2026-55389), allowing an attacker to supply a crafted JSON-Schema with `$ref` fields pointing to local files using `file://` URIs or `../` path traversal sequences, bypassing the `--no-allow-remote-refs` security control, which leads to information disclosure of sensitive data and enables filesystem mapping.</description><content:encoded><![CDATA[<p>A high-severity arbitrary local file read vulnerability (CVE-2026-55389) has been discovered in <code>datamodel-code-generator</code> versions 0.61.0 and earlier. This Python library is commonly used in development workflows, CI/CD pipelines, and multi-tenant services to generate data models from OpenAPI or JSON-Schema specifications. The vulnerability allows an attacker to craft a malicious JSON-Schema containing <code>$ref</code> fields that reference arbitrary local files on the system running the generator. This can be achieved using <code>file://</code> URIs for absolute paths or <code>../</code> sequences for relative path traversal, effectively bypassing the <code>--no-allow-remote-refs</code> security control. Successful exploitation leads to unauthorized information disclosure, including sensitive data like <code>/etc/passwd</code>, private keys (e.g., <code>id_rsa</code>), configuration files, and allows mapping of the host's filesystem layout. The fix was released in version 0.62.0, which applies the remote-ref gate to <code>file://</code> references and local JSON Schema refs outside the input base path.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li><strong>Attacker crafts malicious JSON-Schema:</strong> An attacker creates a JSON-Schema file (e.g., <code>probe.json</code>) containing a <code>$ref</code> field with a crafted URI.</li>
<li><strong>References sensitive local files:</strong> The <code>$ref</code> field uses a <code>file://</code> scheme to point to an absolute path (e.g., <code>file:///etc/passwd</code>) or <code>../</code> path traversal sequences (e.g., <code>../.ssh/id_rsa</code>) to reference arbitrary local files.</li>
<li><strong>Victim executes <code>datamodel-code-generator</code>:</strong> A victim's system, such as a CI/CD pipeline, development environment, or multi-tenant service, invokes the <code>datamodel-code-generator</code> utility to process the attacker's untrusted schema (e.g., <code>datamodel-codegen --input probe.json --output o.py</code>).</li>
<li><strong>Vulnerable reference resolution:</strong> <code>datamodel-code-generator</code>'s internal logic, specifically within the <code>_get_ref_body</code> function, attempts to resolve the <code>$ref</code> target.</li>
<li><strong>Bypasses security control:</strong> The vulnerability allows the <code>file://</code> scheme to be explicitly exempted from the <code>allow_remote_refs</code> check, or for relative paths, the <code>is_relative_to(base_path)</code> check is not enforced, allowing traversal outside the base directory.</li>
<li><strong>Arbitrary file read:</strong> The vulnerable code path (<code>_get_ref_body_from_url</code> or <code>_get_ref_body_from_remote</code>) proceeds to load the content of the arbitrary local file referenced in the <code>$ref</code> field.</li>
<li><strong>Filesystem oracle and information disclosure:</strong> Depending on the target file's content and permissions, the tool either generates an error message (e.g., &quot;TypeError: Expected dict, got str&quot;) indicating the file was read and parsed, or directly incorporates schema-shaped secrets (e.g., from <code>const</code>/<code>default</code>/<code>enum</code>/<code>description</code> fields) from the read file into the generated Python code.</li>
<li><strong>Exfiltration via generated code or errors:</strong> The attacker receives the generated Python code (if it contains secrets) or observes the process's error messages (providing an oracle for file existence and permissions), thereby exfiltrating sensitive information or mapping the victim's filesystem layout.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>This vulnerability leads to arbitrary local file read (CWE-22) and subsequent information disclosure (CWE-200), bypassing a documented security control (<code>--no-allow-remote-refs</code>). Any application, CI pipeline, or multi-tenant service running <code>datamodel-code-generator</code> on untrusted schemas is at risk. Attackers can read any file accessible to the process user, including sensitive system files like <code>/etc/passwd</code>, private keys (e.g., PEM <code>id_rsa</code>), and configuration files (e.g., service-account JSON, Kubernetes secret manifests). This allows for host filesystem mapping by probing arbitrary paths and exfiltrating secret values verbatim if they are embedded within schema-shaped nodes. The issue does not require authentication or special privileges, making it a critical threat for environments processing untrusted input.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade <code>pip/datamodel-code-generator</code> to version <code>0.62.0</code> or higher to remediate CVE-2026-55389.</li>
<li>Ensure the <code>--no-allow-remote-refs</code> flag is enabled when invoking <code>datamodel-code-generator</code> with untrusted input, as this flag's bypass for <code>file://</code> references was fixed in version <code>0.62.0</code>.</li>
<li>Restrict execution permissions for <code>datamodel-code-generator</code> processes to the minimum necessary files and directories to limit potential damage from exploitation.</li>
<li>Block the proof-of-concept URL <code>https://gist.github.com/thegr1ffyn/2a87e81f985883acc30d0118c52da4d3</code> at network perimeters to prevent access to known exploit code.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>vulnerability</category><category>path-traversal</category><category>information-disclosure</category><category>python</category></item></channel></rss>