By Moshe Youdkovich (Data Solutions Architect) and Shimon Ben Ishay (Cloud Solutions Architect), Google Cloud
📖 Read the full article on Medium: Securing Identity Sprawl: Building a Real-Time Access Graph with Google Cloud Spanner
Real-time access graph for GCP using Cloud Spanner's native property graph support.
Ingests Cloud Identity group membership changes and IAM policy bindings via Pub/Sub, writes them to Spanner, and exposes them for graph queries using GQL.
IAM policy bindings don't resolve nested group memberships. A service account can have access to production resources through 4 levels of group nesting and IAM will show zero bindings for it. Policy Analyzer can resolve this per-principal, but you have to know who to ask about. This pipeline finds all risky paths automatically and in real time.
Cloud Identity logs ─┐
├─> Pub/Sub ─> Cloud Run ─> Spanner (Property Graph)
SetIamPolicy logs ───┘
- A logging sink captures
ADD_GROUP_MEMBERandSetIamPolicyevents - Events flow to a Pub/Sub topic
- Cloud Run processes them and writes nodes/edges to Spanner
- GQL queries traverse the graph to find transitive access paths
- Enable Cloud Identity log sharing in the Admin Console (Account > Legal and compliance > Sharing Options)
- Edit
setup.shwith your project ID and region - Run
./setup.sh
See queries.sql for examples. The key one:
GRAPH SecurityGraph
MATCH (identity:Identities)-[:IS_MEMBER]->(g:UserGroups)
-[:NESTED_IN]->{1, 5}(parent:UserGroups)
-[:HAS_PERMISSION]->(res:Resources {sensitivity: 'High'})
RETURN identity.email, g.name, parent.name, res.name;This traverses up to 5 levels of group nesting and finds every identity that reaches a sensitive resource through nested groups.
main.py- Cloud Run service that processes Pub/Sub events and writes to Spannerschema.sql- Spanner DDL for tables and property graph definitionqueries.sql- GQL queries for access path discovery, investigation, and auditsetup.sh- Infrastructure setup scriptDockerfile- Container definition for Cloud Run
- Spanner Enterprise edition (needed for property graph support)
- Cloud Identity log sharing enabled
- Cloud Run SA needs
roles/spanner.databaseUser