Skip to content

fix(security): allowlist CALL procedures in read-only Cypher guard - #1735

Merged
Shashankss1205 merged 1 commit into
CodeGraphContext:mainfrom
ayushi2577:fix/cypher-readonly-call-allowlist
Sep 27, 2026
Merged

Shashankss1205 merged 1 commit into
CodeGraphContext:mainfrom
ayushi2577:fix/cypher-readonly-call-allowlist

Conversation

@ayushi2577

Copy link
Copy Markdown
Contributor

Fixes #1727

What

is_read_only_cypher() blocked write procedures by matching specific name
prefixes (apoc, dbms, db.*). Anything outside those three namespaces —
e.g. Neo4j GDS write/mutate procedures (gds.pageRank.write,
gds.louvain.mutate) or neosemantics (n10s.rdf.import.fetch, SSRF + write
in one call) — passed the guard untouched.

Fix

Invert the model: CALL is now rejected by default and only allowed for an
explicit, auditable allowlist of read-only introspection procedures
(db.labels, db.relationshipTypes, db.propertyKeys,
db.schema.visualization, db.indexes). Any CALL whose procedure name
isn't recognized — including a CALL { ... } subquery, where no procedure
name can even be parsed — fails closed.

Reuses the existing literal/comment-stripping and clause-position logic from
#1511 so n.call, $call, AS call, and identifiers that merely contain
"call" keep working as before.

Testing

  • Added test_allows_allowlisted_introspection_calls,
    test_blocks_call_to_unlisted_procedures, and
    test_call_subquery_still_rejected to
    tests/unit/utils/test_cypher_readonly.py.
  • Verified all pre-existing tests in test_cypher_readonly.py and
    test_cypher_readonly_enforcement.py still pass unchanged.
  • Ran ./tests/run_tests.sh fast.

Out of scope

Extending _read_session_kwargs() to give Kuzu/embedded-Kuzu/Nornic/Ladybug
a session-level read backstop, as discussed on the issue — tracking
separately since those engines have no equivalent to request.

is_read_only_cypher() blocklisted write procedures by name prefix
(apoc, dbms, db.*), which any procedure outside those namespaces
bypassed entirely — e.g. Neo4j GDS write/mutate procedures or
neosemantics' n10s.rdf.import.fetch (SSRF + write).

CALL is now rejected by default and only permitted for a small,
explicit allowlist of read-only introspection procedures
(db.labels, db.relationshipTypes, db.propertyKeys,
db.schema.visualization, db.indexes). CALL subqueries and any
unrecognised procedure name fail closed.

Fixes CodeGraphContext#1727
@vercel

vercel Bot commented Sep 24, 2026

Copy link
Copy Markdown

@ayushi2577 is attempting to deploy a commit to the shashankss1205's projects Team on Vercel.

A member of the Team first needs to authorize it.

@ayushi2577

Copy link
Copy Markdown
Contributor Author

@Shashankss1205 Please review it !

@Shashankss1205 Shashankss1205 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally: trial-merged onto main, the guard suite plus every test touching the read-only path (120 tests) pass. Inverting to an allowlist is the right model — fail closed. Thanks!

@Shashankss1205
Shashankss1205 merged commit 76cd3f9 into CodeGraphContext:main Sep 27, 2026
1 check failed
@Shashankss1205 Shashankss1205 added gssoc:approved GSSoC validation: counts toward scoring level:advanced GSSoC difficulty: 55 pts contributor / 30 mentor mentor:Shashankss1205 GSSoC mentor attribution: credits reviewing mentor quality:clean GSSoC quality: x1.2 contributor / +5 mentor type:bug GSSoC type bonus: bug labels Sep 27, 2026
bismay70 pushed a commit to bismay70/CodeGraphContext that referenced this pull request Oct 15, 2026
…lowlist

CodeGraphContext#1735 inverted the read-only guard to a CALL allowlist, but listed only Neo4j
db.* procedures, so `cgc query "CALL show_tables() RETURN *"` stopped working
on Kùzu, the default backend. Adds Kùzu/LadybugDB's read-only table functions;
config-setting CALLs and FTS index create/drop stay rejected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC validation: counts toward scoring level:advanced GSSoC difficulty: 55 pts contributor / 30 mentor mentor:Shashankss1205 GSSoC mentor attribution: credits reviewing mentor quality:clean GSSoC quality: x1.2 contributor / +5 mentor type:bug GSSoC type bonus: bug

Projects

Status: Done

2 participants