engramx vulnerable to CSRF enabling graph exfiltration and prompt injection
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.
The engramx HTTP server, which is enabled by default and listens on 127.0.0.1:7337, 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 (Access-Control-Allow-Origin: *) 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.
Attack Chain
- A developer installs a vulnerable version of
engramx(>= 1.0.0, < 2.0.2) and the HTTP server starts by default. - The server binds to
127.0.0.1:7337and serves requests without requiring authentication unlessENGRAM_API_TOKENis explicitly set. - A developer visits a malicious website in their browser.
- The malicious website crafts a cross-origin request to
127.0.0.1:7337due to theAccess-Control-Allow-Origin: *header. - A
GETrequest to/queryor/statsis sent, exfiltrating the local knowledge graph, including function names, file layout, and recorded decisions/mistakes. - A
POSTrequest to/learnis sent with a crafted prompt-injection payload, exploiting the lack ofContent-Type: application/jsonenforcement. - The injected payload is written as
mistake/decisionnodes in the knowledge graph. - The user’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.
Impact
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’s projects. Furthermore, the injection of persistent prompt-injection payloads can lead to the ongoing corruption of the user’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 engramx is susceptible to this attack.
Recommendation
- Upgrade to
engramx@2.0.2or later to apply the remediation measures outlined in the advisory. - If upgrading is not immediately feasible, do not run
engram serverorengram uias a workaround. - If
engram servermust be run, setENGRAM_API_TOKENto a long random value and terminate the server before browsing the web (as noted in the advisory). - Deploy the Sigma rule “Detect engramx API access without authentication” to identify potentially unauthorized access attempts to the engramx API.
- Monitor network connections to port 7337 on localhost, filtering for unexpected processes initiating connections.
Detection coverage 2
Detect engramx API access without authentication
highDetects access to the engramx API without proper authentication, indicating a potential CSRF attack.
Detect POST requests to /learn without Content-Type: application/json
mediumDetects POST requests to the /learn endpoint without the expected Content-Type header, indicating a potential CSRF attempt.
Detection queries are kept inside the platform. Get full rules →