DEV Community

Cover image for Detection Engine First, AI Second: Building RoleFlux on Google Cloud
Mohamed
Mohamed

Posted on

Detection Engine First, AI Second: Building RoleFlux on Google Cloud

Dumping raw cloud audit logs into an LLM and asking "is this bad?" is not detection engineering. Here's the architecture I open-sourced instead.

If you've run a SOC over multi-project cloud, you know audit-log hell. Every admin action — granting roles/owner to a service account, editing a firewall rule, exporting a KMS key — spits out a deeply nested, 400-line JSON log. Staring at that all day is how alert fatigue kills a team.

The rushed answer was "AI wrappers": dump raw logs into an LLM and ask "is this dangerous?" That's fundamentally broken — it hallucinates, it's non-deterministic, and you can't audit it for compliance.

So I open-sourced RoleFlux, a serverless Cloud Detection and Response platform for Google Cloud built on one principle: detection engine first, AI copilot second.

https://github.com/medjahdi/RoleFlux

The 3-tier architecture

[ GCP Cloud Audit Logs ]
          |
          v  (log router sink)
[ Pub/Sub topic ]
          |
          v
Tier 1 - Deterministic detection engine (Python 3.12)
  hardcoded SOC rules
  (external principal + prod project + owner role = CRITICAL)
  numeric risk score 0-100
  MITRE ATT&CK mapping (T1098, T1078)
          |
          v  (structured telemetry only)
Tier 2 - AI investigation (Vertex AI / Gemini)
  never evaluates the security boundary
  writes a crisp 2-sentence summary
  generates exact copy-paste gcloud rollback commands
          |
          v
[ Slack alert ] + [ BigQuery long-term telemetry ]
Enter fullscreen mode Exit fullscreen mode

The point: the engine decides what's dangerous, deterministically and auditably. The LLM only explains and drafts remediation — it never gets a vote on the verdict.

A purple-team simulator, included

How do you test detection rules without compromising live infra? RoleFlux ships a local attack simulator that crafts and injects realistic synthetic GCP audit logs into the pipeline, so you can measure detection latency and remediation in seconds.

The takeaway after five weeks

Whether you're teaching offensive security, hunting web bugs, or defending cloud: security isn't a spectator sport. Understand how systems are built, how they break, and then engineer repeatable systems that protect them.

RoleFlux is free, serverless, open source and deployed via Terraform. Star it, read the code, tell me what you'd change:

Top comments (0)