An infrastructure as code platform holds standing permission to create, change and destroy your cloud estate, so whoever controls it can rewrite networks, open storage to the internet or delete production without touching a cloud console. A central IaC platform is the service that runs plan and apply on behalf of teams: a control plane with workspaces or projects, runners that execute the tool, state storage, a policy engine, module and provider sources, and the cloud identities that every apply uses. This guide is for platform engineers, cloud security architects and the owners of that service. It treats the platform as a high-value system in its own right and covers admin roles, the machine identities it holds, keys and state, its own logs, hardening and lifecycle. It does not repeat how to write secure templates or scan them; that is in the Infrastructure as Code Security Guide. It is vendor-neutral and applies to self-hosted orchestrators, managed IaC services and pipeline-based setups alike: confirm exact setting names in your own product's documentation.
Key takeaways
- The platform is tier 0 for the cloud. Its apply identities can change everything they deploy, so its administrators and tokens deserve the same treatment as cloud organisation administrators.
- Separate the people who write policy from the people who apply. Whoever can edit policy sets, runner pools or workspace credentials can bypass every gate the platform enforces.
- State is a secret store. State files and plan outputs routinely contain resource attributes, connection strings and generated passwords; protect, encrypt and audit them as secrets.
- Runners are where credentials live. A shared, long-lived runner turns one malicious module into access to every workspace that runs there.
- Logs must leave the platform. Platform admins can change platform settings; the evidence of who approved and applied what has to be held somewhere they cannot edit.
Why the IaC platform is a high-value target
The NSA and CISA guidance Defending Continuous Integration/Continuous Delivery (CI/CD) Environments (June 2023) treats the delivery pipeline as an attack path in its own right and calls for least privilege, two-person review, short-lived credentials, signed configuration and code, and audit logs that record who committed, reviewed and deployed each change. It also warns specifically against hardcoding secrets in IaC templates. An IaC platform concentrates all of those concerns at the infrastructure layer, where a single apply can change identity policy, networking and data stores together.
The OWASP Top 10 CI/CD Security Risks gives a useful vocabulary for what goes wrong. Applied to an IaC platform:
| OWASP risk | How it shows up on an IaC platform | Control in this guide |
|---|---|---|
| CICD-SEC-1 Insufficient Flow Control Mechanisms | Production applies without approval, or auto-apply on unreviewed branches | Approval and apply rules |
| CICD-SEC-2 Inadequate Identity and Access Management | Too many platform admins, local accounts, no MFA | Admin roles and separation of duties |
| CICD-SEC-3 Dependency Chain Abuse | Unpinned modules or providers pulled from public sources at run time | Module and provider sources |
| CICD-SEC-4 Poisoned Pipeline Execution (PPE) | A pull request changes code that runs during plan with real credentials | Plan and apply identity split, runner isolation |
| CICD-SEC-5 Insufficient PBAC (Pipeline-Based Access Controls) | Every workspace's run can reach every cloud account | Per-workspace federated identities |
| CICD-SEC-6 Insufficient Credential Hygiene | Static cloud keys stored as workspace variables | Machine identities and keys |
| CICD-SEC-7 Insecure System Configuration | Outdated control plane, public admin interface, default settings | Hardening the platform |
| CICD-SEC-9 Improper Artifact Integrity Validation | Plan reviewed, but a different plan applied | Saved plan integrity |
| CICD-SEC-10 Insufficient Logging and Visibility | Platform audit events never reach the SIEM | The platform's own logs |
In MITRE ATT&CK terms, attackers most often reach the platform through valid accounts (T1078.004 Cloud Accounts) or credentials left in files (T1552.001 Credentials In Files), and a poisoned module or provider is a form of T1195.002 Compromise Software Supply Chain.
Admin roles and separation of duties
Most IaC platforms offer organisation, team and workspace or project scopes. Design the roles before onboarding teams, because unwinding broad grants later is slow.
| Role | Can do | Should not be able to do | Typical holders |
|---|---|---|---|
| Platform owner | Organisation settings, SSO, runner pools, audit configuration | Approve production applies in team workspaces day to day | 2 to 3 named engineers, phishing-resistant MFA, privileged access workstation |
| Policy author | Change policy sets through a reviewed repository | Change workspace credentials or runner assignment | Cloud security team |
| Workspace maintainer | Workspace variables (non-secret), triggers, team membership | Edit policy sets, override mandatory policies | Team leads |
| Applier or approver | Approve and apply a reviewed plan in named workspaces | Approve their own change in production | Engineers in the owning team |
| Reader | View runs and plans | View sensitive outputs or state where the product allows separation | Wider engineering, auditors |
- Federate all human access: sign in only through the corporate identity provider, disable local password accounts except one sealed break-glass account, and provision team membership through groups. See the Break-Glass Account Guide.
- Protect policy as code: keep policy sets in their own repository with branch protection and a second reviewer from the security team; the platform should load policy only from that repository. Treat a mandatory policy override as a privileged action with its own approval and an alert.
- Two-person rule for production: the person who merges a change should not be the only approver of its production apply. The NSA and CISA guidance makes two-person review its baseline control against a single compromised account.
- Recertify quarterly: platform owner, policy author and production approver grants, plus every API token. The Infrastructure as code platform health check gives the metrics.
Machine identities: runners, apply identities and tokens
The platform is mostly operated by non-human identities. List them explicitly, because each is a credential an attacker can use.
| Identity | Purpose | Preferred form | Main risk if mishandled |
|---|---|---|---|
| Plan identity (per workspace) | Read cloud state to calculate a plan | Federated, short-lived, read-only | Pull requests run untrusted code with write rights (PPE) |
| Apply identity (per workspace) | Make the changes | Federated, short-lived, scoped to the workspace's accounts and resource types | One workspace can change another team's estate |
| Runner registration credential | Join a runner to a pool | Single-use or short-lived, stored in a secrets manager | A rogue runner receives jobs and their credentials |
| Platform API tokens | Automation that creates workspaces or triggers runs | Team or service scoped, expiring, owned | Long-lived organisation token equals full platform control |
| Source control integration | Read repositories, post plan results | App installation scoped to named repositories | Read access to all code, or write access to merge |
| State backend access | Read and write state | Per-workspace path or bucket permissions | Read every environment's secrets in state |
- Federate cloud access: replace stored access keys with workload identity federation, binding each trust to the workspace, project and run phase claims the platform issues. The NSA and CISA guidance recommends cloud-provided temporary credentials for software. Details are in the Workload Identity Federation Guide and the Workload Identity Federation vs Static Cloud Keys.
- Split plan from apply: plans on pull requests run with read-only identities; only applies from the protected branch receive write identities.
- Own every identity: each has a named team owner, a purpose and a review date in the NHI inventory. See the NHI Ownership Guide.
Keys, state and plan integrity
State is the platform's most sensitive data. It maps the whole estate and often contains values the template marked sensitive, because the tool needs them to compare desired and actual state.
- Encrypt state at rest with a customer-managed key held in your key management service, with key use logged and the key policy limited to the platform's state service role. See Securing the cloud key management service (KMS) itself.
- Separate state per environment and per workspace, so a non-production identity can never read production state. Turn on object versioning and locking so state can be restored and concurrent writes are refused.
- Restrict state readers: humans should not need routine raw state access; treat each read as a sensitive event in the logs.
- Keep secrets out of state where you can: have resources fetch secrets at run time from a secrets manager instead of passing values through variables. See the Secrets Management Guide.
- Apply only the reviewed plan: store the saved plan as a run artefact, record its hash, and apply that artefact rather than re-planning at apply time. A change in hash between approval and apply should stop the run.
- Pin modules and providers: mirror them into an internal registry, pin versions and verify checksums or signatures. The Software Supply Chain Security Guide covers dependency controls in depth.
Runner isolation
Runners execute provider code and any local scripts a module calls, with the apply identity loaded. NIST SP 800-204D, Strategies for the Integration of Software Supply Chain Security in DevSecOps CI/CD Pipelines, treats build and deployment stages as part of the software supply chain to be secured. For IaC runners that means:
- Ephemeral by default: a fresh runner per job, destroyed afterwards, so nothing survives from one workspace's run to the next. The NSA and CISA guidance also calls for removing temporary resources after pipeline runs.
- Pools per trust level: production and non-production never share a runner pool, and tier 0 workspaces (identity, organisation policy, logging accounts) get their own.
- Egress control: runners reach the cloud APIs, the internal module registry and the state backend, not the open internet.
- No instance-level credentials: runners on cloud instances should not carry a powerful instance role that every job inherits; block or restrict metadata service access from job processes (ATT&CK T1552.005 Cloud Instance Metadata API describes the abuse).
The Self-hosted CI/CD Runners and Build Agents guide gives host-level hardening.
The platform's own logs
Collect three layers and forward them to a SIEM the platform's administrators cannot alter:
| Layer | Events to keep | High-value alert |
|---|---|---|
| Platform control plane | Sign-ins, role and team changes, token creation, workspace variable changes, policy set changes, policy overrides, run approvals and applies | New organisation token or platform owner; mandatory policy override; apply with no recorded approval |
| Runners | Job start and end, workspace, image version, outbound connections | Job on a runner outside its assigned pool; unexpected outbound destination |
| Cloud audit logs | Every write by apply identities, and every write by any other identity to platform-managed accounts | Change in a managed account by an identity that is not an apply identity or break-glass role |
Retain platform audit events for at least as long as your cloud audit logs so an apply can be traced from commit to approval to API call. The NSA and CISA top ten misconfigurations advisory lists inadequate internal network monitoring and poor credential hygiene among the most common weaknesses its teams find; both show up on IaC platforms as missing platform logs and unrotated tokens.
Hardening the platform: a phased approach
- Inventory (week 1 to 2): list admins, tokens, workspaces, runner pools, state locations, cloud identities and integrations. Mark tier 0 workspaces. Do not change anything yet.
- Close the front door (weeks 2 to 4): enforce SSO and phishing-resistant MFA, remove local accounts except break-glass, cut platform owners to a named few, expire unowned API tokens. Test break-glass sign-in before removing anything else.
- Log out (weeks 3 to 5): forward control plane, runner and cloud audit logs and build the alerts above, so the next phases are observed.
- Replace static credentials (weeks 4 to 10): move workspaces to federated plan and apply identities in waves, non-production first. Keep the old key disabled, not deleted, for one release cycle so a failed migration can be rolled back, then delete it.
- Isolate runners and protect state (weeks 6 to 12): move to ephemeral pools by trust level, encrypt state with customer-managed keys, split state access per environment.
- Lock policy and plan integrity (weeks 8 to 14): move policy sets into a protected repository, start new mandatory policies in advisory mode for two weeks, then enforce; turn on saved plan apply.
- Measure and recertify (ongoing): run the health check quarterly.
Decision guidance
- Managed service or self-hosted control plane: a managed service moves patching and availability of the control plane to the provider, but your state, tokens and audit export settings stay yours. Self-hosting gives network isolation and key custody at the cost of running and patching the control plane yourself. Either way, keep runners for tier 0 workspaces inside your own network.
- Central platform or pipelines per team: a central platform gives one place to enforce policy and log, but becomes a single high-value target; team pipelines spread the risk but multiply the credentials to govern. Most organisations above a few teams centralise and invest in isolation.
- Small organisations: one platform owner plus a deputy, federated identities from day one, a single protected policy repository and separate production runners is a sound minimum.
- Large organisations: separate platform instances or organisations for tier 0 infrastructure, dedicated policy authors, and automated token expiry.
Lifecycle: buy, run, retire
- Selection: ask for SSO and group-based roles, audit log export, short-lived federated credentials, customer-managed state encryption, policy enforcement with override logging and self-hosted runner options.
- Operation: patch the control plane and runner images on your normal schedule; rebuild runner images regularly rather than patching in place.
- Migration and retirement: when moving platforms, export and archive audit history, move state with integrity checks, revoke every token, federation trust and runner registration credential of the old platform, and remove its trust relationships from each cloud account. The Infrastructure as code platform rollout playbook covers onboarding on the new side.
Detection and measurement
- Federation coverage: share of workspaces using only federated, short-lived cloud identities (target 100% in production).
- Out-of-band writes: writes to managed accounts by identities other than apply identities or break-glass roles (target zero).
- Policy overrides: mandatory policy overrides per 100 production applies, each with an approval.
- Privileged population: number of platform owners and organisation-scoped tokens, trending down to the agreed minimum.
- Runner reuse: share of production runs on fresh runners (target 100%).
Framework mapping
| Control area | NIST SP 800-53 Rev. 5 | NIST CSF 2.0 | CIS Controls v8.1 |
|---|---|---|---|
| Admin roles, separation of duties | AC-2, AC-5, AC-6 | PR.AA-05 | Control 5, Control 6 |
| Machine identities and tokens | IA-5, AC-6 | PR.AA-01 | Control 5 |
| Change approval and policy as code | CM-3, CM-5 | PR.PS-01 | Control 4, Control 16 |
| State encryption and key management | SC-12, SC-28 | PR.DS-01 | Control 3 |
| Module, provider and plan integrity | CM-14, SI-7, SR-4 | PR.PS-01 | Control 16 |
| Logging and monitoring | AU-2, AU-6, AU-9 | PR.PS-04, DE.CM-09 | Control 8 |
Common failure patterns
- Policy authors who can also apply: a single engineer able to relax a policy and apply the change it was blocking.
- Plans with write credentials: pull request plans running with the apply identity, so any contributor can run code with production rights.
- One organisation token in a script: created for a migration, never expired, stored in a pipeline variable.
- Shared state bucket: every environment in one location with one access role, so a test workspace can read production secrets.
- Long-lived shared runners: files, caches and credentials persisting between jobs from different workspaces.
- Audit log left in the product: no export, short retention, and no way to prove who approved a damaging apply. If the platform is already suspected of misuse, follow If your infrastructure as code platform is compromised.
Practitioner checklist
- SSO and phishing-resistant MFA enforced; only one sealed break-glass local account.
- Platform owners limited to a named few; policy authors and production approvers are different people.
- Policy sets loaded only from a protected, reviewed repository; overrides logged and alerted.
- Every workspace uses federated, short-lived plan and apply identities; no stored cloud keys.
- API tokens scoped, expiring and owned; organisation-scoped tokens reviewed quarterly.
- State encrypted with a customer-managed key, split per environment, versioned and locked.
- Saved plan applied with hash check; modules and providers pinned and mirrored.
- Ephemeral runners in pools by trust level, with egress control.
- Control plane, runner and cloud audit logs in a SIEM outside the platform admins' control.
- Quarterly health check run and findings tracked.
Standards and references
- NSA and CISA: Defending Continuous Integration/Continuous Delivery (CI/CD) Environments
- NIST: SP 800-204D, Strategies for the Integration of Software Supply Chain Security in DevSecOps CI/CD Pipelines
- NIST: SP 800-53 Rev. 5, Security and Privacy Controls
- NIST: Cybersecurity Framework 2.0
- OWASP: Top 10 CI/CD Security Risks
- NSA and CISA: Top Ten Cybersecurity Misconfigurations
- MITRE ATT&CK: Compromise Software Supply Chain
- CIS: Critical Security Controls v8.1
Related NHI Mgmt Group resources: Infrastructure as Code Security Guide, Infrastructure as code platform health check, Workload Identity Federation Guide, If your infrastructure as code platform is compromised.