criticalAgent ThreatPrompt Injection

Langroid Neo4jChatAgent Prompt-to-Cypher Injection Leading to RCE

First seen Jul 10, 2026 · Updated Jul 10, 2026

prompt-injectioncypher-injectionneo4jlangroidragrcegraph-databaseunsanitized-tool-callASI05 · Unsafe Code ExecutionAML.T0051AML.T0053Surface: Tool LayerPropagation: Single Hop

Langroid's Neo4jChatAgent forwards LLM-generated Cypher queries directly to the Neo4j driver without validation, statement allowlisting, or an opt-out mechanism. An attacker who can influence the prompt—either directly or via indirect content ingested through RAG—can manipulate the LLM into generating destructive or data-exfiltrating Cypher queries, and potentially achieve OS command execution if APOC or dbms.security procedures are enabled on the server. This mirrors a previously patched SQLChatAgent vulnerability (CVE-2026-25879) whose fix was never extended to the Neo4j module.

Technical Analysis

The entry point is any text that reaches the LLM's context window feeding Neo4jChatAgent, including untrusted RAG-retrieved documents or direct user input. Because the agent treats LLM output as trusted and passes it verbatim to the Neo4j driver's query execution API, there is no boundary between natural-language reasoning and privileged database operations, allowing prompt injection to translate directly into arbitrary Cypher execution. This crosses the trust boundary between the LLM (untrusted reasoning layer) and the database tool (privileged execution layer), a classic tool-layer injection pattern. When APOC procedures or dbms.security extensions are enabled, Cypher's procedure-call capability extends the blast radius from data manipulation to OS command execution and filesystem access, achieving full RCE. The same defect class was already fixed for the SQL-backed agent in v0.63.0, indicating a systemic pattern-matching failure to propagate the sanitization fix across all database-connector modules.

Affected Systems

Langroid

Detection Signatures

  • Log entries showing Cypher queries containing CALL apoc.* or CALL dbms.* procedures originating from LLM-generated tool calls
  • Unexpected DELETE, DETACH DELETE, or DROP statements in Neo4jChatAgent query logs
  • Cypher queries containing shell-like strings, file paths, or encoded payloads embedded in RAG-sourced text
  • Anomalous query patterns immediately following ingestion of external/untrusted documents
  • Tool invocation logs where LLM output is passed directly to driver.execute_query without an intermediate validation step

Remediation Steps

  1. 1

    Upgrade Langroid

    Update to Langroid version 0.65.5 or later, which contains the fix for the neo4j module.

  2. 2

    Implement Cypher statement allowlisting

    Restrict Neo4jChatAgent to a predefined set of read-only or parameterized query templates rather than allowing arbitrary LLM-generated Cypher.

  3. 3

    Disable dangerous procedures

    Disable or restrict APOC and dbms.security procedures on the Neo4j server unless explicitly required, and apply least-privilege database roles to the agent's connection.

  4. 4

    Sanitize and validate LLM output before execution

    Add a validation layer that parses generated Cypher for disallowed statement types (DELETE, CALL, DROP, procedure invocations) before execution.

  5. 5

    Isolate RAG content from executable context

    Treat retrieved/indirect content as untrusted data and avoid allowing it to directly influence query-generation prompts without sanitization or provenance tagging.

CVE / Advisory IDs

CVE-2026-55615CVE-2026-25879

Industries Most Exposed

TechnologySoftware DevelopmentFinancial ServicesHealthcareAny industry using graph-database-backed LLM applications

Sources

Respond to this threat

Pro subscribers get a full AI-generated incident-response playbook for this threat — detection, containment, eradication, and recovery steps — plus an unlimited AI Threat Advisor for questions about your environment.