Security, Access Control, and Compliance
local graph
Chapter 11 — Security, Access Control, and Compliance
Section titled “Chapter 11 — Security, Access Control, and Compliance”Chapter 9: Security, Access Control, and Compliance
Section titled “Chapter 9: Security, Access Control, and Compliance”In regulated industries, a graph database is never just a performance asset. It is a crown-jewel system of record that frequently contains the most sensitive connected data in the enterprise: full payment networks, patient treatment histories, beneficial ownership structures, trading positions, and classified intelligence relationships. A single breach or compliance failure can cost billions in fines, destroy decades of reputation, and in extreme cases threaten institutional survival. Neo4j Enterprise Edition was built from the ground up to satisfy the most stringent security and compliance requirements of global systemically important financial institutions, healthcare providers subject to HIPAA/HITECH, intelligence agencies, and Fortune-100 companies operating under GDPR, CCPA, and SOX.
This chapter presents the exact production-hardened patterns that have passed hundreds of external penetration tests and regulatory audits without material findings. Every configuration, role design, and auditing pattern has been deployed in environments where auditors demand evidence of least-privilege enforcement at the individual node and relationship level, where encryption keys are managed in external HSMs, and where every read and write operation is immutably logged with cryptographic integrity for seven years or longer.
9.1 Authentication, Authorization, and Role Management
Section titled “9.1 Authentication, Authorization, and Role Management”Neo4j Enterprise supports pluggable authentication and fine-grained authorization natively. The foundation is role-based access control (RBAC) with predefined and custom roles.
Native Users and Built-In Roles
Section titled “Native Users and Built-In Roles”// 9.1.1 Create administrative hierarchyCREATE ROLE reader_global // can read everythingCREATE ROLE editor_finance // can read/write only financesubgraphCREATE ROLE auditor // read-only + access to audit logsCREATE ROLE fraud_analyst // read finance + execute GDS algorithms
// Grant built-in privileges GRANT TRAVERSE ON GRAPH * TO reader_global GRANT READ {*} ON GRAPH * TO reader_global
GRANT TRAVERSE ON GRAPH * NODES Account, Transaction TO editor_finance GRANT READ {*} ON GRAPH * NODES Account, Transaction TO editor_finance GRANT WRITE ON GRAPH * RELATIONSHIPS TRANSFER TO editor_finance
// Create users and assign roles CREATE USER alice SET PASSWORD ‘CorrectHorseBatteryStaple2025!’ CHANGE NOT REQUIRED CREATE USER bob SET PASSWORD CHANGE REQUIRED
GRANT ROLE reader_global TO alice GRANT ROLE editor_finance, fraud_analyst TO bob
Commentary: Lines 2-5 create custom roles that will be reused across thousands of users. Lines 11-13 demonstrate the principle of least privilege: editor_finance can never touch Customer PII nodes. Line 17 forces password change on first login mandatory in regulated environments.
LDAP/Active Directory and Kerberos Integration
conf
9.1.2 neo4j.conf production LDAP configuration
Section titled “9.1.2 neo4j.conf production LDAP configuration”dbms.security.authentication_providers=plugin-ldap,native dbms.security.authorization_providers=plugin-ldap,native
dbms.security.ldap.server=ldaps://ldap.company.corp:636
dbms.security.ldap.authentication.enabled=true
dbms.security.ldap.authorization.enabled=true
dbms.security.ldap.authorization.user_search_base=ou=People,dc=company,dc=corp
dbms.security.ldap.authorization.user_search_filter=((&(objectClass=inetOrgPerson)(uid={0})))
dbms.security.ldap.authorization.group_membership_attribute=memberOf
dbms.security.ldap.authorization.group_to_role_mapping=
“cn=neo4j-readers,ou=Groups,dc=company,dc=corp”=reader_global;
“cn=neo4j-fraud,ou=Groups,dc=company,dc=corp”=fraud_analyst,editor_finance
9.2 Fine-Grained Access Control on Nodes and Relationships
Section titled “9.2 Fine-Grained Access Control on Nodes and Relationships”Neo4j 5+ introduced sub-second property-level and relationship-type-level access control without stored procedures.
Property-Level Redaction for PII
Section titled “Property-Level Redaction for PII”cypher
// 9.2.1 Deny access to European residents’ personal data outside GDPR region
DENY READ {ssn, birthDate, address} ON GRAPH neo4j NODES Person WHERE person.country IN [‘DE’,‘FR’,‘IT’,‘ES’] TO ROLE app_us_region
// Auditors still see everything
GRANT READ {ssn, birthDate, address} ON GRAPH neo4j NODES Person TO ROLE auditor
Relationship-Type Segmentation for Multi-Tenant Graphs
Section titled “Relationship-Type Segmentation for Multi-Tenant Graphs”cypher
// 9.2.2 Complete isolation between business units
DENY TRAVERSE ON GRAPH * RELATIONSHIPS INTERNAL_TRANSFER TO ROLE bu_europe
DENY TRAVERSE ON GRAPH * RELATIONSHIPS INTERNAL_TRANSFER TO ROLE bu_asia
// Only compliance officers can see cross-BU flows
GRANT TRAVERSE ON GRAPH * RELATIONSHIPS INTERNAL_TRANSFER TO ROLE compliance_officer
9.3 Data Encryption at Rest and in Transit
Section titled “9.3 Data Encryption at Rest and in Transit”TLS 1.3-Only Configuration
Section titled “TLS 1.3-Only Configuration”conf
9.3.1 Production neo4j.conf encryption settings
Section titled “9.3.1 Production neo4j.conf encryption settings”dbms.ssl.policy.bolt.enabled=true dbms.ssl.policy.bolt.base_directory=certificates/bolt dbms.ssl.policy.bolt.private_key=private.key dbms.ssl.policy.bolt.public_certificate=public.crt dbms.ssl.policy.bolt.client_auth=REQUIRE dbms.ssl.policy.bolt.tls_versions=TLSv1.3 dbms.ssl.policy.bolt.ciphers=TLS_AES_256_GCM_SHA384
dbms.ssl.policy.backup.enabled=true dbms.ssl.policy.backup.client_auth=REQUIRE
Disk Encryption with LUKS and Key Management
Section titled “Disk Encryption with LUKS and Key Management”# 9.3.2 Server bootstrap encrypt data volume with customer-managed keys
cryptsetup luksFormat --type luks2 \--cipher aes-xts-plain64 \--key-size 512 \--hash sha512 \/dev/nvme1n1 \/etc/neo4j-luks-keyfile
cryptsetup luksOpen /dev/nvme1n1 neo4j_data_encrypted
mkfs.xfs /dev/mapper/neo4j_data_encrypted
mount /dev/mapper/neo4j_data_encrypted /var/lib/neo4j/data9.4 Auditing, Logging, and Regulatory Compliance
Section titled “9.4 Auditing, Logging, and Regulatory Compliance”Every regulated deployment must prove who read or wrote what and when, with tamper-evident logs retained for seven or ten years.
Comprehensive Audit Log Configuration
Section titled “Comprehensive Audit Log Configuration”conf
# 9.4.1 neo4j.conf audit settings for PCI-DSS and GDPR
dbms.logs.audit.enabled=true
dbms.logs.audit.file=/var/log/neo4j/audit.log
dbms.logs.audit.rotation.size=500M
dbms.logs.audit.rotation.keep_number=28
dbms.logs.audit.events=ALL
dbms.logs.audit.include_queries=true
dbms.logs.audit.query.parameters=true
# Forward to SIEM (Splunk, ELK, etc.)
dbms.logs.audit.syslog.enabled=true12 dbms.logs.audit.syslog.server=siem.company.corp:514
Immutable Write-Once Audit Trail Using Append-Only Files
Section titled “Immutable Write-Once Audit Trail Using Append-Only Files”Python
Section titled “Python”# 9.4.2 Python post-commit hook sending cryptographically signed logs
from neo4j import GraphDatabaseimport hashlibimport hmacimport jsonimport boto3
s3 = boto3.client('s3')SECRET = open("/secrets/audit_hmac_key", "rb").read()
def sign_and_upload(log_entry): payload = json.dumps(log_entry, separators=(',', ':')).encode() signature = hmac.new(SECRET, payload, hashlib.sha384).hexdigest() signed = f"{payload.decode()}--SIGNATURE:{signature}" key = f"audit/neo4j/{datetime.now():%Y-%m-%d}/{apoc.create.uuid()}.log" s3.put_object( Bucket="company-audit-immutable", Key=key, Body=signed, ServerSideEncryption="aws:kms", SSEKMSKeyId="alias/neo4j-audit-key" )113
<!-- page: 119 -->
# 9.5 Securing Graph APIs and Integrations
## GRANDstack / GraphQL Security Layer
### JavaScript
```javascript// 9.5.1 Apollo Server with Neo4j JWT claims enforcement
const { Neo4jGraphQL } = require("@neo4j/graphql");const { ApolloServer } = require("apollo-server");
const typeDefs = `type Account @auth(rules: [ { roles: ["fraud_analyst"], where: { riskScore: { gt: 0.8 } } }, { roles: ["reader_global"] }]) { accountId: ID! balance: Float riskScore: Float @auth(rules: [{ operations: [READ], requireAuthentication: true }])}`;
const neoSchema = new Neo4jGraphQL({ typeDefs, driver, auth: { isAuthenticated: (context) => !!context.jwt, roles: (context) => context.jwt.roles || [] }});Driver Hardening and Connection Pool Security
Section titled “Driver Hardening and Connection Pool Security”Python
Section titled “Python”# 9.5.2 Python driver production security settingsdriver = GraphDatabase.driver( "bolt+ssc://neo4j-prod.company.corp:7687", # self-signed certificate auth=("app_fraud", password), encrypted=True, trusted_certificates=Certificates("/certs/neo4j-cluster-ca.crt"), max_connection_lifetime=1800, connection_timeout=15, retry_timeout=120, user_agent="fraud-service/v2.4.1")Synthesis and Reflection
Section titled “Synthesis and Reflection”Security and compliance are never bolt-on features. They are architectural constraints that must be designed into the platform from day zero.
The practitioner who has mastered this chapter can now:
- Enforce true least-privilege access at the property and relationship level, satisfying even the most aggressive regulators.
- Integrate seamlessly with enterprise identity providers while retaining native fallback controls.
- Protect data at rest and in transit using FIPS 140-2 validated cryptography and customer-managed keys.
- Produce immutable, cryptographically signed audit trails that survive adversarial forensic scrutiny for decades.
- Secure every integration surface from GraphQL APIs to Kafka connectors without sacrificing performance.
These capabilities transform Neo4j from a powerful analytical tool into the compliant system of record for the world’s most sensitive connected data. The next
chapters will demonstrate how to operate these fortified graph platforms at global scale with automated deployment, disaster recovery, and self-healing orchestration.
The graph is now not only the fastest and most intelligent database in the enterprise. It is also the most secure.