Note: This post is written as part of my submission for the **Kiroween 2026* hackathon.*

Most AWS accounts have a zombie problem.

Not the movie kind. The s3:*, dynamodb:*, and iam:PassRole on Resource = "*" kind.

Policies written in a rush during a Friday deployment. Never touched again. Silently waiting for one leaked key to turn a minor bug into a full-blown breach.

Everyone knows you should enforce least-privilege IAM.

The catch?

Auditing CloudTrail logs by hand is brutal. Mapping 500+ API calls back to Terraform HCL2 blocks takes hours.

So naturally, people throw an LLM at the .tf file and say, "Fix my IAM permissions."

Big mistake.

Raw LLMs love to improvise. They hallucinate JSON keys. They break HCL2 syntax. Worse, they randomly delete permissions your app actually needs in production.

One bad string replacement and your deployment pipeline goes down at 2 AM.

So for Kiroween 2026, I built FrankenGuard using Kiro—an autonomous IAM least-privilege engine that refuses to let an AI blindly edit code.

How I Used Kiro to Keep the AI on a Leash

Before Kiro, building an AI DevSecOps agent meant writing a giant prompt and praying the model obeyed.

With Kiro, I split reasoning from code mutation:

  1. Kiro Specs (FR-01 to FR-05): Before writing application code, I locked down strict functional requirements—zero wildcards allowed, mandatory aws:SourceArn condition blocks, and automated post-patch verification.
  2. Kiro Steering Rules: I added five non-negotiable guardrails into .kiro/steering/. The agent is strictly forbidden from doing raw text or regex replacements on Terraform files.
  3. Kiro Crew + Custom MCP Server: Instead of one overloaded prompt, Kiro Crew orchestrates specialized roles—a Telemetry Auditor, an IAM Graph Analyst, and an AST Patcher—connected over a custom MCP bridge.

The Secret Weapon: C++ Tree-sitter AST Surgery

Here is how a remediation actually runs inside FrankenGuard:

Step 1 — Telemetry Truth: The agent cross-checks your declared Terraform IAM policies against real AWS CloudTrail runtime logs. It separates what your workload actually uses from dead wildcards and lateral-movement traps.

Step 2 — Surgical HCL2 Patching: Kiro never touches the .tf text directly. It passes only the verified actions and target ARNs to a native C++ Tree-sitter HCL2 engine. Tree-sitter locates the exact policy = jsonencode(...) AST node and swaps it in-place with clean, least-privilege HCL2. Comments, formatting, and surrounding resources stay 100% intact.

Step 3 — Monster Anatomy View: A real-time visual dashboard tracks every severed permission edge and drops blast-radius risk scores by over 90% (e.g., from 96/100 Vulnerable down to 8/100 Least-Privilege Enforced).

Building Secure AI Tools Is Fun

The biggest lesson from building FrankenGuard during Kiroween 2026:

Don't ask an LLM to be a compiler.

Let Kiro's specs, steering guardrails, and MCP orchestration handle the security reasoning—and let deterministic AST tools do the surgery.

Watch the full 3-minute live demo here: https://youtu.be/9X5fDJgfpM0

Happy hacking,

Taufiqurrohman

P.S. If you're entering Kiroween 2026 too, seriously—put your agent rules inside .kiro/steering/. It saves hours of debugging hallucinated file edits.