Concerned about recent PAN-OS and other firewall/VPN CVEs? Take advantage of Zscaler’s special offer today

/ What Is IaC Security?

What Is IaC Security?

Infrastructure as code (IaC) security is the embedding of consistent, scalable cloud security coverage that helps to detect misconfiguration in code early in the software development life cycle to prevent vulnerabilities at runtime. It enables organizations to enforce security measures in IaC templates throughout their life cycle, be it in code repositories, continuous integration/continuous delivery (CI/CD) tools, or as early as the developer IDE.

Why Is Infrastructure as Code Security Important?

Business requirements and DevOps adoption are seeing applications delivered and deployed faster than ever before. This trend can have a negative effect on both the compliance and security realms, where regulations and cyberthreats are constantly evolving.

When developers are unaware of the compliance requirements—or these requirements are inaccessible—vulnerabilities can be introduced into the production environment. Organizations need to combat this by bridging the gap between security and DevOps teams as the responsibility and accountability for security rapidly shifts towards DevOps engineers.

The problem stems from a reliance on manual processes and siloed tools that can’t keep pace with development velocity and continuous release cycles. You need to give your developers a frictionless, collaborative platform that allows them to quickly identify and fix issues so that they can enforce consistent security policies and compliance—without sacrificing speed.

IaC security should:

  • Scan code for configuration errors, vulnerabilities, and insecure deployments violating security standards
  • Benchmark configuration checks against security best practices and compliance controls
  • Alert and guide developers/engineers on remediation and secure deployments
  • Enforce guardrails by failing pull requests and CI/CD builds with critical vulnerabilities directly within the tools they use and blocking potential violations where relevant

Before we further discuss the importance of IaC security, let’s take a look at exactly what IaC is and why it matters for modern operations.

What Is Infrastructure as Code?

Infrastructure as code (IaC) is descriptive code, commonly written in markup (JSON, YAML, etc.) or proprietary languages (e.g., Terraform HCL), used for provisioning and managing cloud infrastructure resource configurations. Infrastructure as code provides increased productivity and agility, reduces human error, provides standardization for deployment, and maintains version control of the infrastructure configuration.

IaC tools come in many forms—from dedicated infrastructure management platforms to configuration management tools to open source, there is a plethora of options available. Some of the most popular choices include HashiCorp Terraform, AWS CloudFormation, and Azure Resource Manager.

Benefits of IaC

IaC comes with a number of benefits that mainly focus on flexibility and speed. It allows you to:

  • Quickly and easily provision and manage cloud resources
  • Automate deployment processes by codifying cloud infrastructure
  • Scale infrastructure by virtue of cloud

These benefits negate the need for time-consuming manual configuration and reduces the risk of human error. Plus, they enable engineers to institute version control, which allows DevOps teams—let’s cover this in a bit more detail.

Why Does IaC Matter for DevOps?

IaC allows IT teams to manage and provision data centers through written files. Not only does this reduce the cost of building and running applications, it also makes it easier to share data across teams as well as automate script writing—all of which lighten the load on DevOps teams when they're tasked with creating cloud apps.

What’s more, IaC allows DevOps teams to provision and run a multitude of test environments, and they allow developers to be more diverse in their language use if need be. With this added flexibility, these teams can hunker down and focus on building, testing, and running high quality applications in less time and at a lower cost.

However, by these same tokens, IaC can also make infrastructure more vulnerable.

What Security Risks Are Associated with IaC?

IaC offers operational benefits, such as quick provisioning of IT infrastructure in a declarative approach rather than an imperative approach. However, its impact on security presents a major challenge due its potential impact on resources.

If a single resource is manually misconfigured, the scope of the mistake is limited to that resource alone—but making one mistake in code that can be used to automatically provision 100 or more resources presents a far greater security risk.

Achieving comprehensive IaC security is a challenge for organizations. It can bring a great many benefits, but it can also create dangerous vulnerabilities.

5 IaC risks

Infrastructure as code may leave your organization at risk of:

  • A broad attack surface: IaC misconfigurations can expand the attack surface (e.g., security group misconfigurations that leave assets inadvertently exposed to the internet).
  • Data exposure: IaC templates could contain vulnerabilities and insecure default configurations that could lead to data exposure (e.g., secrets embedded in Terraform code that is checked to source control).
  • Excessive privileges: Developers often use privileged accounts to provision cloud apps and the underlying infrastructure resources, which can lead to unauthorized access to sensitive data or a potential breach.
  • Compliance violations: Organizations need to comply with a number of regulatory standards, such as GDPR, HIPAA, PCI DSS, and SOC2. If policy guardrails based on these standards aren’t enforced in the IaC process, it can lead to compliance failures.
  • Cross-functional team friction: Developers are accelerating deployment to deliver quality products with tight deadlines. Their security counterparts, on the other hand, have little visibility into the code and little control over committed changes. As such, applying security guidelines, either based on regulatory compliance, best practices, or company policy, becomes a real challenge without bridging the gap between DevOps and SecOps.

