Two wildlife officers in snow follow a hound working a scent trail on a lead, with the article title about BloodHound Cypher queries with an LLM
Cover based on a photo by USFWS Mountain-Prairie, via Wikimedia Commons, Public domain

BloodHound Cypher queries with an LLM are quick to get and easy to get wrong. Ask a model for "attack paths from this user to Domain Admins" and you'll get something that looks like Cypher and runs without complaint. Then BloodHound shows nothing, and it's tempting to read that as "no path". Often the query asked for an edge that doesn't exist. BloodHound doesn't reject unknown relationship types; it just finds no matches. An LLM-written query is a guess until it has returned a path you already know is in the graph.

This guide runs that check on one small lab. Every query result below came from BloodHound Community Edition v9.10.1, the current release on the BloodHound release notes, running against a synthetic Active Directory collection we generated on one box. We ran the binary from the official specterops/bloodhound:9.10.1 image with the PostgreSQL graph driver; the project's example Docker Compose file defaults to Neo4j, which we did not test. We rechecked node labels, edge names and the supported Cypher subset against the BloodHound docs on November 23, 2026. The drafts were written for this guide to reproduce mistakes models commonly make in BloodHound queries. They are not a captured model transcript, and no model was called in the lab. BloodHound's output is the evidence, not the model's.

Authorized work only. Run BloodHound on your own lab or on an assessment with written scope that covers AD collection. Keep collected data, names and SIDs out of prompts unless your engagement terms allow it.

If you hunt in Microsoft Sentinel rather than in a graph, see KQL hunting queries with an LLM; the same draft-then-test loop applies to Zeek scripts. For how a full engagement fits together, see the authorized pentest workflow with red-cyber-1.

Why write BloodHound Cypher queries with an LLM

BloodHound's prebuilt searches cover the common questions. Real assessments raise narrower ones: which helpdesk group can reset a service account, which workstation holds a session for someone in Tier Zero, which Kerberoastable accounts are still enabled. Each is a few lines of Cypher. Models are good at Cypher's shape: MATCH, a path variable, a variable-length relationship, a WHERE.

They are much less reliable on BloodHound's vocabulary. The graph uses fixed label names (User, Group, Computer, Domain) and fixed edge names (MemberOf, AdminTo, HasSession, ForceChangePassword). Edges point in the direction of compromise. BloodHound also runs only a supported subset of Cypher, which rules out procedures, UNION and several other constructs a model will reach for. Those are the places an AI BloodHound custom query breaks.

How to test an AI BloodHound custom query

Ask two questions, in order:

  1. Does BloodHound accept it? Unsupported syntax fails with HTTP 400 and a cypher query could not be parsed message.
  2. Does it return a path you planted? A wrong label or edge name doesn't error. It returns nothing. The only way to catch that is a graph where you already know the answer.

We ran every query through BloodHound's Run a Cypher query API, POST /api/v2/graphs/cypher, with the same text you would paste into Explore > Cypher:

curl -s -X POST http://127.0.0.1:8080/api/v2/graphs/cypher \
  -H "Authorization: Bearer $BH_TOKEN" -H "Content-Type: application/json" \
  -d '{"query": "MATCH (n:User) RETURN n LIMIT 5", "include_properties": true}'

One behavior to know before you script anything: in our runs, a query with no matches came back as HTTP 404 with "message":"resource not found". The API reference doesn't list a 404 for this endpoint. Treat it as "zero rows", not as a wrong URL.

Step 1: Build a lab AD graph you own

Decide what the right answer is before you ask the model for anything. We wrote a short Python script that emits a SharpHound-format collection (users, groups, computers and one domain, LAB.LOCAL, with made-up SIDs) and uploaded it through BloodHound's file upload. BloodHound ingested it and ran its own analysis, so every label and edge below was created by BloodHound, not by us.

We planted one attack path and a few objects that should not be on it:

Fact in the lab collectionEdge BloodHound should create
JDOE is a member of IT SUPPORTMemberOf
IT SUPPORT can reset SVC_SQL's passwordForceChangePassword
SVC_SQL is in the local Administrators group on WS-ADM01AdminTo (from analysis)
DA.ADMIN is logged on to WS-ADM01HasSession (computer to user)
DA.ADMIN is a member of DOMAIN ADMINSMemberOf
BLEE (not privileged) is logged on to WS-DEV02HasSession, off the path

After ingest, this query listed every edge type in the graph:

