Supply Chain / Research

Terraform Backdoors in Legitimate Projects

An investigation into how apparently legitimate infrastructure-as-code can become an unexpected persistence and supply-chain risk.

Published 2026-09-10·12 min·Intermediate

Executive Summary

Infrastructure code is often trusted because it is reviewed as configuration rather than treated as executable logic. This investigation examines where that assumption can fail, how a malicious change can blend into normal Terraform workflows, and what evidence defenders can use to detect it.

Developer → Repository → CI/CD → Identity → Infrastructure ↓ Evidence & Logs ↓ Detection / Defense

Executive Summary

Terraform sits at a powerful trust boundary: it can create identities, networking, storage, compute and other infrastructure. That makes changes to infrastructure code security-relevant even when the diff looks like routine configuration.

Why This Matters

A compromised repository, dependency, module, workflow or maintainer can turn an ordinary infrastructure change into an attack path. The important question is not only whether Terraform can make a change, but which identities and automated systems are authorized to make it.

Threat Model

The working model is a repository used by an automated deployment pipeline. The attacker can influence a code path that reaches the Terraform plan or apply stage but does not initially control the target cloud account.

Technical Analysis

Investigate module sources, provider configuration, state access, CI variables, role assumptions and approval gates. Pay particular attention to trust relationships that are invisible when reading a single Terraform file in isolation.

Detection

Useful evidence includes unexpected module changes, provider behavior, unusual role assumptions, new resources outside normal change windows, state-file access patterns and CI executions from unexpected branches or actors.

Mitigation

Require review for privileged infrastructure changes, constrain CI identities, pin dependencies where appropriate, separate plan and apply privileges, protect state, and continuously evaluate the permissions available to automation.

Lessons Learned

Infrastructure-as-code should be treated as part of the software supply chain. The security boundary includes the repository, dependency graph, workflow, identity and target environment—not just the Terraform configuration.

Reproduction Lab

This investigation can be explored through the corresponding controlled laboratory where applicable. Keep all experimentation within systems you own or are explicitly authorized to test.

Explore the laboratories →

Further Research

What changes when the attacker has less privilege? Which assumptions can be tested independently? What evidence survives when the environment is rebuilt? These are the questions that turn a demonstration into research.