Join our Newsletter — 33% off our NHI Course
Home› Glossary› Threats, Abuse & Incident Response› Cypher Injection (Neo4j)
Threats, Abuse & Incident Response

Cypher Injection (Neo4j)

← Back to Glossary
By NHI Mgmt Group Updated October 20, 2026 Domain: Threats, Abuse & Incident Response

Cypher injection is an injection flaw where untrusted input changes a Neo4j Cypher query’s structure or logic. Attackers can bypass filters, read data they should not access or modify graph contents. Defenders should use parameterised queries, avoid string concatenation and constrain query-building paths that accept user input.

How Cypher Injection Changes a Neo4j Query

Cypher injection happens when untrusted input is allowed to alter the structure of a Neo4j query instead of remaining data. That means the query can execute different logic than the developer intended, including broader reads, unintended matches, or graph updates.

The core issue is not Neo4j itself, but unsafe query construction. If application code splices user input into the Cypher string, the input can become part of the executable query grammar. Proper parameterisation keeps values separate from query syntax and preserves the intended control flow.

Why It Is Dangerous in Graph Applications

Graph databases often hold highly connected data, so one successful injection can expose more than a single record. Attackers may pivot through relationships, infer hidden links, or manipulate nodes and edges in ways that are harder to notice than a simple table query failure.

Because Cypher is expressive, the impact can range from over-broad retrieval to destructive writes. A weak filter or a poorly bounded dynamic clause can let an attacker change labels, traverse relationships the application did not intend to expose, or tamper with graph integrity.

How to Recognise Exposure

Exposure usually starts with any code path that builds Cypher from concatenated strings, template fragments, or user-controlled field names. Review the application’s query builder paths, input-handling routines, and any feature that accepts search terms, sort keys, labels, or relationship names from a request.

Validation should focus on where the query text is assembled, not just where input first enters the system. Neo4j vendor guidance and the OWASP Top 10 are useful references for recognising injection patterns, while the Web Application Attacks Guide places Cypher injection in the broader family of query-structure abuse.

Prevention and Verification

The safest default is parameterised Cypher, with query text fixed and only data passed as parameters. Where dynamic query elements are unavoidable, constrain them to tightly controlled allowlists and keep business logic from assembling raw query fragments from user input.

Verification should include code review, security testing of query-building paths, and checking that defensive layers do not just block obvious quotes or symbols but actually prevent grammar injection. The OWASP Top 10 and the Web Application Attacks Guide both help frame testing around injection prevention rather than surface-level input cleaning.

Risk and Threat Considerations

Cypher injection is dangerous because graph queries often combine data access and relationship traversal in a single expression, so a small syntax break can become a broad privilege break. The same flaw can expose sensitive connected data, reveal hidden relationships, or enable write actions against graph content.

Failure mechanism: An attacker supplies input that closes or reshapes the intended Cypher expression, then uses the altered query logic to bypass filters, expand reads, or issue unintended graph operations.

Impact: Confidential graph data can be disclosed, integrity can be damaged, and downstream application decisions that depend on graph results can be manipulated.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP ASVS, CIS Controls v8 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP ASVSV4 — API and Web Service SecurityCypher injection is a query-structure injection flaw in application request handling.
V8 — AuthorizationThe flaw can bypass intended read and write boundaries inside graph queries.
Recommendation — Verify that query construction keeps user input out of executable query syntax. Enforce authorization checks separately from query text and result shaping.
CIS Controls v8CIS-16 — Application Software SecurityThe issue is a software flaw that should be prevented and tested in application code.
Recommendation — Build secure query handling into development, review, and testing workflows.
NIST SP 800-53 Rev 5SI-10 — Information Input ValidationUntrusted input can alter query logic when it is not constrained before use in Cypher.
SA-11 — Developer Testing and EvaluationInjection flaws require security testing of the paths that assemble database queries.
Recommendation — Validate and constrain all user-controlled query inputs before they are incorporated. Test query-building code for injection flaws before release.

Practitioner Guidance

What to watch for: Treat every place where an application builds Cypher dynamically as a security boundary, especially when the code accepts search, filter, sort, or relationship-selection input. The safest pattern is to keep query structure static and restrict variation to parameters or tightly governed allowlists.

Practitioner takeaway: If user input can change the query grammar, the application has already lost control of the database request path.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 20, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org