MATCH ()-[r]->() RETURN type(r) AS edge, count(*) AS n ORDER BY edge
edge=AdminTo  n=4
edge=ClaimSpecialIdentity  n=8
edge=DCFor  n=1
edge=DCSync  n=2
edge=ForceChangePassword  n=1
edge=GenericAll  n=13
edge=GetChanges  n=2
edge=GetChangesAll  n=2
edge=HasSession  n=2
edge=LocalToComputer  n=3
edge=MemberOf  n=16
edge=MemberOfLocalGroup  n=4

AdminTo and DCSync were not in our JSON. BloodHound derived AdminTo from local group membership and DCSync from the GetChanges plus GetChangesAll rights on the domain, as the GetChanges page describes. Run the same inventory on your own instance and paste its output into the prompt. It is the most useful context a model can get.

Step 2: Give the model the schema, not just the question

A prompt that works:

Write one BloodHound CE Cypher query. Find paths from the user JDOE@LAB.LOCAL to the group DOMAIN ADMINS@LAB.LOCAL, up to 6 hops. Use only these relationship types, which exist in my graph: MemberOf, ForceChangePassword, AdminTo, HasSession. HasSession points from Computer to User. Names are uppercase with an @DOMAIN suffix. Do not use CALL, APOC, UNION or list comprehensions. Return the query only.

Without the edge list, a model has to fill the gaps from memory, and it can mix in generic Neo4j examples, Azure edge names or plain English.

Step 3: A wrong edge name returns nothing

A typical first draft, without the schema in the prompt:

MATCH p=(u:User {name: 'JDOE@LAB.LOCAL'})-[:MemberOf|ResetPassword|AdminTo|HasSession*1..6]->(g:Group {name: 'DOMAIN ADMINS@LAB.LOCAL'})
RETURN p

It reads well, and BloodHound accepts it. The result:

HTTP 404
{"http_status":404,...,"errors":[{"context":"","message":"resource not found"}]}

No parse error, no warning, no path. There is no ResetPassword edge in Active Directory data. The AD edge for resetting a password without knowing the current one is ForceChangePassword; the closest name in the docs is AZResetPassword, which is an Azure edge. The supported-syntax reference states the behavior directly: "Unknown labels and relationship types produce no matches. A list of alternative relationship types can still match its known alternatives."

The second sentence explains why this is easy to miss. The known types in the list still work. The same wrong list on a one-hop query returns real rows:

MATCH p=(u:User {name: 'JDOE@LAB.LOCAL'})-[:MemberOf|ResetPassword]->(g:Group)
RETURN p
HTTP 200
nodes: 3  edges: 2
  edge (JDOE@LAB.LOCAL)-[:MemberOf]->(IT SUPPORT@LAB.LOCAL)
  edge (JDOE@LAB.LOCAL)-[:MemberOf]->(DOMAIN USERS@LAB.LOCAL)

So a spot check on a short query looks fine. The broken name only shows up when the path needs that hop.

Diagram of testing BloodHound Cypher queries from an LLM: a draft using the invented ResetPassword edge returns no rows, the fixed query with ForceChangePassword returns the five-hop attack path from JDOE to Domain Admins in a lab AD graph
The draft used an edge BloodHound does not have and returned no rows. With ForceChangePassword, the same query returned the five-hop path to Domain Admins. Image: RedRouter, Original

Step 4: The fixed LLM Active Directory attack path query

Swap in the documented edge name:

MATCH p=(u:User {name: 'JDOE@LAB.LOCAL'})-[:MemberOf|ForceChangePassword|AdminTo|HasSession*1..6]->(g:Group {name: 'DOMAIN ADMINS@LAB.LOCAL'})
RETURN p
HTTP 200
nodes: 6  edges: 5
  edge (JDOE@LAB.LOCAL)-[:MemberOf]->(IT SUPPORT@LAB.LOCAL)
  edge (IT SUPPORT@LAB.LOCAL)-[:ForceChangePassword]->(SVC_SQL@LAB.LOCAL)
  edge (SVC_SQL@LAB.LOCAL)-[:AdminTo]->(WS-ADM01.LAB.LOCAL)
  edge (WS-ADM01.LAB.LOCAL)-[:HasSession]->(DA.ADMIN@LAB.LOCAL)
  edge (DA.ADMIN@LAB.LOCAL)-[:MemberOf]->(DOMAIN ADMINS@LAB.LOCAL)

That is the path from the Step 1 table, hop for hop, and nothing else. WS-DEV02 and BLEE stayed out, as they should. Each edge matches its documented schema: MemberOf goes from a user, group or computer to a group; ForceChangePassword ends at a user; AdminTo ends at a computer; HasSession goes from a computer to a user. All four are marked traversable.

