Insecure Infrastructure-as-Code Configuration
Infrastructure templates such as Terraform, CloudFormation, Bicep or Kubernetes manifests define resources with insecure settings that are deployed wherever they are used.
| Severity | Medium |
| CVSS 3.1 | 5.6 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L Open in the calculator |
| CVSS 4.0 | 6.3 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-732: Incorrect Permission Assignment for Critical Resource |
| OWASP Top 10 | A01:2025 Broken Access Control |
| MITRE ATT&CK | T1530 Data from Cloud Storage, T1190 Exploit Public-Facing Application |
| Category | Security Misconfiguration |
Description
The organisation's infrastructure-as-code templates, such as Terraform, CloudFormation, Azure Bicep or ARM templates, Kubernetes manifests and Helm charts, define resources with insecure settings. Common examples are storage buckets or blob containers allowing public access; security groups or firewall rules open to the internet on administrative ports such as SSH, RDP or database ports; identity policies with wildcard actions or resources; storage, databases and disks without encryption; logging and versioning turned off; containers that run privileged or as root; and secrets written into templates or variable files.
What an attacker can do depends on the misconfiguration and the resource. Public storage can expose data to anyone on the internet; administrative services open to the internet invite password attacks and exploitation of unpatched flaws; and broad identity policies let an attacker who compromises one workload or credential reach far more. Because templates are reused, a single insecure module or default is copied into every environment built from it, which often includes production, and manual fixes made in the console are overwritten at the next deployment. Terraform state files are a related concern: they hold resource attributes, often including secrets, in plain text, so state kept in a repository or an openly readable bucket exposes them.
The weakness is identified by reviewing the templates manually and with static analysis tools such as Checkov, Trivy or KICS, and by comparing what the templates define with the deployed resources. These tools report many low-impact items, so each result is judged on what the resource holds and whether it is reachable; template findings that have not been deployed, or that apply to resources holding no sensitive data, carry less immediate risk.
Remediation
Fix the templates, and make secure settings the default in the deployment process:
- Correct the insecure settings in the templates and shared modules rather than in the deployed resources, then redeploy so that every environment picks up the change: block public access to storage, restrict inbound rules to known address ranges or private access paths, replace wildcard permissions with specific actions and resources, enable encryption and logging, and run containers unprivileged as a non-root user.
- Remove secrets from templates and variable files, reference them from a secrets manager, and rotate any that were committed.
- Store Terraform state in a remote backend with encryption, restricted access and locking, never in the repository.
- Run an infrastructure-as-code scanner in the CI/CD pipeline and fail builds on high-severity findings, recording any accepted exception with a reason and an owner.
- Enforce key rules at deployment time as well, using cloud policy services or Kubernetes admission control, so that insecure resources are blocked even if they bypass the pipeline.
- Detect drift between the templates and the deployed resources, so that manual changes are found and reconciled.
Confirm the fix by rescanning the templates and checking the deployed resources for the corrected settings.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.