Join our Newsletter — 33% off our NHI Course
Home› Guides› BloodHound Cypher Queries Cheat Sheet: Finding and Closing…
Template Identity Visibility, Posture & Threat Detection

BloodHound Cypher Queries Cheat Sheet: Finding and Closing AD Attack Paths

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 13 min read
On this page

BloodHound shows defenders the permission chains that lead from ordinary accounts to Tier Zero, but the prebuilt views only go so far: closing paths at scale needs Cypher queries that answer specific defensive questions and can be re-run after every fix. This cheat sheet gives Cypher queries grouped by defensive question (Tier Zero size and exposure, Kerberos weaknesses, delegation, and access control entries that should not exist), each with the remediation that closes it and a way to track progress. Queries follow the syntax and labels in the BloodHound documentation and the SpecterOps BloodHound Query Library as checked on 26 November 2026, for BloodHound v9.10 and later. It is for Active Directory defenders and identity security teams with authorised access to their own BloodHound data. It covers finding and removing paths only, with no abuse steps. For attack path concepts, Tier Zero and choke points, see the BloodHound and Active Directory Attack Path Guide.

This is an independent guide from NHI Mgmt Group, based on SpecterOps' public BloodHound documentation as of November 2026. It is not sponsored or reviewed by SpecterOps. Product features change, so confirm settings against SpecterOps' current documentation.

Key takeaways

  • Query Tier Zero by label. BloodHound marks Tier Zero members with the Tag_Tier_Zero node label; the documentation says not to rely on the older system_tags property.
  • Edges point towards more privilege. Relationships always run in the direction of compromise, so a path from Domain Users to a Tier Zero object is a path that must be cut.
  • Bound your searches. Unbounded patterns can exhaust execution budgets and return an error instead of partial results; add LIMIT and depth bounds such as *1..3.
  • Queries are read-only unless you turn on mutations. CREATE, SET, REMOVE and DELETE need enable_cypher_mutations in the configuration and the GraphDBMutate permission.
  • Treat the collector and its output as Tier Zero. Collection data maps every weakness in the domain; protect the service account, the zip files and the BloodHound server accordingly.

How to use this template

  1. Confirm authorisation: record who approved collection and analysis, and tell the SOC before collection so alerts are expected.
  2. Replace example names: string matching is case-sensitive, and AD names are stored in upper case with a domain suffix, such as the group name DOMAIN ADMINS followed by the upper-case domain name after an at sign.
  3. Save each query in BloodHound under Explore, Cypher, Saved Queries, with a description and owner, and export them to JSON for version control.
  4. Run the queries in order: Tier Zero definition first, then the highest-impact paths, then hygiene.
  5. Re-run after each change and record the counts in the tracking table in "Remediation tracking".
RecordValue
Edition and version[Community Edition / Enterprise, version]
Domains and forests in scope[ ]
Collection date and method[e.g. SharpHound Default / DCOnly]
Approval reference[ ]
Query owner[ ]

Availability: the Cypher search and supported syntax apply to both BloodHound Enterprise and BloodHound Community Edition. Community Edition includes the default Tier Zero zone; custom Privilege Zones, the Attack Paths findings page, posture history and risk acceptance are described as Enterprise features. Apart from the Zone-node query, the queries on this page use the Tag_Tier_Zero label and standard Cypher.

Cypher basics for BloodHound

ElementSyntaxMeaning
Node(n:User)A node with a label: User, Group, Computer, Domain, GPO, OU, Container, CertTemplate, EnterpriseCA, Base (any AD object)
Tier Zero(n:User:Tag_Tier_Zero)Combine labels with a colon; other zones use their own case-sensitive Tag_ label
Relationship-[:MemberOf]->Direction of compromise or further privilege
Alternatives-[:GenericAll|WriteDacl]->Match any of several edge types
Variable length-[:MemberOf*1..3]->One to three hops; *1.. means unbounded
Shortest pathMATCH p=shortestPath((a)-[*1..]->(b))One minimum trail per pair; allShortestPaths returns all tied trails and costs more
FilterWHERE n.enabled = trueProperty filter; =~ "(?i).*svc.*" for case-insensitive regex
Well-known SIDsWHERE g.objectid ENDS WITH '-513'Match groups by RID or SID rather than by name: -512 Domain Admins, -513 Domain Users, -516 Domain Controllers, -519 Enterprise Admins, -525 Protected Users
PipelineWITH DISTINCT mPass results between query parts; supports aggregation
LimitLIMIT 1000Always cap result size

BloodHound accepts a subset of Cypher. Procedure calls and user-supplied query parameters are rejected, and on the PostgreSQL backend regex follows PostgreSQL syntax. Several queries in the documentation and the Query Library use AD_ATTACK_PATHS in place of a relationship type, as shorthand for the Active Directory attack path edges.

Tier zero and high-value targets

Confirm what Tier Zero contains before measuring paths into it. SpecterOps defines Tier Zero as the assets in control of enterprise identities and their security dependencies; see Active Directory Tiering vs Red Forest.

Defensive questionQuery
What is in Tier Zero?MATCH (n:Tag_Tier_Zero) RETURN n
Is Tier Zero too large in any domain?MATCH (d:Domain)-[:Contains*1..]->(n:Base) WHERE (n:Tag_Tier_Zero) WITH d, COUNT(n) AS t0 WHERE t0 > 50 RETURN d
Which groups are nested into Tier Zero groups?MATCH p=(t:Group)<-[:MemberOf*..]-(s:Group) WHERE (t:Tag_Tier_Zero) AND NOT s.objectid ENDS WITH '-512' AND NOT s.objectid ENDS WITH '-519' RETURN p LIMIT 1000
Can Domain Users reach Tier Zero?MATCH p=shortestPath((s:Group)-[:AD_ATTACK_PATHS*1..]->(t:Tag_Tier_Zero)) WHERE s.objectid ENDS WITH '-513' AND s<>t RETURN p LIMIT 1000
Which non-Tier Zero objects sit one step from Tier Zero (choke points)?MATCH p=(neighbor)-[*2]->(:Zone {name: 'Tier Zero'}) WHERE NOT (neighbor:Tag_Tier_Zero) RETURN p LIMIT 500 (needs Zone nodes, which analysis generates after Findings Prioritization is turned on; check availability in your edition)
Where do Domain Admins log on outside domain controllers?MATCH (s)-[:MemberOf*0..]->(g:Group) WHERE g.objectid ENDS WITH '-516' WITH COLLECT(s) AS exclude MATCH p=(c:Computer)-[:HasSession]->(:User)-[:MemberOf*1..]->(g:Group) WHERE g.objectid ENDS WITH '-512' AND NOT c IN exclude RETURN p LIMIT 1000
Which Tier Zero users are not in Protected Users?MATCH (m:User) WHERE (m:Tag_Tier_Zero) OPTIONAL MATCH (g:Group)<-[:MemberOf*1..]-(n:Base) WHERE g.objectid ENDS WITH '-525' WITH m, COLLECT(n) AS members WHERE NONE(n IN members WHERE n.objectid = m.objectid) RETURN m
Which enabled Tier Zero accounts are dormant (60 days, simplified from the Query Library version, which also checks lastlogon and whencreated)?MATCH (n:Base) WHERE (n:Tag_Tier_Zero) AND n.enabled = true AND n.lastlogontimestamp < (datetime().epochseconds - (60 * 86400)) RETURN n

Kerberoastable and delegation findings

Defensive questionQueryATT&CK
Which enabled user accounts have an SPN (Kerberoastable)?MATCH (u:User) WHERE u.hasspn = true AND u.enabled = true AND NOT u.objectid ENDS WITH '-502' AND NOT COALESCE(u.gmsa, false) = true AND NOT COALESCE(u.msa, false) = true RETURN u LIMIT 100T1558.003
Are any Kerberoastable users in Tier Zero?As above, adding AND (u:Tag_Tier_Zero)T1558.003
Which users do not require Kerberos pre-authentication?MATCH (u:User) WHERE u.dontreqpreauth = true AND u.enabled = true RETURN u LIMIT 100T1558.004
Which non-Tier Zero objects have unconstrained delegation?MATCH (n:Base) WHERE n.unconstraineddelegation = true AND NOT (n:Tag_Tier_Zero) RETURN nNone
Which principals have constrained delegation?MATCH p=(n:Base)-[:AllowedToDelegate]->(m:Base) RETURN pNone
Does anything delegate to the krbtgt service?MATCH (n:Base) WHERE (n:User OR n:Computer) AND ANY(t IN n.allowedtodelegate WHERE toUpper(head(split(t, '/'))) = 'KRBTGT') RETURN n (needs ObjectProps collection)None
Which computers accept resource-based constrained delegation from others?MATCH p=(m:Base)-[:AllowedToAct]->(n:Computer) WHERE NOT (n:Tag_Tier_Zero) RETURN pNone

