<?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>Engramx — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/tags/engramx/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata — refreshed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Wed, 24 Jan 2024 12:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/tags/engramx/feed.xml" rel="self" type="application/rss+xml"/><item><title>engramx vulnerable to CSRF enabling graph exfiltration and prompt injection</title><link>https://feed.craftedsignal.io/briefs/2024-01-engram-csrf-prompt-injection/</link><pubDate>Wed, 24 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-engram-csrf-prompt-injection/</guid><description>The engramx HTTP server, enabled by default and binding to 127.0.0.1:7337, is vulnerable to CSRF and prompt injection attacks, allowing a malicious website to exfiltrate the local knowledge graph and inject persistent prompt-injection payloads.</description><content:encoded><![CDATA[<p>The <code>engramx</code> HTTP server, which is enabled by default and listens on <code>127.0.0.1:7337</code>, is vulnerable to Cross-Site Request Forgery (CSRF) and prompt injection attacks in versions prior to 2.0.2. This vulnerability stems from a combination of a wildcard CORS policy (<code>Access-Control-Allow-Origin: *</code>) and the absence of authentication by default. An attacker could exploit this by enticing a developer to visit a malicious web page, leading to the exfiltration of sensitive data from the local knowledge graph and the injection of malicious payloads. The vulnerability was discovered and responsibly disclosed by @gabiudrescu in engram issue #7. Defenders should prioritize upgrading to version 2.0.2 or implementing the provided workarounds to mitigate the risk of unauthorized access and persistent compromise.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>A developer installs a vulnerable version of <code>engramx</code> (&gt;= 1.0.0, &lt; 2.0.2) and the HTTP server starts by default.</li>
<li>The server binds to <code>127.0.0.1:7337</code> and serves requests without requiring authentication unless <code>ENGRAM_API_TOKEN</code> is explicitly set.</li>
<li>A developer visits a malicious website in their browser.</li>
<li>The malicious website crafts a cross-origin request to <code>127.0.0.1:7337</code> due to the <code>Access-Control-Allow-Origin: *</code> header.</li>
<li>A <code>GET</code> request to <code>/query</code> or <code>/stats</code> is sent, exfiltrating the local knowledge graph, including function names, file layout, and recorded decisions/mistakes.</li>
<li>A <code>POST</code> request to <code>/learn</code> is sent with a crafted prompt-injection payload, exploiting the lack of <code>Content-Type: application/json</code> enforcement.</li>
<li>The injected payload is written as <code>mistake</code>/<code>decision</code> nodes in the knowledge graph.</li>
<li>The user&rsquo;s AI coding agent is persistently reminded of the injected payload on every future session and file edit, leading to compromised code generation and execution.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation of this vulnerability could lead to the compromise of sensitive developer data, including internal function names, file layouts, and coding decisions, allowing attackers to gain insights into the target&rsquo;s projects. Furthermore, the injection of persistent prompt-injection payloads can lead to the ongoing corruption of the user&rsquo;s AI coding agent, potentially causing the generation of flawed or malicious code. While the exact number of affected users is unknown, any developer using a vulnerable version of <code>engramx</code> is susceptible to this attack.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade to <code>engramx@2.0.2</code> or later to apply the remediation measures outlined in the advisory.</li>
<li>If upgrading is not immediately feasible, do <strong>not</strong> run <code>engram server</code> or <code>engram ui</code> as a workaround.</li>
<li>If <code>engram server</code> must be run, set <code>ENGRAM_API_TOKEN</code> to a long random value and terminate the server before browsing the web (as noted in the advisory).</li>
<li>Deploy the Sigma rule &ldquo;Detect engramx API access without authentication&rdquo; to identify potentially unauthorized access attempts to the engramx API.</li>
<li>Monitor network connections to port 7337 on localhost, filtering for unexpected processes initiating connections.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>csrf</category><category>prompt-injection</category><category>engramx</category></item></channel></rss>