Prerequisites
- Target system, dependencies and environment configured.
Usage
Purpose
Infrastructure is code now — Terraform, CloudFormation, Kubernetes manifests — and an insecure setting there (a public S3 bucket, an open security group, an unencrypted database) becomes a real cloud misconfiguration the moment it deploys. IaC scanning catches those misconfigurations before deployment, at the code stage, where they're a one-line fix instead of a production exposure. This skill covers integrating IaC scanning into the pipeline, shifting cloud security left.
When to use it
Any pipeline that deploys infrastructure via IaC (most modern ones). It's the shift-left counterpart to the cloud-security domain's posture management (CSPM) — IaC scanning prevents misconfigurations at the code stage, CSPM catches them at runtime; together they cover the lifecycle.
Procedure
- Scan IaC in the pipeline before deploy. Wire an IaC scanner (Checkov, tfsec, Trivy, KICS) into CI to check Terraform/CloudFormation/Kubernetes/ARM against misconfiguration rules on every change. Catching the public bucket in the pull request is far cheaper than catching it in production.
- Cover the high-impact misconfiguration classes — the same ones the cloud domain warns about, but caught in code:
- Public storage (S3 buckets, blob containers open to the world).
- Open security groups / firewall rules (
0.0.0.0/0 on sensitive ports).
- Unencrypted data (storage, databases without encryption-at-rest).
- Over-permissive IAM (wildcard policies).
- Missing logging/audit configuration, public databases, weak TLS.
- Map findings to real risk. IaC scanners flag against a broad policy set, some of which won't matter for your context; prioritise the genuinely dangerous misconfigurations (public exposure, over-permission) over stylistic or low-impact rules — the same tuning discipline as SAST.
- Gate on high-severity misconfigurations. Fail the pipeline on the dangerous ones (public exposure, open sensitive ports, wildcard IAM) so they can't deploy; report the rest. This prevents the misconfiguration from ever reaching the cloud.
- Scan modules and dependencies too. IaC pulls in reusable modules (Terraform registry); a misconfigured or malicious module is your exposure. Scan what you pull in, not just what you wrote.
- Handle the existing-infrastructure baseline. As with SAST, turning IaC scanning on surfaces many pre-existing findings; baseline them and gate on new misconfigurations so the pipeline stays usable while debt is worked down.
- Close the loop with CSPM. IaC scanning prevents misconfigurations pre-deploy, but drift happens (manual changes in the console). Pair with runtime CSPM (cloud domain) so a misconfiguration introduced outside IaC is still caught. Fix drift back in the IaC, not the console.
Cheatsheet
infra = code (Terraform/CloudFormation/K8s) ; insecure setting -> real cloud misconfig on deploy
IaC scanning = catch it BEFORE deploy (one-line fix in PR vs production exposure)
shift-left counterpart to CSPM (runtime)
integrate
SCAN in CI before deploy (Checkov / tfsec / Trivy / KICS) on every change
cover high-impact classes (same as cloud domain, caught in code)
public storage | open security groups (0.0.0.0/0 sensitive ports) | unencrypted data
| wildcard IAM | missing logging | public DBs | weak TLS
MAP to real risk (broad rule sets -> prioritise dangerous over stylistic — SAST-style tuning)
GATE on high-severity (public exposure, open ports, wildcard IAM) -> can't deploy ; report rest
scan MODULES/dependencies too (Terraform registry — misconfigured module = your exposure)
EXISTING infra: baseline, gate on NEW (keep pipeline usable)
pair with CSPM (drift happens — console changes) ; fix drift in the IaC not the console
Reading the results
- A public storage bucket or open security group flagged in the IaC = a cloud breach caught at the code stage — a one-line fix now versus a production exposure and possible incident later. The highest-value IaC-scanning catch, and exactly what shift-left is for.
- Wildcard IAM policies in the IaC = over-permission caught before it deploys; the cloud IAM-privesc paths prevented at source.
- Findings against a broad policy set, many low-impact = needs the same tuning as SAST; prioritise the genuinely dangerous misconfigurations over stylistic rules, or fatigue sets in.
- A misconfigured reused module = your exposure even though you didn't write it; scan modules and dependencies, not just your own code.
- Turning IaC scanning on and blocking all deploys on pre-existing findings = an unusable pipeline; baseline existing infra and gate on new misconfigurations.
- A misconfiguration introduced in the console (drift) = IaC scanning won't catch it (it's not in the code); CSPM does. Pair them, and fix drift back in the IaC.
- Pre-deploy IaC scanning gating dangerous misconfigs, paired with runtime CSPM = cloud security covered across the lifecycle.
Pitfalls
- Only catching misconfigurations at runtime (CSPM), not in code. IaC scanning prevents them pre-deploy, far cheaper than remediating a live exposure. Shift the check left.
- Not tuning the broad rule set. IaC scanners flag many low-impact rules; without prioritising the dangerous ones, fatigue sets in. Tune like SAST.
- Ignoring modules/dependencies. A misconfigured reused module is your exposure; scan what you pull in.
- Blocking on existing debt. Turning scanning on and gating all deploys on pre-existing findings makes the pipeline unusable; baseline and gate on new.
- Fixing drift in the console. Manual console fixes get overwritten by the next IaC apply; fix misconfigurations in the IaC so they stick.
- Treating IaC scanning as sufficient alone. Drift and console changes bypass it; pair with runtime CSPM.
References
- Checkov, tfsec, Trivy, KICS documentation
- The cloud-security domain (the misconfigurations, and cspm-baseline for runtime)
- The sast-integration and policy-as-code skills (same integration discipline)
- CIS benchmarks for cloud providers
Inputs
- Relevant source code, logs, network traces, or system specifications.
Outputs
- Analysis findings, security audit report, or generated code artifacts.
1---2name: iac-scanning3description: Use when scanning infrastructure-as-code for misconfigurations before deploy — catching the insecure Terraform/CloudFormation/Kubernetes settings that become cloud breaches.4---5678## Prerequisites9- Target system, dependencies and environment configured.1011## Usage12### Purpose1314Infrastructure is code now — Terraform, CloudFormation, Kubernetes manifests — and an insecure setting there (a public S3 bucket, an open security group, an unencrypted database) becomes a real cloud misconfiguration the moment it deploys. IaC scanning catches those misconfigurations *before* deployment, at the code stage, where they're a one-line fix instead of a production exposure. This skill covers integrating IaC scanning into the pipeline, shifting cloud security left.1516### When to use it1718Any pipeline that deploys infrastructure via IaC (most modern ones). It's the shift-left counterpart to the cloud-security domain's posture management (CSPM) — IaC scanning prevents misconfigurations at the code stage, CSPM catches them at runtime; together they cover the lifecycle.1920### Procedure21221. **Scan IaC in the pipeline before deploy.** Wire an IaC scanner (Checkov, tfsec, Trivy, KICS) into CI to check Terraform/CloudFormation/Kubernetes/ARM against misconfiguration rules on every change. Catching the public bucket in the pull request is far cheaper than catching it in production.232. **Cover the high-impact misconfiguration classes** — the same ones the cloud domain warns about, but caught in code:24 - Public storage (S3 buckets, blob containers open to the world).25 - Open security groups / firewall rules (`0.0.0.0/0` on sensitive ports).26 - Unencrypted data (storage, databases without encryption-at-rest).27 - Over-permissive IAM (wildcard policies).28 - Missing logging/audit configuration, public databases, weak TLS.293. **Map findings to real risk.** IaC scanners flag against a broad policy set, some of which won't matter for your context; prioritise the genuinely dangerous misconfigurations (public exposure, over-permission) over stylistic or low-impact rules — the same tuning discipline as SAST.304. **Gate on high-severity misconfigurations.** Fail the pipeline on the dangerous ones (public exposure, open sensitive ports, wildcard IAM) so they can't deploy; report the rest. This prevents the misconfiguration from ever reaching the cloud.315. **Scan modules and dependencies too.** IaC pulls in reusable modules (Terraform registry); a misconfigured or malicious module is your exposure. Scan what you pull in, not just what you wrote.326. **Handle the existing-infrastructure baseline.** As with SAST, turning IaC scanning on surfaces many pre-existing findings; baseline them and gate on new misconfigurations so the pipeline stays usable while debt is worked down.337. **Close the loop with CSPM.** IaC scanning prevents misconfigurations pre-deploy, but drift happens (manual changes in the console). Pair with runtime CSPM (cloud domain) so a misconfiguration introduced outside IaC is still caught. Fix drift back in the IaC, not the console.3435### Cheatsheet3637```38infra = code (Terraform/CloudFormation/K8s) ; insecure setting -> real cloud misconfig on deploy39 IaC scanning = catch it BEFORE deploy (one-line fix in PR vs production exposure)40 shift-left counterpart to CSPM (runtime)4142integrate43 SCAN in CI before deploy (Checkov / tfsec / Trivy / KICS) on every change44 cover high-impact classes (same as cloud domain, caught in code)45 public storage | open security groups (0.0.0.0/0 sensitive ports) | unencrypted data46 | wildcard IAM | missing logging | public DBs | weak TLS47 MAP to real risk (broad rule sets -> prioritise dangerous over stylistic — SAST-style tuning)48 GATE on high-severity (public exposure, open ports, wildcard IAM) -> can't deploy ; report rest49 scan MODULES/dependencies too (Terraform registry — misconfigured module = your exposure)50 EXISTING infra: baseline, gate on NEW (keep pipeline usable)51 pair with CSPM (drift happens — console changes) ; fix drift in the IaC not the console52```5354### Reading the results5556- **A public storage bucket or open security group flagged in the IaC** = a cloud breach caught at the code stage — a one-line fix now versus a production exposure and possible incident later. The highest-value IaC-scanning catch, and exactly what shift-left is for.57- **Wildcard IAM policies in the IaC** = over-permission caught before it deploys; the cloud IAM-privesc paths prevented at source.58- **Findings against a broad policy set, many low-impact** = needs the same tuning as SAST; prioritise the genuinely dangerous misconfigurations over stylistic rules, or fatigue sets in.59- **A misconfigured reused module** = your exposure even though you didn't write it; scan modules and dependencies, not just your own code.60- **Turning IaC scanning on and blocking all deploys on pre-existing findings** = an unusable pipeline; baseline existing infra and gate on new misconfigurations.61- **A misconfiguration introduced in the console (drift)** = IaC scanning won't catch it (it's not in the code); CSPM does. Pair them, and fix drift back in the IaC.62- **Pre-deploy IaC scanning gating dangerous misconfigs, paired with runtime CSPM** = cloud security covered across the lifecycle.6364### Pitfalls6566- **Only catching misconfigurations at runtime (CSPM), not in code.** IaC scanning prevents them pre-deploy, far cheaper than remediating a live exposure. Shift the check left.67- **Not tuning the broad rule set.** IaC scanners flag many low-impact rules; without prioritising the dangerous ones, fatigue sets in. Tune like SAST.68- **Ignoring modules/dependencies.** A misconfigured reused module is your exposure; scan what you pull in.69- **Blocking on existing debt.** Turning scanning on and gating all deploys on pre-existing findings makes the pipeline unusable; baseline and gate on new.70- **Fixing drift in the console.** Manual console fixes get overwritten by the next IaC apply; fix misconfigurations in the IaC so they stick.71- **Treating IaC scanning as sufficient alone.** Drift and console changes bypass it; pair with runtime CSPM.7273### References7475- Checkov, tfsec, Trivy, KICS documentation76- The cloud-security domain (the misconfigurations, and cspm-baseline for runtime)77- The sast-integration and policy-as-code skills (same integration discipline)78- CIS benchmarks for cloud providers7980## Inputs81- Relevant source code, logs, network traces, or system specifications.8283## Outputs84- Analysis findings, security audit report, or generated code artifacts.