How Does IaC Security Work?

IaC security takes a “shift-left” approach to securing code. Namely, developers and DevOps engineers receive security feedback on their code earlier in the process. IaC security gives devs such visibility by:

  • Scanning IaC templates before they’re committed to source control
  • Benchmarking configurations
  • Identifying misconfigurations, vulnerabilities, and policy violations

With these processes in place, SecOps teams are readily notified of any issues that need fixing before an app is deployed.

Best Practices for IaC Security

Here are some of the security best practices for IaC that can be easily integrated into the development lifecycle:

Gain Visibility into Asset Inventory

During IaC operations, you must identify, tag, monitor, and maintain an inventory of deployed assets. Untagged resources should be carefully monitored as they’re difficult to track and cause drift. Whenever the resources are retired, their associated configuration must be deleted and data should be secured or deleted as well.

Identify and Fix Environmental Drift

Ideally, configurations across developers’ environments are uniform. But application owners sometimes need to make modifications to their applications and the underlying infrastructure. Without proper monitoring or tools, the unchecked accumulation of these leads to configuration drift which can leave the infrastructure exposed and create gaps in security and compliance.

Secure Hard-Coded Assets

Sensitive data such as secret keys, private keys, SSH keys, access/secret keys, and API keys hardcoded in IaC can provide easy access to underlying services or operations and help attackers move laterally. Having exposed credentials spread through IaC code, which is committed to source control (e.g. GitHub), can be of great risk for organizations.

Secure Developer Accounts

Developers' accounts need to be secured from attackers. It is important to harden and monitor developers’ accounts, track changes in IaC configurations, and verify that the changes are sanctioned and intentional. Unauthorized changes can cause IaC template or configuration tampering that may result in a code leak.

Restrict Access to Environments

Security teams need to have a single point of control that enables consistent management of privileged accounts, credentials, and secrets across each of the development and compute environments. It enables them to govern current and future privileged credentials usage, detect access configuration issues with required context, right-sizing of identity access and permissions, and consistent least-privileged policy enforcement.

Enforce Guardrails

Security teams should enforce cloud-native policy guardrails that incorporate checks to secure multi-cloud infrastructures from configuration drifts and alert on violations, enforce consistent security policies during build and runtime, and deliver clear guidance to developers on how to resolve vulnerabilities and risks. For instance, one may want the CI/CD build to fail, in case a certain security threshold was not met.

We’ve made one thing clear: IaC can greatly benefit your organization, but it comes with security risks you can’t ignore. To get the most out of IaC, you need a cybersecurity partner that has built a solution with DevSecOps in mind, mastered cloud data protection, and above all, will help you get the most out of your IaC investment. That partner is Zscaler.

How Can Posture Control Help?

Posture Control is a cloud native application protection platform (CNAPP) designed to help your development and security teams work together to build a comprehensive infrastructure as code (IaC) security program from the ground up.

Key Capabilities

Visibility and Control

  • Identify issues and visualize the security and compliance postures of your code repository
  • Easily investigate and remediate violations by category, policy severity, compliance controls, tags, and status
  • Get detailed visibility about the code violation, code repository, pull request, CI/CD build and other critical information to trace the issue back to the source

Continuous Assessment

  • Continuously scans for IaC templates (e.g., Terraform HCL, AWS CloudFormation templates, Kubernetes app manifest YAML files and Helm charts) as code is updated or pushed in code repositories and builds are triggered in CI/Cd systems
  • Scan code for security policy violations as early as possible (developer IDE) to provide the developer with immediate feedback
  • Assess IaC templates for security issues, noncompliance, and other misconfigurations or insecure default configurations (e.g., missing encryption, identity and credential tracking) for excessive permissions, publicly exposed resources as workloads, storage buckets, weak security group roles, and more
  • Continuously compare observed configuration with the desired state to report, notify, and remediate unexpected configuration drift
  • Scan code committed to code repositories and fail the build in CI/CD systems when critical vulnerabilities are identified

Enhanced Productivity

  • Improve developer experience by identifying issues with the right context, integrated security guidance, and recommendations to resolve problems/issues natively in their DevOps ecosystems tools such as IDEs, code repositories and CI/CD systems
  • Automate IaC security and embed it into existing processes to reduce friction between developers and security, operations, and compliance team members (a DevSecOps best practice)


  • Integrate with ticketing tools to generate near-real-time alerts, allowing you to notify and alert the right owners and teams with the necessary context on issues, impact, and action required to remediate an issue
promotional background

Zscaler Posture Control is a 100% agentless solution built to identify and remediate hidden risk across the cloud life cycle.

Suggested Resources

Shift Left and Shift Down with CWPP
Read the blog
Securing Infrastructure by Embedding IaC Security into Developer Workflows
Read the blog
The Growing Importance of the Cloud Native Application Protection Platform (CNAPP)
Read the blog
Top 5 Benefits of a Cloud Native Application Protection Platform
Read the blog
01 / 02