Nexus Void AI Research
Infrastructure as Code, IaC Security, Terraform, DevSecOps, Cloud Security, Misconfiguration
What Is IaC Security? Terraform, Docker and Kubernetes Checks
What IaC security is, what to check in Terraform, Dockerfiles and Kubernetes, how IaC scanning works, and how it differs from CSPM.
Infrastructure as code (IaC) security is finding and fixing security problems in the code that builds your cloud, such as Terraform, CloudFormation, Kubernetes manifests, Helm charts and Dockerfiles, before that code is applied. IaC scanning checks those files for public storage, open network rules, over-broad permissions, hardcoded secrets and risky base images, ideally on every pull request.
Last updated 31 October 2026.
IaC is now how most cloud infrastructure gets built, so mistakes scale automatically. When you apply a template, every flaw in it (a public storage bucket, an open security group, an over-privileged role) is created exactly as written, in every environment that uses it. The IaC supply chain is a target too: in the Coder registry compromise, attackers rerouted a module registry to deliver malicious Terraform modules that stole cloud and CI/CD secrets. Your cloud provider doesn't catch these for you: under the AWS shared responsibility model, configuring your resources securely is your job, not AWS's.
What does IaC security cover?
Four recurring problem areas. Good IaC security addresses all four, not just the first.
Risk area | Example | Typical control |
|---|---|---|
Misconfiguration | Public S3 bucket or security group open to 0.0.0.0/0 | Policy-as-code scanning in the pull request |
Hardcoded secrets | API key in a | Secret scanning, a secrets manager, protected state |
Supply chain | Malicious or stale module, provider or base image | Pin and verify versions; scan imported modules and images |
Excess permissions | Wildcard IAM policy ( | Least-privilege review |
The OWASP Infrastructure as Code Security Cheat Sheet and the CIS Benchmarks are good references for what "secure by default" looks like.
What should you check in Terraform and CloudFormation?
Terraform and CloudFormation define your cloud account, so the high-impact checks are about exposure and access:
Storage: buckets and blobs not public; encryption at rest on.
Network: no security group or firewall rule open to 0.0.0.0/0 on admin ports such as SSH (22) or RDP (3389).
Identity: no wildcard actions or resources in IAM policies; separate roles per workload.
Logging: CloudTrail or the equivalent audit log enabled and not deletable by the workload role.
State: Terraform state stored remotely, encrypted and access-controlled, because it can contain secrets in plain text. HashiCorp's guide to sensitive data in state explains why.
Modules: third-party modules and providers pinned to exact versions, not floating references.
What should you check in Dockerfiles?
Dockerfile security is mostly about what ends up inside the image and what it's allowed to do:
Base image: a maintained, minimal base image pinned to a specific version or digest, scanned for known CVEs.
User: the container runs as a non-root user (
USERset).Secrets: no keys or tokens in
ENV,ARGor copied files; they persist in image layers.Contents: no build tools, package caches or debug utilities in the final image; use multi-stage builds.
See Docker's build best practices and the OWASP Docker Security Cheat Sheet.
What should you check in Kubernetes manifests and Helm charts?
Privilege: no
privileged: true, no host network or host path mounts unless essential.Users and capabilities:
runAsNonRoot, dropped Linux capabilities, read-only root filesystem where possible.Resources: CPU and memory limits set so one workload can't starve the node.
Secrets: pulled from a secret store, not written into manifests or values files.
The Kubernetes Pod Security Standards define baseline and restricted profiles to check against.
How do you scan infrastructure as code?
Run static analysis against the templates in your pipeline before they're applied. IaC scanners parse Terraform, CloudFormation, Kubernetes, Helm and Dockerfiles and check them against a rule library, for example flagging encryption left off or a security group open to the internet. The most useful checks run in the pull request, so a risky change is caught as a review comment and fixed before it merges, rather than discovered later in a live cloud account. Open-source scanners such as Trivy, Checkov and KICS cover the common rules; the hard part for a small team is triage and fixing.
IaC security vs cloud security posture management (CSPM)
IaC security | CSPM | |
|---|---|---|
When | Before deployment, in code | After deployment, in the live account |
What it sees | Templates, modules, Dockerfiles | Running resources, including manual changes |
Fix cost | A line in a pull request | A change to production, plus finding who made it |
Best for | Preventing misconfigurations | Catching drift and console changes |
Using both catches issues early in code and still detects drift later.
IaC security best practices
Apply least privilege to the resources you define and to the pipeline identity that applies them.
Keep secrets out of code with a secrets manager and short-lived credentials, and scan for secrets on every commit.
Pin third-party modules, providers and base images to exact, verified versions.
Scan every template in the pull request and enforce the important rules as a required check, so insecure code can't merge.
Protect the state file.
Treat the IaC pipeline as production infrastructure: whoever controls it controls everything it builds.
These map to the "protect the software" practices in the NIST Secure Software Development Framework.
How ARGUS scans infrastructure as code
ARGUS runs IaC scanning as a dedicated phase of every scan, using the Trivy config engine. One pass covers Terraform and Terraform plans, CloudFormation, Azure ARM templates and Dockerfiles; a second covers Kubernetes manifests and Helm charts, labelled so you can tell cluster findings from cloud-template ones. Container base-image CVEs are reported as dependency findings located at the Dockerfile that pulls the image, so a vulnerable base image shows up where you'd fix it.
IaC findings sit in the same pull request review and ranked list as your code and dependency issues, so a public bucket or an open security group is flagged before the template merges, and you decide whether that check blocks the merge. ARGUS also builds an infrastructure inventory (HBOM) from your Terraform resources, Compose services, base images and Kubernetes workloads. ARGUS checks configuration in code; it doesn't scan your live cloud account, so pair it with your provider's posture tools. See how ARGUS fits into your workflow.
Frequently asked questions
What is IaC scanning?
IaC scanning is static analysis of infrastructure code (Terraform, CloudFormation, Kubernetes, Helm, Dockerfiles) against security rules, run before the code is applied, ideally in every pull request.
What is Dockerfile security?
Making sure a container image is built safely: a minimal, pinned and scanned base image, a non-root user, no secrets in layers, and no unnecessary tools in the final image.
Is IaC security the same as CSPM?
No. IaC security checks code before deployment; CSPM checks the running cloud environment after deployment. Most teams need both.
Does IaC security replace penetration testing?
No. IaC scanning catches misconfigurations in code, but it doesn't show whether an attacker could chain weaknesses across your live environment. See vulnerability scanning vs penetration testing.
Our read
Infrastructure as code turned cloud setup into software, so cloud security is now largely code security. Treat IaC the way mature teams treat application code: least privilege by default, secrets out of the repository, third-party modules pinned and verified, and every change scanned before it can merge.
Related reading: What is a software supply chain attack? · How to detect malicious npm packages · Reachability analysis · How to secure a CI/CD pipeline on GitHub Actions
DATA SOURCES
OWASP Infrastructure as Code Security: https://owasp.org/www-project-devsecops-guideline/ ; CISA Secure by Design: https://www.cisa.gov/securebydesign ; NIST SP 800-53: https://csrc.nist.gov/