How to Configure Neo4j Least Privilege

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up neo4j least privilege by replacing broad built-in roles with custom graph roles. These custom roles restrict which nodes, relationships, and properties each user or app can read or write. Most teams start by giving developers the built-in admin or editor role to move fast. Broad roles let one bad query or stolen key read or wipe the whole graph. How neo4j least privilege works in the graph Neo4j manages permissions through role-based rules that apply to users and service accounts.

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up neo4j least privilege by replacing broad built-in roles with custom graph roles. These custom roles restrict which nodes, relationships, and properties each user or app can read or write. Most teams start by giving developers the built-in admin or editor role to move fast. Broad roles let one bad query or stolen key read or wipe the whole graph.

How neo4j least privilege works in the graph

Neo4j manages permissions through role-based rules that apply to users and service accounts. Out of the box, the database offers built-in roles like reader, editor, publisher, and architect. Those default roles apply across the entire database and every label inside it. To narrow that scope, admins create custom roles and grant specific graph privileges.

Graph privileges break down into traverse, read, and write rules. Traverse rules decide which nodes and relationships a user can find while walking the graph. Read rules control which properties a user can view once they find a node. Write rules limit who can create, update, or delete specific labels and properties.

Admins can also use deny rules to block sensitive labels or properties for specific roles. If a role has both a grant rule and a deny rule, the deny rule wins. Teams often pair these graph rules with database privileges that block schema changes or index drops. For external login, teams map groups from their identity provider directly to these custom roles.

How to scope roles for users and apps

Start by listing every app, service, and human team that logs in to the database. Group these accounts by the exact graph tasks they need to run each day. A billing app might only need to read customer nodes and write invoice nodes. Give that app a dedicated role with grants for those two labels only.

Human users need a different approach than automated backend services. Most engineers only need to traverse the graph and read non-sensitive properties during normal days. You can create a support role that denies read rights on properties holding emails or phone numbers. Save write privileges and schema rules for automated deployment pipelines and rare break-glass tasks.

Least Privilege Principle + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Where native graph roles fall short

Native database roles do a good job of separating broad app duties inside the graph. Still, static roles still struggle with day-to-day human debugging and live production fixes. When an engineer needs to fix a broken node, they must use a role with write rights. Once logged in with that role, the database allows any write query on those allowed labels.

Static roles decide who logs in, not what individual queries do in flight. A single bad query without a limit clause can still update thousands of nodes at once. Also, native property deny rules hide the whole property instead of masking sensitive strings inside results. Masking rewrites matched fields like card numbers or national IDs in results while keeping the query working.

Managing dozens of custom roles across many graph instances also creates heavy upkeep for platform teams. Every new node label or relationship type requires updates to multiple role definitions. Over time, teams often fall back to broad roles just to keep engineers unblocked.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits inline in the protocol beside the service as an open-source proxy, a sidecar for your database or API. On every production query an agent or human runs, hoop.dev decides whether to pass, mask, block, or escalate it for review.

Before a query runs, hoop.dev guardrails check the statement against your rules, an AI Analyzer you configure can score intent or hold risky calls for human approval, and hoop.dev data masking rewrites sensitive fields in responses in memory. Explore the MIT-licensed project on GitHub.

Frequently asked questions

What is the difference between traverse and read in Neo4j?

Traverse lets a query find a node or relationship and use it to walk the graph. Read lets the query return the actual properties stored on that node or relationship.

Do deny rules override grant rules in Neo4j?

Yes, a deny rule always wins over a grant rule when a user holds both. Teams use deny rules to block sensitive labels or properties for broad read roles.

Should apps use the built-in editor role in production?

No, the built-in editor role allows writes to every existing label and property in the graph. Production apps should use custom roles that only grant writes to their specific labels.

The query runs. The emails stay hidden.