Remediation detail for these findings is in the How to Find Kerberoastable Accounts in Active Directory and Fix Them guide, the Kerberoasting and AS-REP Roasting Defence Guide and How to find unconstrained delegation in Active Directory.

ACL abuse paths to close

Defensive questionQuery
Who has DCSync-equivalent rights on the domain? (T1003.006)MATCH p=(:Base)-[:DCSync|AllExtendedRights|GenericAll]->(:Domain) RETURN p LIMIT 1000
Which non-Tier Zero principals can change a Tier Zero group's permissions?MATCH p=(n:Base)-[:WriteDacl]->(g:Group) WHERE NOT (n:Tag_Tier_Zero) AND (g:Tag_Tier_Zero) RETURN p
Who controls AdminSDHolder without being Tier Zero?MATCH p=(n:Group)-[r:AD_ATTACK_PATHS]->(m:Container) WHERE NOT (n:Tag_Tier_Zero) AND m.name STARTS WITH "ADMINSDHOLDER@" RETURN p
Who can link GPOs to the domain head or Domain Controllers OU?MATCH p=(n:Base)-[:WriteGPLink|GenericAll|GenericWrite|WriteDacl|WriteOwner|Owns]->(t:Base) WHERE (t:Domain OR t:OU) AND (t:Tag_Tier_Zero) AND NOT (n:Tag_Tier_Zero) RETURN p LIMIT 1000
Who can write shadow credentials on Tier Zero accounts?MATCH p=(n:Base)-[:AddKeyCredentialLink]->(m:Base) WHERE (n:User OR n:Computer) AND (m:Tag_Tier_Zero) RETURN p LIMIT 1000
Do large default groups have outbound control?MATCH p=(n:Group)-[:MemberOf*0..]->(:Group)-[r:AD_ATTACK_PATHS]->(:Base) WHERE (n.objectid ENDS WITH '-513' OR n.objectid ENDS WITH '-515' OR n.objectid ENDS WITH '-S-1-5-11' OR n.objectid ENDS WITH '-S-1-1-0') AND NOT type(r) IN ['MemberOf', 'ClaimSpecialIdentity'] RETURN p
Are Domain Users local administrators anywhere?MATCH p=(s:Group)-[:AdminTo]->(:Computer) WHERE s.objectid ENDS WITH '-513' RETURN p LIMIT 1000
Can Domain Users read LAPS passwords?MATCH p=(s:Group)-[:AllExtendedRights|ReadLAPSPassword]->(:Computer) WHERE s.objectid ENDS WITH '-513' RETURN p LIMIT 1000
Which non-Tier Zero principals can read enabled gMSA passwords?MATCH p=(s:Base)-[:ReadGMSAPassword|GenericAll|GenericWrite|WriteOwner|WriteDacl]->(d:Base) WHERE s<>d AND d.gmsa = true AND d.enabled = true AND NOT (s:Tag_Tier_Zero) RETURN p
Who can enrol in ESC1-style certificate templates?MATCH p=(:Base)-[:Enroll|GenericAll|AllExtendedRights]->(ct:CertTemplate)-[:PublishedTo]->(:EnterpriseCA) WHERE ct.enrolleesuppliessubject = True AND ct.authenticationenabled = True AND ct.requiresmanagerapproval = False AND (ct.authorizedsignatures = 0 OR ct.schemaversion = 1) RETURN p LIMIT 1000

Remediation tracking

FindingTypical fixWhere to read more
Kerberoastable user accountsMove services to gMSA; remove unused SPNs; long random passwords and AES-only encryption where gMSA is not possibleGroup Managed Service Accounts (gMSA) Guide
Pre-authentication not requiredClear "Do not require Kerberos preauthentication" unless a documented legacy need existsKerberoasting and AS-REP Roasting Defence Guide
Unconstrained delegation outside DCsChange to constrained or resource-based delegation; mark privileged accounts sensitive or add them to Protected UsersHow to find unconstrained delegation in Active Directory
DCSync rights on non-Tier Zero principalsRemove replication rights except for DCs and approved sync accountsHow to Find Accounts With DCSync Rights in Active Directory and Remove Them
WriteDacl, GenericAll, Owns on Tier Zero objectsRemove the ACE or change the owner; fix delegation at the OU, not per objectActive Directory ACL and Delegation Hygiene Guide
AdminSDHolder controlRestore the default AdminSDHolder ACL; SDProp then reapplies it to protected objectsAdminSDHolder, SDProp and Protected Groups Guide
Shadow credentials write accessRemove write access to msDS-KeyCredentialLink on Tier Zero accountsShadow Credentials Defence Guide
Domain Users as local admin or LAPS readersRemove the group from local Administrators; restrict LAPS read rights to tiered admin groupsLocal Administrator Password Solution (LAPS) Guide
ESC certificate templatesRemove enrolee-supplied subject or require manager approval; narrow enrolment rightsAD CS ESC1 to ESC16 Reference

