Infra security

From superagent-ai/skills · View interactive version

Infra security is an AI agent skill from the GitHub repository superagent-ai/skills. Audit Infrastructure-as-Code for security misconfigurations before it ships — Terraform (.tf/.tfvars/.hcl), CloudFormation/SAM (YAML/JSON), Kubernetes & Helm manifests, and Docker / Docker Compose. Reads the IaC offline and reports each misconfiguration at file:line with a severity (P0–P3) and a cor

How to use this skill

Skill file

Infrastructure-as-Code Security Scanner

This skill turns the model into a cloud security auditor. Read the IaC, find the dangerous misconfigurations, and report each one with a severity and a concrete fix. The analysis runs entirely against files on disk — no live cloud, no credentials, no apply.

The rules encode the consensus from the CIS Benchmarks, AWS Well-Architected, the Kubernetes Pod Security Standards, and the checks that tools like tfsec/trivy, checkov, kube-score, and cfn-nag ship — applied as a source read rather than another scanner to wire up.

How it works: two stages

This skill is deliberately split, the same way skill-security is.

The scanner is high-recall, not high-precision on purpose. Trust its file:line anchors; apply your own judgment to severity and validity.

Mental model

Misconfiguration risk is exposure × blast radius, not a checklist tick.

The same literal pattern can be P0 or P3 depending on these two axes — which is exactly why the scanner proposes and you decide. When you genuinely cannot tell the blast radius from the IaC alone, say so and rate conservatively with the assumption stated.

Workflow

Three phases, in order.

Phase 1 — Discover and ingest

Run the scanner over the target to get the candidate findings and a file inventory:

python3 scripts/scan.py <target-dir> --format markdown

It classifies files by extension and a content peek:

Use --format json when you want to fold the findings into your own reasoning programmatically; --severity P0,P1 to focus; the scanner exits 1 when any P0/P1 is present (so it gates a pipeline) and 0 otherwise.

Phase 2 — Evaluate by category

Take the scanner's candidates and read the surrounding IaC. Walk the categories in references/controls.md, confirming impact and looking for the judgment-only gaps the scanner can't:

For each candidate, the deciding question is the mental model: what is the exposure, and what is the blast radius? That is what turns a raw pattern match into a rated finding.

Phase 3 — Report and remediate

For every confirmed finding, produce:

Assemble these into the report in references/report-template.md. Default save path: ./infra-audit-report-<timestamp>.md.

Finding format

When reporting inline (not the full document), use this structure. Group by severity, P0 first.

[P0] network-ssh-world-open in infra/sg.tf:24
  aws_security_group.web allows 0.0.0.0/0 to port 22. Any host on the
  internet can reach SSH; combined with the public subnet on this SG,
  the blast radius is full shell access to the instance.

  Current:
    ingress {
      from_port   = 22
      to_port     = 22
      cidr_blocks = ["0.0.0.0/0"]
    }

  Fix (scope to the bastion / VPN CIDR, or use SSM Session Manager):
    ingress {
      from_port   = 22
      to_port     = 22
      cidr_blocks = [var.admin_cidr]   # e.g. ["10.0.0.0/16"]
    }

If the user pastes a snippet without a path, refer to "the resource" and use line numbers within the snippet. Always name the exposure and the blast radius — that pair is the justification for the severity.

Severity scale

Summary only — full criteria, the deployment risk rating, and the effort scale are in references/severity-rubric.md.

When it looks clean

After walking all categories, if nothing fires:

  1. Say so explicitly. "No findings against the standard control set."
  2. Note what was not checked: live cloud state and drift (the deployed resource may differ from this IaC), evaluated IAM permissions (the scanner reads policy documents, not the effective access graph), runtime container behavior, secrets injected outside the IaC, and anything in modules/charts not present in the scanned tree.
  3. Recommend the user confirm against the deployed environment — a clean IaC read does not prove the running infrastructure is safe.

Safety and guardrails

  1. Read-only against files. Never run terraform apply/plan -out, kubectl apply, helm install, aws cloudformation deploy, or docker build/run to "validate" a finding. This skill reasons about the IaC text, nothing more.
  2. No credentialed access. Do not read ~/.aws/credentials, ~/.kube/config, environment secrets, or call any cloud API to confirm a finding.
  3. Deterministic rules first. Severity decisions trace back to references/controls.md. Model judgment is for blast radius, false-positive suppression, and rationale — not for inventing rules.
  4. False-positive reduction. Flag a finding only when the bad pattern is present and no compensating control is visible in the same scope (e.g. an explicit aws_s3_bucket_public_access_block, a default that sets encryption, a WAF in front of the open port). When a compensating control might exist outside the scanned tree, note the assumption.
  5. Redact secrets. If the IaC contains live secrets, redact them in the report rather than echoing them.

Trigger phrases

Audit this Terraform for security issues: <dir>
Review these Kubernetes manifests before deploy: <dir>
Check this CloudFormation for public S3 buckets: <file>
Is this security group open to the internet?
Is this container running as root / privileged?
Pre-deployment security review of this IaC: <dir>
What's the blast radius if this Terraform is wrong?

Reference files

What this skill won't do

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.