Skip to content
Solar Account.
Education & Software

How to Use BloodHound Queries in Active Directory Analysis

To use BloodHound queries in Active Directory analysis, ingest domain data collected by SharpHound into BloodHound, then run queries through the built-in Analysis tab or the custom Cypher query bar. Analysts use Cypher queries to discover hidden attack paths,...

How to Use BloodHound Queries in Active Directory Analysis

To use BloodHound queries in Active Directory analysis, ingest domain data collected by SharpHound into BloodHound, then run queries through the built-in Analysis tab or the custom Cypher query bar. Analysts use Cypher queries to discover hidden attack paths, identify misconfigured Access Control Lists (ACLs), audit privilege escalation risks, and expose dangerous domain relationships.

Contents

Understanding BloodHound Architecture and Graph Database Fundamentals

Active Directory (AD) security analysis historically relied on static spreadsheet exports and localized LDAP queries. While LDAP searches reveal individual attributes—such as identifying which users belong to a specific group—they fail to expose multi-hop privilege paths. BloodHound fundamentally alters Active Directory analysis by representing directory objects and security descriptors as a graph database.

In graph theory, data consists of nodes (entities) connected by edges (relationships). When analyzing Active Directory, BloodHound translates identity and infrastructure components into distinct node types:

  • Users (:User): Individual user accounts within the directory.
  • Computers (:Computer): Workstations, servers, and Domain Controllers.
  • Groups (:Group): Security and distribution groups used for permission assignment.
  • Organizational Units (:OU): Administrative containers structuring domain objects.
  • Domains (:Domain): Active Directory domain security boundaries.
  • Group Policy Objects (:GPO): Security settings and scripts applied across OUs.

Edges represent explicit permissions, sessions, or structural inheritances between these nodes. Common relationship edges include:

Using the BloodHound Tool for an Active Directory Security Assessment
  • MemberOf: Indicates membership in a group or nested group structure.
  • AdminTo: Represents local administrator privileges on a targeted computer.
  • HasSession: Reflects an active network or interactive logon session on a machine.
  • GenericAll: Grants full control over the targeted object.
  • WriteDacl: Allows an attacker to modify the Access Control List of the target.
  • WriteOwner: Grants the capability to claim ownership of the target object.
  • Owns: Indicates explicit ownership of an object.
  • GetChanges / GetChangesAll: Grants directory replication permissions required for DCSync attacks.
  • AllowedToDelegate: Indicates Kerberos constrained delegation trust.

By linking these nodes and edges into a continuous graph, BloodHound exposes indirect escalation paths. An attacker with low-privilege access to User A might hold GenericAll rights over User B, who is a MemberOf Group C, which has AdminTo rights on Server D, where a Domain Admin HasSession. BloodHound queries automate the discovery of these complex multi-step vectors across enterprise environments.

Prerequisites for Active Directory Graph Analysis

Before executing queries within BloodHound, security personnel and penetration testers must gather, process, and import Active Directory security data correctly. Running queries against incomplete or corrupted graph data produces misleading results and false negatives.

Data Collection with SharpHound or AzureHound

Data ingestors collect security descriptors, group memberships, session data, trust relationships, and domain object properties. The primary collector for on-premises Active Directory environments is SharpHound.

  1. Execution Scope: Run SharpHound from a domain-joined system using a standard domain user account. Administrative privileges are not required for general domain queries, though local admin rights on target endpoints yield higher-fidelity session data.
  2. Collection Loop Strategy: Command-line flags dictate data depth. Running SharpHound.exe --CollectionMethods All gathers all standard details, including session data, group memberships, local admin groups, and object ACLs. For stealth or low-overhead audits, SharpHound.exe --CollectionMethods DCOnly retrieves directory object metadata directly from the Domain Controller without querying endpoints for network sessions.
  3. Data Output: SharpHound outputs compressed JSON files containing raw telemetry for computers, users, groups, domains, containers, and ACLs.

Ingesting Data into BloodHound

Once collection completes, import the output archive into BloodHound:

  1. Launch the BloodHound interface (whether running BloodHound Legacy connected to Neo4j or BloodHound Community Edition).
  2. Use the Upload Data interface drag-and-drop area to upload the generated ZIP file containing the JSON payloads.
  3. Monitor the ingestion bar to confirm that all nodes, relationships, and property maps finish processing without structural parsing errors.

Executing Built-in BloodHound Queries for Rapid Assessment

BloodHound includes pre-built queries designed to highlight common security boundaries, privilege misconfigurations, and direct escalation paths. Access these directly through the Analysis tab in the main user interface.

