Security teams should treat the Git repository as a control point for change approval, code review, and pipeline integrity. The key is to separate source control from deployment privilege, enforce least privilege on service accounts, and require auditable promotion steps. That reduces the chance that a compromised repo, token, or pipeline can directly modify cloud infrastructure.
Why This Matters for Security Teams
Terraform pipelines turn Git into a privileged control plane, so the real question is not just who can edit code, but who can cause infrastructure to change. When repositories sit in Azure DevOps or another Git platform, the danger is that source control, pipeline execution, and cloud access become too tightly coupled. The result is a compromised token, pull request, or build agent can reach far beyond code review.
This is why NHI governance applies directly to infrastructure as code. A pipeline service principal, deployment token, or short-lived runner credential is still a non-human identity, and it needs lifecycle controls just like any other. NHIMG has repeatedly shown how pipeline and secrets failures spread across environments in CI/CD pipeline exploitation case study and the Guide to the Secret Sprawl Challenge.
The security objective is to make every Terraform change prove who approved it, what context it ran under, and why it was allowed to reach production. In practice, many teams discover the weakness only after a pipeline token or repo credential has already been used to alter cloud infrastructure, rather than through intentional design.
How It Works in Practice
Strong governance starts by separating three things that are often conflated: source control, build execution, and deployment privilege. Git should approve change, not own cloud authority. That means human reviewers validate Terraform plans, while the pipeline uses tightly scoped service accounts or workload identities to apply changes only after policy checks pass. NIST CSF 2.0 is useful here because it reinforces access control, change management, and auditability as operational requirements, not optional hygiene; see the NIST Cybersecurity Framework 2.0.
For Terraform in Azure DevOps or similar platforms, current guidance suggests four practical controls:
- Require protected branches, mandatory pull request reviews, and status checks before merge.
- Use short-lived credentials for pipeline jobs, not long-lived static secrets stored in variables or files.
- Keep deployment identities scoped to specific subscriptions, resource groups, or environments.
- Log every plan, approval, and apply step so the change path is auditable end to end.
The identity model matters. Workload identity is preferable to shared secrets because it proves what the pipeline is, not just what password it knows. In cloud-native environments, that usually means federated identity, ephemeral tokens, and policy-based authorisation at runtime. NHIMG’s Azure Key Vault privilege escalation exposure shows why secret storage alone does not solve privilege risk if the issuing identity is over-permissioned. These controls tend to break down when teams allow the same identity to review code, read secrets, and apply to production because one compromise then becomes a full infrastructure compromise.
Common Variations and Edge Cases
Tighter pipeline control often increases delivery friction, requiring organisations to balance release speed against the risk of unauthorized infrastructure change. That tradeoff is especially visible when teams use Terraform across many subscriptions, business units, or ephemeral preview environments. Best practice is evolving, but there is no universal standard for whether every environment should require the same approval depth.
In lower-risk nonproduction environments, some organisations use automated policy gates and lighter approval paths, while production applies stricter separation of duties, manual review, and just-in-time access. The important point is consistency of intent: the more destructive the target, the less acceptable static standing privilege becomes. This is where agents, automation, and infrastructure code governance intersect with broader NHI discipline described in NHIMG’s Ultimate Guide to NHIs and Ultimate Guide to NHIs.
Edge cases usually appear when platform teams centralize Terraform runners, when multiple repos share one deployment identity, or when secrets are injected dynamically but never rotated. Those patterns can work, but only if access boundaries are explicit and continuously reviewed. The weakest environments are the ones that treat pipeline accounts like developer convenience accounts instead of governed infrastructure identities.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10, OWASP Agentic AI Top 10 and CSA MAESTRO address the attack and risk surface, while NIST CSF 2.0 and NIST Zero Trust (SP 800-207) set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-01 | Terraform runners and deploy tokens are non-human identities needing lifecycle control. |
| OWASP Agentic AI Top 10 | A-03 | Autonomous pipelines can act like agents and need runtime authorization boundaries. |
| CSA MAESTRO | MAESTRO-4 | Covers agent and workflow privilege separation in automated execution chains. |
| NIST CSF 2.0 | PR.AC-4 | Least privilege and access management are central to pipeline governance. |
| NIST Zero Trust (SP 800-207) | SC-10 | Zero Trust supports continuous verification for pipeline and deployment identities. |
Inventory pipeline identities, scope them tightly, and remove standing access wherever possible.
Related resources from NHI Mgmt Group
- How should security teams add governance to existing Infrastructure as Code pipelines without disrupting delivery workflows?
- How should security teams govern Terraform module versions in large infrastructure estates?
- What do security teams get wrong about onboarding infrastructure as code platforms?
- How should security teams govern infrastructure as code for security platforms?
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on August 28, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org