Inspiration

Cloud engineering teams routinely deploy over-privileged AWS IAM policies ("Action": "*" or "s3:*") during rapid prototyping and forget to tighten them—leaving dangerous privilege-escalation vectors like iam:PassRole exposed. Existing AI code assistants try to fix Infrastructure-as-Code (IaC) by rewriting raw Terraform text, which frequently introduces syntax hallucinations or breaks production state. Inspired by the Frankenstein category, FrankenGuard stitches together live AWS CloudTrail runtime telemetry, Kiro Steering guardrails, and deterministic Abstract Syntax Tree (AST) surgery into one autonomous security engine.

What it does

FrankenGuard acts as an autonomous least-privilege exorcism engine for AWS IAM and Terraform:

  1. Runtime Telemetry & Blast-Radius Mapping (scan_iam_graph): Correlates declared Terraform IAM policies against actual AWS CloudTrail API call logs across 5 real-world production attack scenarios to isolate unused wildcards and privilege-escalation vectors.
  2. Deterministic HCL2 AST Surgery (apply_ast_patch): Instead of letting an LLM rewrite .tf files as free-form text, FrankenGuard uses C++ Tree-sitter HCL2 parsers to locate the exact policy = jsonencode(...) node and surgically replace it in-place with idiomatic Terraform HCL2—leaving surrounding blocks, comments, and formatting untouched.
  3. Monster Anatomy View (http://localhost:3000): Provides a real-time visual dashboard featuring live 1.2s auto-sync polling, dynamic SVG blast-radius topology graphs (96/100 → 8/100, -92%), side-by-side HCL2 AST diffs, and live MCP server connectivity telemetry.

How we built it

We engineered FrankenGuard around Kiro's spec-driven and multi-agent ecosystem:

  • Kiro Specs & Steering Guardrails (.kiro/specs & .kiro/steering): Enforced strict deterministic policies (Rules 1–5) prohibiting raw LLM string replacement on .tf files, severing escalation vectors (iam:PassRole, iam:*, iam:CreateAccessKey, iam:PutRolePolicy, sts:AssumeRole), and injecting Condition (ArnLike: aws:SourceArn) blocks.
  • Kiro Crew Multi-Agent Orchestration: Coordinated specialized reasoning roles—a Telemetry Auditor, IAM Graph Analyst, and AST Patcher—through a custom local Model Context Protocol (MCP) server (scan_iam_graph and apply_ast_patch over TCP :4444 with Docker fallback).
  • Zero-Host-Dependency Docker Runtime: Built with TypeScript/Node.js, native C++ Tree-sitter HCL2 bindings, and a multi-container Docker Compose setup (frankenguard-engine + frankenguard-ui) so judges can evaluate everything with a single docker compose up command.

Challenges we ran into

Ensuring zero-hallucination modifications on nested HCL jsonencode(...) blocks inside Terraform files required strictly separating AI reasoning from code mutation. Mapping high-level CloudTrail event names (such as GetObject or InvokeModelWithResponseStream) accurately back to granular IAM action strings, exact resource ARNs, and multi-action service patterns also demanded strict schema validation inside our MCP tools.

Accomplishments that we're proud of

  • Achieved 100% syntax-safe Terraform patching and up to 92% blast-radius risk reduction (96/100 → 8/100) across 5 curated AWS production workloads by pairing Kiro Crew reasoning with deterministic Tree-sitter AST mutations[cite: 2, 3].
  • Built a zero-host-dependency containerized experience with real-time visual feedback in the Monster Anatomy View dashboard, requiring zero local Node.js, Bun, or C++ compiler setup for evaluators[cite: 2].

What we learned

Combining multi-agent orchestration (Kiro Crew) with hard deterministic guardrails (Kiro Steering + AST Parsers) unlocks safe autonomous remediation for high-stakes infrastructure code where probabilistic text generation alone is too risky.

What's next for FrankenGuard

  • Automated GitHub Pull Request generation via Kiro Agent Hooks whenever new CloudTrail anomalies are detected.
  • Support for AWS CDK, CloudFormation, and multi-account AWS Organizations Service Control Policies (SCPs).

Built With

Share this project:

Updates

Submission history