← All technical notes

Security principles for infrastructure automation

Design automation around scoped identities, trusted inputs, and reviewable changes. Keep the path to production narrow and auditable.

Infrastructure automation concentrates authority. A small configuration change can create resources, change network access, or remove data. The objective is not simply to make the pipeline succeed. It is to make the pipeline’s authority understandable and to constrain the consequences of a mistake or compromised input.

The principles below are an architectural starting point. Examples are illustrative and must be adapted to the trust model, cloud platform, and recovery requirements of a real environment.

Map the trust boundaries

Write down what the workflow reads, what it can change, and which identities it uses. Include repository content, third-party actions, dependency registries, state storage, cloud APIs, and approval mechanisms. A deployment job inherits risk from every input it executes with its permissions.

Separate validation of an untrusted contribution from deployment of an approved revision. A pull request can propose changes to both application code and workflow definitions; it should not automatically receive production credentials merely because a job has started.

Review the automation configuration with the same care as the infrastructure configuration. A change to a job trigger or an environment rule can remove a control without altering a single resource definition.

Prefer scoped, temporary identities

Give each workflow only the operations and resource scope it needs. Separate environments and separate planning from applying where the tooling permits it. Avoid a general-purpose administrator credential shared across unrelated pipelines.

For platforms that support workload federation, use short-lived credentials with a constrained trust relationship. GitHub’s OpenID Connect documentation describes exchanging a workflow identity for a temporary cloud token. The cloud-side policy still needs to verify the relevant identity claims and restrict the resulting role.

An illustrative identity design might use:

  • A validation job with no cloud write access.
  • A planning identity that can inspect relevant resources and read the required state, with state treated as sensitive.
  • An apply identity restricted to the target environment, issued only after the deployment gate passes.
  • A separate recovery procedure, with controlled access and an audit trail, for situations the normal pipeline cannot repair.

Short token lifetime limits one dimension of exposure. It does not make a broad role safe, and it does not compensate for a trust policy that accepts unrelated workloads.

Make the reviewed change the applied change

Review is meaningful only when the executed input matches what was reviewed. Record the source revision and tool versions. Where supported, create a saved plan, protect it as a sensitive artifact, and apply that exact plan within a defined validity window.

A saved plan may become inappropriate after another actor changes the environment. Detect stale state, prevent concurrent changes to the same target, and require a fresh plan when preconditions no longer hold. Do not silently replace the reviewed plan with a newly generated one during deployment.

Plan artifacts and state files may contain secrets or sensitive identifiers. Protect their storage, transmission, access, and retention. Publishing a plan in a public pull request is not inherently safe just because it is text rather than a credential file.

Treat dependencies as executable inputs

A pipeline often downloads tools and runs reusable steps. Make those dependencies explicit. Pin executable dependencies to immutable identifiers where supported, verify integrity through an authenticated source, and review updates deliberately.

Pinning makes the selected input stable; it does not prove that input is trustworthy or current. Maintain a process for security updates and retire unused dependencies. A checksum obtained from the same compromised channel as a binary offers limited independent assurance.

Record the relationship between source and generated artifacts. SLSA provenance provides a vocabulary for verifiable information about where and how software artifacts were produced. Such records help investigation, but their value depends on who produced them and how verification is enforced.

Make logs useful without making them dangerous

Record the initiating revision, execution identity, target environment, approval reference, and result. Exclude secret values and avoid dumping full environments or request payloads. Masking features reduce accidental exposure; they should not be the only control.

Set retention and access according to the information in the logs. Test the failure path too: verbose error handlers and debugging output are common places for sensitive data to escape.

When AI is used to interpret logs or propose changes, retain these same boundaries. Read practical AI in DevOps workflows for a way to separate evidence, suggestions, and authority.

Verify the negative paths

A useful security check asks what the system refuses to do. In a disposable environment, confirm that an untrusted contribution cannot obtain deployment credentials, a job cannot modify resources outside its scope, and an expired or mismatched plan cannot proceed.

Also rehearse revocation and recovery. Identify how to stop running jobs, revoke access, preserve evidence, and restore service without handing every operator permanent administrative privileges.

These checks should produce observable outcomes rather than a claim that the pipeline is “secure.” For the execution side of the same problem, continue with designing reliable automation pipelines.