Tracking metrics

MetricHow to measureTarget direction
Tier Zero object count per domainCount of Tag_Tier_Zero nodesDown, then stable
Paths from Domain Users to Tier ZeroRows from the shortestPath queryZero
Non-Tier Zero principals with control edges into Tier ZeroDistinct sources in the ACL queriesZero, or accepted with an owner
Kerberoastable and AS-REP roastable enabled usersRow countsDown every cycle
Tier Zero users outside Protected UsersRow countZero, with documented exceptions

Record each count with the collection date, the change ticket that should have reduced it, and the result of the re-run. A count that does not fall after a change usually means the fix was applied to the wrong object or a second path exists.

Safe collection practices

  • Collector account: SpecterOps recommends a gMSA for the SharpHound service account, membership of Protected Users (which its testing found works only with a gMSA, and which stops NTLM-based collection for some edges), and a tiered collector strategy. Domain Admin membership is not required.
  • Collection scope: SharpHound Community Edition's Default method includes local groups and sessions from domain-joined computers; DCOnly queries only domain controllers. Choose the method that matches your approval.
  • Output protection: SharpHound writes zipped JSON to its working folder, and the zip is not encrypted unless ZipPassword is set. Set it, move the file to the analysis host over an approved channel, and delete local copies after ingest.
  • Server protection: the BloodHound database is a map of every path to Tier Zero. Restrict accounts, keep mutations off unless needed, and log access.
  • Expect detection: collection uses LDAP and, for session and local group data, remote enumeration of computers (ATT&CK T1087.002, T1069.002, T1482). Tell the SOC in advance, and use the same telemetry to spot unauthorised collection; see the Active Directory Security Monitoring and Event IDs Guide.

Common mistakes

  • Matching groups by display name: names differ by language and can be renamed. Match well-known groups by SID or RID suffix.
  • Running unbounded queries on large graphs: they can fail without partial results. Bound depth and add LIMIT.
  • Fixing low-impact edges first: start with choke points into Tier Zero, where one change removes many paths.
  • Trusting stale session data: sessions change hourly. Re-collect before you report a session-based path closed.
  • Leaving collection zips on file shares: unencrypted output is a ready-made reconnaissance package for an intruder.
  • Not defining Tier Zero completely: backup, hypervisor, identity sync and management systems that control DCs belong in Tier Zero, or paths through them stay invisible.

Implementation guidance

  1. Agree scope and approval with AD owners and the SOC, and fill in the record table.
  2. Harden the collector (gMSA, Protected Users, tiering) before the first run.
  3. Review Tier Zero membership with the Tier Zero queries and add missing control-plane systems.
  4. Baseline the metrics above from the first collection.
  5. Fix choke points first through normal change control, with a rollback note for each ACE or setting removed.
  6. Re-collect and re-run on a fixed cycle, and report the metric trend to identity and security leadership.

Attack path management supports NIST CSF 2.0 ID.RA (risk assessment) and PR.AA (identity management, authentication and access control), and the identity response steps in the Active Directory Domain Compromise Response Playbook.

Practitioner checklist

  • Record approval, scope, edition and collection method before collecting.
  • Run the collector as a hardened gMSA and protect its output with ZipPassword.
  • Query Tier Zero with Tag_Tier_Zero, not system_tags.
  • Match well-known groups by SID suffix.
  • Bound depth and add LIMIT to every saved query.
  • Map each finding to a fix and a change ticket.
  • Re-collect and re-run after every remediation cycle.
  • Keep Cypher mutations disabled unless there is an approved need.

Standards and references

Related NHI Mgmt Group resources: BloodHound and Active Directory Attack Path Guide · Active Directory ACL and Delegation Hygiene Guide · Kerberoasting and AS-REP Roasting Defence Guide · Group Managed Service Accounts (gMSA) Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

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.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.