Skip to content

Bug: SQL Error when using mutliple MATCHes with pg graph_driver #1900

@rtpt-romankarwacik

Description

@rtpt-romankarwacik

Description:

When using queries like to the following:

MATCH p=(c:Computer)-->(u:User)
MATCH p2=shortestPath((u)-[*1..]->(d:Domain))
RETURN p,p2
LIMIT 500

The following SQL error is thrown:

2025-09-17 11:35:33.286 CEST [368368] bloodhound@bloodhound ERROR:  missing FROM-clause entry for table "s0" at character 566
2025-09-17 11:35:33.286 CEST [368368] bloodhound@bloodhound STATEMENT:  with s0 as (select (e0.id, e0.start_id, e0.end_id, e0.kind_id, e0.properties)::edgecomposite as e0, (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0, (n1.id, n1.kind_ids, n1.properties)::nodecomposite as n1 from edge e0 join node n0 on n0.id = e0.start_id join node n1 on n1.id = e0.end_id where n1.kind_ids operator (pg_catalog.&&) array [25]::int2[] and n0.kind_ids operator (pg_catalog.&&) array [26]::int2[]), s1 as (with s2(root_id, next_id, depth, satisfied, is_cycle, path) as (select * from unidirectional_sp_harness($1::text, $2::text, 15)) select s0.e0 as e0, (select array_agg((e1.id, e1.start_id, e1.end_id, e1.kind_id, e1.properties)::edgecomposite) from edge e1 where e1.id = any (s2.path)) as e1, s2.path as ep0, s0.n0 as n0, (n1.id, n1.kind_ids, n1.properties)::nodecomposite as n1, (n2.id, n2.kind_ids, n2.properties)::nodecomposite as n2 from s2 join node n1 on n1.id = s2.root_id join node n2 on n2.id = s2.next_id) select edges_to_path(variadic array [(s1.e0).id]::int8[])::pathcomposite as p, edges_to_path(variadic ep0)::pathcomposite as p2 from s1 limit 500;

The same does not happen with the neo4j graph_driver.

Maybe related to https://github.com/SpecterOps/DAWGS/blob/main/cypher/Cypher%20Syntax%20Support.md#right-hand-bound-node-lookups ?

Are you intending to fix this bug?

No

Component(s) Affected:

  • API
  • PostgreSQL

Environment Information:

BloodHound: edc549f (8.2.0-rc2), initially confirmed with v8.0.1

Collector: Used sample data from https://bloodhound.specterops.io/get-started/quickstart/ce-ingest-sample-data

OS: Debian 12

Go (if API related): 1.25.0

Database (if persistence related): postgresql-15 (15.14-0+deb12u1)

Contributor Checklist:

  • I have searched the issue tracker to ensure this bug hasn't been reported before or is not already being addressed.
  • I have provided clear steps to reproduce the issue.
  • I have included relevant environment information details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageThis issue requires triaging

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions