Skip to content

AI skill · Cloud

AI skill: infrastructure as code security review

Claude Code skill that reviews Terraform, Kubernetes manifests or CloudFormation and flags deviations: exposure, IAM, encryption, secrets, network rules.

By Steven Carrier Published

Works with: Claude Code, Claude.ai (projects), agents that support the SKILL.md format

Preview the file
---
name: iac-security-review
description: Reviews Terraform, Kubernetes manifests or CloudFormation and flags security deviations with file:line, impact and fix. Use when the user provides infrastructure as code and asks for a security review, a cloud configuration audit or a search for secrets and exposures.
---

# Infrastructure as code security review

You help an auditor review infrastructure as code from a security standpoint. You change nothing and run nothing (no `terraform apply`, no `kubectl`): you read, you flag, you suggest.

## Expected input

The user provides some or all of:
- Terraform files (`.tf`), Kubernetes manifests (YAML, rendered Helm), CloudFormation templates;
- context: cloud provider, environment (production, staging), intended exposure, known organisation policies.

If context needed to judge is missing (should this resource be public? where does this variable come from?), ask, or record it under "Not verified".

## Families to review

1. **Public exposure**: storage open to everyone, database or service reachable from the Internet, `LoadBalancer` `Service` without restriction, API without authentication.
2. **IAM and permissions**: actions or resources set to `*`, administrator policies attached to application roles, overly broad trust relationships, service accounts with more rights than needed.
3. **Encryption**: storage, volumes, databases and queues without encryption at rest, clear-text traffic, obsolete TLS versions, managed keys without rotation.
4. **Logging and audit**: audit logs disabled, no access logs on storage and load balancers, zero or very short retention.
5. **Secrets in code**: passwords, tokens, keys in clear text in files, variables or default values.
6. **Network rules**: security groups or firewall rules opening `0.0.0.0/0` on administration or database ports, no Kubernetes network policies.
7. **Kubernetes containers**: `privileged`, `hostNetwork`, `hostPID`, running as root, no `securityContext`, host volume mounts, no resource limits.

Flag any other obvious weakness you run into while reading, without inventing any.

## Finding format

For each finding, in this order:

1. **Title**: the weakness and the resource, in fewer than 12 words.
2. **Location**: `path/file.ext:line` (or `lines 40-52`) and resource type and name. Only give a line number if it is visible in the content provided.
3. **Impact**: what it allows and to whom, in two sentences.
4. **Severity**: Critical, High, Medium, Low or Informational, with the rationale.
5. **Excerpt**: the relevant lines, copied as they are.
6. **Fix**: the minimal change, then complementary measures. The proposed code is a suggestion to validate.
7. **Confidence**: Confirmed by the code read, Probable, or To verify, with what would need to be checked.

## Rules

- Never invent a resource, line, value or version. If a variable, module or remote state is not provided, say so and do not presume its value.
- Distinguish what the code proves from what you assume; an assumption is marked "To verify".
- An exposure may be intended: if the context justifies it, rate it Informational and explain.
- Mask secrets you come across: keep the first four characters and replace the rest with `…`. Recommend rotating any secret exposed in a repository.
- End with a "Not verified" section: missing modules, real cloud state, policies outside the code, files not examined.
- If a family yields nothing, write "No findings" without padding.
- Write in the user's language, with no pleasantries or generic conclusion. Sort findings from most to least severe.

Infrastructure as code moves configuration mistakes into the repository: a public bucket or an over-broad role shows up at review time, before deployment. This skill has the model read the files you give it, by risk family, with the exact location and a suggested fix.

What the skill produces

  • A list of findings with location (file:line), resource concerned, impact, justified severity and suggested fix.
  • The families covered: public exposure, excessive IAM permissions, encryption at rest and in transit, logging and audit, secrets in clear text in code, overly open network rules, and Kubernetes container security settings.
  • A "Not verified" section: modules or variables not provided, remote state, policies applied outside the code.

To go deeper on the IAM side on AWS, see the AWS IAM audit cheat sheet.

Install the skill

In Claude Code, for all your projects:

mkdir -p ~/.claude/skills/iac-security-review
curl -fsSL -o ~/.claude/skills/iac-security-review/SKILL.md \
  https://arsenal.bearops.fr/telechargements/skills/revue-iac/en/SKILL.md

For a single project, put the file in .claude/skills/iac-security-review/SKILL.md at the root of the repository. With another agent, add the file’s content to its project instructions.

Use it

Give the files and their context:

Do a security review of these Terraform files (AWS, production account,
eu-west-3 region). The bucket must stay private and access goes through CloudFront.

[paste the .tf files, the manifests or the CloudFormation template here]

Give line numbers or let the model read the files directly in the repository: without them, it does not state a line.

Limitations

  • The skill reads declarative code: it sees neither the real state of the cloud nor policies applied elsewhere (SCPs, organisation policies, admission controllers).
  • It replaces neither an IaC static analysis tool nor an audit of the live configuration; it can miss deviations or report false ones.
  • A value coming from a variable or a module that was not provided is marked "To verify".
  • Do not send any client file to an online AI service unless your contract allows it. Remove secrets before sending.

Sources

Related resources

  • AI prompt · Infrastructure and AD pentesting · OSINT · Cloud

    Attack surface prompt

    Prompt that analyses an asset inventory from the authorised scope (domains, IPs, services, cloud) to prioritise testing: exposure, criticality, checks.

    Published

  • Cheatsheet · Cloud

    AWS IAM audit (CLI)

    Read-only AWS IAM review with the AWS CLI: identity, users, roles, policies, access key age, MFA, credential report and Prowler pointers.

    Published

  • Cheatsheet · Cloud

    Azure / Entra ID audit (CLI)

    Read-only Azure and Entra ID review with the Azure CLI: subscriptions, RBAC roles, identities, key vaults, storage and network security groups.

    Published

BEAROPS

Need a penetration test?

BEAROPS experts test your applications, infrastructure and cloud, black box or grey box, following OWASP, NIST and ANSSI guidance.