BLOODHOUND ANALYSIS WORKFLOW

  1. Data Collection (SharpHound JSON)
  2. Graph Ingestion (BloodHound / CE)
  3. Analysis & Remediation (Pre-built & Cypher)

Key Target Categories:

  • High-Value Targets (Domain Admins, Tier-0 OUs, Enterprise Admins)
  • Dangerous Permissions (GenericAll, WriteDacl, WriteOwner, ForceChangePassword)
  • Kerberos Exposure Points (Kerberoastable Admins, Unconstrained Delegation)

Navigating Built-in Query Categories

Built-in queries address foundational threat-hunting and posture-assessment goals. Selecting a pre-built option immediately paints the resulting subgraph on the main canvas. Key built-in categories include:

  • Find All Domain Admins: Instantly lists all accounts holding direct or nested membership within the Domain Admins group.
  • Shortest Paths to Domain Admins: Displays the shortest administrative escalation path from any node in the environment to the Domain Admins group.
  • Shortest Paths to High Value Targets: Evaluates paths reaching entities marked as High Value (such as Domain Controllers, Enterprise Admins, and sensitive service accounts).
  • Shortest Paths from Kerberoastable Users: Maps privilege escalation vectors starting specifically from user accounts configured with Service Principal Names (SPNs).
  • Find Foreign Admins: Identifies user accounts from external or trusted domains that possess administrative rights in the target domain.
  • Find Shortest Paths from Unconstrained Delegation Systems: Highlights compromised infrastructure vectors where Kerberos unconstrained delegation allows ticket harvesting.

Operationalizing Pre-Built Query Results

When evaluating query output in the graph interface:

  1. Set High-Value Targets: Right-click critical domain groups, server pools, or specific administrative identities and toggle Mark as High Value. This enriches built-in queries targeting critical enterprise assets.
  2. Inspect Node Properties: Select any node to review detailed property fields in the left-hand panel, including passwordlastset, enabled, pwdneverexpires, admincount, and sensitive flag statuses.
  3. Analyze Edge Properties: Click on any relationship edge to display the underlying mechanism driving the link (e.g., specific Active Directory permissions or Windows Security Group memberships).

Writing and Executing Custom Cypher Queries

While pre-built queries cover common threat models, custom Cypher queries allow security teams to conduct targeted hunting, perform granular ACL auditing, and generate tailored compliance reports.

Cypher is the declarative graph query language used by graph databases like Neo4j. It relies on visual ASCII-art style patterns to represent nodes and edges:

  • Parentheses () represent Nodes.
  • Brackets [] inside arrows --> represent Edges and relationships.

Basic Cypher Syntax Structure

A standard Cypher query follows a structured layout:

MATCH (sourceNode:Label)-[relationship:REL_TYPE]->(targetNode:Label)WHERE sourceNode.property = 'Value'RETURN sourceNode, relationship, targetNode

  • MATCH: Defines the graph pattern to locate.
  • WHERE: Applies filters to node properties or relationship parameters.
  • RETURN: Specifies the data, paths, or aggregations to display.
  • WITH: Chains query statements together by passing intermediate results to subsequent clauses.

In BloodHound, you execute custom Cypher statements by pasting the query into the Raw Query bar at the bottom of the interface (or using the Cypher query tab in BloodHound CE) and pressing Enter.

High-Impact Custom Queries for Active Directory Auditing

The following custom Cypher queries target specific Active Directory risk factors, privilege vulnerabilities, and security boundary violations.

1. Identifying All Accounts with DCSync Privileges

DCSync attacks allow an unauthorized account to simulate a Domain Controller and request account password hashes via the Directory Replication Service Remote Protocol (MS-DRSR). This requires GetChanges and GetChangesAll rights over the domain object.

To locate non-standard accounts possessing these replication rights, execute:

MATCH (n)-[r:GetChanges|GetChangesAll]->(d:Domain)WHERE NOT n.name STARTS WITH "DOMAIN CONTROLLERS"RETURN n, r, d

This query matches any node n holding GetChanges or GetChangesAll relationships to a domain d, filtering out standard Domain Controller accounts to isolate anomalous permissions.

2. Detecting Kerberoastable Accounts with Administrative Capabilities

Kerberoastable accounts possess Service Principal Names (SPNs) allowing any authenticated user to request an encrypted Kerberos TGS ticket and attempt offline password cracking. If a Kerberoastable account holds administrative privileges, cracking its credential yields direct high-level domain access.

Execute this query to isolate Kerberoastable users with path paths to local administrator access:

MATCH (u:User {hasspn: true})-[r:AdminTo]->(c:Computer)RETURN u, r, c

To expand this search to include nested group paths leading to Domain Admin privileges:

MATCH p=shortestPath((u:User {hasspn: true})-[r:MemberOf|AdminTo|GenericAll*1..]->(g:Group {name: "DOMAIN ADMINS@DOMAIN.LOCAL"}))RETURN p

This expression uses shortestPath() and variable-length relationship hops *1.. to uncover hidden pathways connecting Kerberoastable service accounts to full domain compromise.

3. Mapping Abuse Paths Target Sensitive Groups via Dangerous ACLs

Attacker techniques often leverage Object Control Model misconfigurations. Permission edges such as GenericAll, WriteDacl, WriteOwner, and GenericWrite over sensitive groups allow malicious actors to modify group membership directly.

To discover all non-admin entities holding control-relationship rights over groups with admincount = true:

MATCH (n)-[r:GenericAll|WriteDacl|WriteOwner|GenericWrite]->(g:Group)WHERE g.admincount = true AND NOT n.name STARTS WITH "DOMAIN ADMINS"RETURN n, r, g

This query isolates non-standard identities that can reconfigure protected security groups, enabling security teams to strip unnecessary object ownership and explicit write rights.

4. Locating Systems Configured for Unconstrained Kerberos Delegation

Computers configured for unconstrained Kerberos delegation store the TGTs of any user connecting to their services inside memory. If an attacker compromises an unconstrained delegation host, they can extract cached Domain Admin TGTs.

Execute the following query to list all non-Domain Controller computers configured with unconstrained delegation:

MATCH (c:Computer {unconstraineddelegation: true})WHERE NOT c.name STARTS WITH "DC"RETURN c

To visualize escalation paths where low-privileged accounts possess local admin access on these delegation hosts:

MATCH p=(u:User)-[r:AdminTo]->(c:Computer {unconstraineddelegation: true})RETURN p

5. Auditing Cross-Domain Trust Paths and Enterprise Admin Exposure

In multi-domain forests, external or cross-domain trusts can introduce lateral movement vulnerabilities. To find foreign domain users or groups holding administrative access inside the current domain:

MATCH (n1:User)-[r:AdminTo|MemberOf|GenericAll]->(n2)WHERE n1.domain <> n2.domainRETURN n1, r, n2

This query filters for relationships where the source node's domain string differs from the target node's domain string, pinpointing cross-boundary administrative relationships.

Active Directory Attack Path Remediation Matrix

Analyzing graph data requires translating discovered relationships into practical security fixes. The table below outlines common Active Directory risk patterns mapped by BloodHound queries, their underlying security implications, and standard remediation workflows.

Attack Vector / Edge Type Primary Security Risk BloodHound Query Focus Recommended Remediation Action
DCSync Rights (GetChanges / GetChangesAll) Non-DC objects can replicate domain credentials and password hashes. MATCH (n)-[r:GetChanges]->(d:Domain) Remove explicit extended replication rights from non-Domain Controller accounts; enforce administrative tier boundaries.
Kerberoastable Admins (hasspn: true + AdminTo) Offline password cracking of service accounts grants direct administrative access. MATCH (u:User {hasspn: true})-[r:AdminTo]->(c) Remove SPNs from privileged accounts, transition service identities to Group Managed Service Accounts (gMSAs), and enforce complex 25+ character passwords.
Dangerous ACL Control (GenericAll, WriteDacl, WriteOwner) Low-privilege accounts can modify targeted group memberships or reset account passwords. MATCH (n)-[r:WriteDacl]->(target) Break explicit object ownership chains, restore default Active Directory DACLs, and execute periodic ACL auditing scripts.
Unconstrained Delegation (unconstraineddelegation: true) Host compromise enables Kerberos ticket harvesting for any connecting user identity. MATCH (c:Computer {unconstraineddelegation: true}) Disable unconstrained delegation on standard servers; migrate applications to Constrained Delegation or Resource-Based Constrained Delegation (RBCD).
Nested Privileged Group Membership (MemberOf*1..) Transitive group inheritance grants unintended Tier-0 administrative capabilities. MATCH p=(u:User)-[r:MemberOf*1..]->(g:Group) Flatten group structures, remove nested administrative roles, and implement dynamic enterprise privilege assignments.
Stale Session Exposure (HasSession) Interactive logon sessions leave high-privilege credentials vulnerable to LSASS memory dumps. MATCH (c:Computer)<-[r:HasSession]-(u:User) Restrict Domain Admin logons to designated Privileged Access Workstations (PAWs); enforce local admin credential isolation via LAPS.

Operational Limitations and Common Pitfalls

While BloodHound is an invaluable Active Directory security platform, security analysts must navigate operational limits to ensure accurate data interpretation.

1. Temporal vs. Static Graph Telemetry