You can also drop the edge list and let BloodHound pick the shortest route. This version matches Domain Admins by its well-known RID instead of its name:

MATCH p=shortestPath((u:User {name: 'JDOE@LAB.LOCAL'})-[*1..]->(g:Group))
WHERE g.objectid ENDS WITH '-512'
RETURN p

It returned the same five edges. On the PostgreSQL backend, the docs say open-ended searches like [*1..] run under execution budgets and return an error rather than partial results if a budget runs out. Add an upper bound on a large graph.

Step 5: Other mistakes we reproduced

Each of these is a pattern models produce. Each result is from the same lab.

Wrong direction. Models often write sessions as "user has a session on a computer":

MATCH p=(u:User)-[:HasSession]->(c:Computer)
RETURN p

HTTP 404, no rows. BloodHound edges point toward compromise, so HasSession runs from the computer to the user. MATCH p=(c:Computer)-[:HasSession]->(u:User) RETURN p returned both sessions: WS-ADM01 to DA.ADMIN and WS-DEV02 to BLEE.

Wrong case in a name. {name: 'Domain Admins'} in place of {name: 'DOMAIN ADMINS@LAB.LOCAL'} returned HTTP 404 with the otherwise-correct path query. The docs note that string matching is case-sensitive and AD names are stored uppercase with a domain suffix. Matching on objectid ENDS WITH '-512' avoids the problem.

Invented labels. MATCH (n:ADUser) RETURN n returned HTTP 404. The AD label is User; Azure users are AZUser.

Procedures and APOC. Models trained on Neo4j examples reach for CALL. BloodHound rejects it before it reaches the database:

CALL db.relationshipTypes()
HTTP 400  cypher query could not be parsed: line 1:0 standalone CALL is not supported
procedure invocation is not supported

... CALL apoc.algo.allSimplePaths(u, g, '', 6) YIELD path ...
HTTP 400  cypher query could not be parsed: line 2:0 in-query CALL is not supported
procedure invocation is not supported

UNION and list comprehensions. Both are on the docs' list of unsupported constructs. A UNION of Kerberoastable users and unconstrained-delegation computers failed with oC_Union rule is not supported. RETURN [n IN nodes(p) | n.name] failed with HTTP 500 and unable to resolve or otherwise lookup identifer n (BloodHound's spelling). That message doesn't mention list comprehensions, so check the unsupported constructs list before you debug the variable.

Queries worth asking a model for

These are good requests once the model has your edge inventory. Each returned the expected rows in the lab.

Non-Tier Zero objects with a direct edge into Tier Zero. BloodHound marks Tier Zero with the Tag_Tier_Zero label:

MATCH p=(n)-[:MemberOf|AdminTo|HasSession|ForceChangePassword|GenericAll|DCSync]->(t:Tag_Tier_Zero)
WHERE NOT n:Tag_Tier_Zero
RETURN p
edge (WS-ADM01.LAB.LOCAL)-[:HasSession]->(DA.ADMIN@LAB.LOCAL)

That one row is the finding a defender would act on: a Domain Admin logged on to a workstation that a service account administers.

Who can DCSync the domain:

MATCH p=(n)-[:DCSync]->(d:Domain)
RETURN p
edge (DOMAIN CONTROLLERS@LAB.LOCAL)-[:DCSync]->(LAB.LOCAL)
edge (DOMAIN ADMINS@LAB.LOCAL)-[:DCSync]->(LAB.LOCAL)

Enabled accounts with SPNs (Kerberoasting candidates):

MATCH (u:User)
WHERE u.hasspn = true AND u.enabled = true
RETURN u.name AS user, u.serviceprincipalnames AS spns
user=SVC_SQL@LAB.LOCAL  spns=['MSSQLSvc/sql01.lab.local:1433']

Common mistakes in LLM BloodHound Cypher queries

  • Edge names from memory. ResetPassword and AdminOf (in place of AdminTo) both returned no rows in our lab. Check every edge against the edges reference, or better, against your own type(r) inventory.
  • Silent partial matches. Known edge types in a | list still match, so a broken list can pass a short test. Test with the full path you expect.
  • Reversed edges. HasSession runs from computer to user. Every edge points in the direction of compromise.
  • Exact-name filters. Names are case-sensitive and carry a domain suffix. Prefer objectid ENDS WITH '-512' for well-known groups.
  • Neo4j-only syntax. CALL, APOC, UNION, CASE, list comprehensions and MERGE are outside BloodHound's supported subset.
  • Legacy Tier Zero checks. Use the Tag_Tier_Zero label. The docs warn that matching on system_tags is temporary and will be deprecated.
  • Reading "no results" as "no path". An empty result from an unvalidated query means nothing until a known-good path comes back.