Active Directory data imported into BloodHound consists of two distinct dataset types:

  • Static Configuration Data: Object ACLs, group memberships, OU structures, user flags, and computer attributes change relatively infrequently. This data remains accurate until administrative changes occur in the domain.
  • Temporal Session Telemetry: The HasSession relationship is a point-in-time snapshot of logged-on users. Network sessions fluctuate constantly as users log on, disconnect, or lock workstations. Relying on outdated session collection data can generate false positives (attempting to harvest a session that has ended) or false negatives (missing newly established privileged sessions).

2. Network Collection Restrictions and Firewalls

SharpHound relies on RPC over SMB (Port 445) and NetAPI to query remote endpoints for local Administrators group memberships and active user sessions. If internal host firewalls or network segmentation block port 445, SharpHound cannot query host endpoints. In these scenarios, BloodHound will lack complete AdminTo and HasSession data, potentially masking viable attack paths.

3. Graph Query Performance Bottlenecks

Cypher queries incorporating unconstrained variable-length relationships across massive active directory databases (e.g., MATCH p=(n)-[*1..]->(m)) force the graph database engine to evaluate millions of potential pathways. In domains with tens of thousands of nodes, poorly optimized Cypher queries can cause browser lockups or database memory exhaustion. Always constrain query depth (e.g., *1..5), apply specific node labels, and leverage property filters (WHERE) to restrict evaluation boundaries.

4. Over-Reliance on Default Tooling Assumptions

BloodHound maps explicit security descriptors defined within LDAP and host endpoints, but it cannot model out-of-band controls. For example, if a target system is protected by external Multi-Factor Authentication (MFA), network-level microsegmentation, or Endpoint Detection and Response (EDR) prevention rules, a theoretical graph path returned by Cypher may not be exploitable in practice. Graph analysis must be contextualized alongside existing defense-in-depth controls.

Frequently Asked Questions

How do BloodHound queries differ from standard LDAP searches?

Standard LDAP searches query flat attributes across directory objects, returning lists such as all members of a single group. BloodHound Cypher queries analyze relational paths between entities, mapping multi-hop transitive permissions, session vectors, and object control rights across the entire directory graph.

Can BloodHound queries be run without local administrator rights on target endpoints?

Yes. Running SharpHound and querying BloodHound requires only standard, unprivileged domain user credentials. However, without administrative rights on target remote endpoints, network session enumeration (HasSession) and local group collection via RPC may yield less complete data if host firewalls restrict access.

What is the difference between Cypher queries in BloodHound Legacy and BloodHound Community Edition (CE)?

BloodHound Legacy uses Neo4j as its underlying graph database and runs Cypher queries natively through the raw query bar or Neo4j Browser interface. BloodHound Community Edition uses an updated architecture supporting modern API integrations and PostgreSQL/OpenCypher graph engines, using slightly refined schema naming conventions while retaining core visual graph mechanics.

Why does a BloodHound query return no path even when a user is known to be an administrator?

A query may return no path if SharpHound failed to collect host session data due to network firewalls blocking port 445, if local administrator privileges were assigned via non-standard registry settings, or if data collection parameters omitted specific domain controllers or organizational units.

How frequently should BloodHound queries be executed for Active Directory security monitoring?

Organizations should automate SharpHound data collection and graph analysis on a scheduled basis—such as weekly or bi-weekly—and after major enterprise infrastructure updates. Continuous graph collection allows security teams to detect newly introduced attack paths and track remediation progress over time.

Establishing an Ongoing Active Directory Graph Auditing Strategy

Deploying BloodHound queries effectively requires transitioning from one-off audits to a structured, continuous identity governance program.

To build a persistent graph analysis capability, implement the following operational framework:

  1. Automate Ingestion Pipelines: Schedule automated collection scripts using dedicated service accounts configured with appropriate network access. Feed generated JSON archives into BloodHound Community Edition systematically to maintain current directory context.
  2. Establish Tier-0 Security Baselines: Define and tag all core identity infrastructure objects—including Domain Controllers, Enterprise Admins, PKI servers, and identity sync servers—as High Value Targets within the graph.
  3. Prioritize Path Elimination Over Node Patching: Instead of attempting to fix thousands of isolated ACL warnings, focus on high-leveraged "choke point" edges. Eliminating a single dangerous permission link (such as an unneeded GenericAll ACL on a intermediate group) frequently neutralizes hundreds of downstream escalation paths targeting Tier-0 assets.
  4. Integrate Graph Metrics into Vulnerability Management: Incorporate Cypher path metrics into regular security metrics. Tracking the total number of shortest paths leading to Domain Admin identities provides a quantitative metric for measuring Active Directory hardening success over time.

Written by

Elizabeth Ward

Real Estate & Housing Analyst