What to send the model

  • Send: your BloodHound version, the question in plain words, the type(r) edge inventory from your instance, the label of each node type you want, and the exact error message for anything that failed.
  • Scrub: real usernames, hostnames, domain names and SIDs. Rename them to a lab pattern (JDOE@LAB.LOCAL), get the query working, then swap the real names back in locally.
  • Don't send: SharpHound zip files or raw collection JSON. The model needs the schema, not the data.
  • Check retention. On RedRouter, zero data retention is an opt-in setting, off by default. The data handling docs explain what is stored and how to turn it on.

Automating the check

The test half is one HTTP call, so the loop is easy to script. This sketch asks a model for a query, runs it against your lab BloodHound, and sends back either the parse error or a "no rows" note until a path comes back. It uses the OpenAI Python SDK with RedRouter's https://redrouter.org/v1 base URL from the quickstart. We did not run it against the API for this post. The BloodHound half is the same endpoint used for every result above.

import os, requests
from openai import OpenAI

llm = OpenAI(base_url="https://redrouter.org/v1", api_key=os.environ["REDROUTER_API_KEY"])
bh = "http://127.0.0.1:8080/api/v2/graphs/cypher"
auth = {"Authorization": "Bearer " + os.environ["BH_TOKEN"]}
messages = [{"role": "user", "content": open("prompt.txt").read()}]  # include your edge inventory

for attempt in range(4):
    reply = llm.chat.completions.create(model="glm-5.3-flash-red", messages=messages)
    query = reply.choices[0].message.content.strip().removeprefix("```cypher").strip("`").strip()
    r = requests.post(bh, headers=auth, json={"query": query, "include_properties": False})
    if r.status_code == 200 and r.json()["data"].get("edges"):
        print(query)
        break
    if r.status_code == 404:
        note = "BloodHound returned no rows. Check every label and edge name against the inventory."
    else:
        note = "BloodHound rejected the query: " + r.text[:500]
    messages += [{"role": "assistant", "content": query},
                 {"role": "user", "content": note + "\nReturn the fixed query only."}]

Stop the automation at "a path came back". Whether it is the right path is a judgment against what you planted, so keep a person on that step. If an agent will run queries on its own during an engagement, give it a scope file and logs, as in the Claude Code broker pattern.

Choosing a model for BloodHound Cypher queries

Use any model that follows a "query only" instruction and can hold a few rounds of errors. On RedRouter, GLM 5.3 Flash Red (glm-5.3-flash-red) is $0.25 per 1M input tokens, $0.13 per 1M cached input tokens and $1.00 per 1M output tokens. red-cyber-1 (Beta), the featured model for authorized penetration testing and red-team work, is $0.28 / $0.13 / $1.10 per 1M tokens. The models docs list a 1,048,576-token context window for both and current rates for every model; plans are on /pricing.

Attack-path prompts name real techniques: password resets, session theft, DCSync. RedRouter is built for that kind of authorized security work.

FAQ

Can I write BloodHound Cypher queries with an LLM?

Yes, as a first draft. In our lab, a draft using the invented ResetPassword edge returned no rows. The same query with ForceChangePassword returned the planted five-hop path from JDOE to Domain Admins. Give the model your edge inventory and test against a path you know exists.

Why does my AI BloodHound custom query return no results?

Usually an unknown label or edge name, a reversed edge such as HasSession, or a name with the wrong case. BloodHound returns no matches for unknown types instead of an error. Through the API, an empty result came back as HTTP 404 "resource not found" in our runs.

How do I write an LLM Active Directory attack path query that works?

Name the start and end nodes exactly, list only edge types that exist in your graph, put an upper bound on the path length, and check the result hop by hop. shortestPath with [*1..] lets BloodHound choose the edges.

Does BloodHound CE support APOC or CALL?

No. BloodHound rejects standalone and in-query CALL with "procedure invocation is not supported". UNION, CASE, MERGE and list comprehensions are also outside the supported subset.

Which edge names does BloodHound use for AD attack paths?

Examples from the docs and our lab are MemberOf, AdminTo, HasSession, ForceChangePassword, GenericAll, GetChanges, GetChangesAll and DCSync. The edges reference lists them all, with source, destination and whether each is traversable.

Is it safe to paste BloodHound data into an LLM?

Not raw collection data unless your engagement terms allow it. Send the schema and lab-style names instead. On RedRouter, zero data retention is opt-in and off by default; see the data handling docs.

Sources