Deployment workflows often run with assumptions about trusted sources, approved environments, and limited operator scrutiny. If any of those assumptions are false, the workflow can pass API keys or tokens to an attacker-controlled command or URL. This is why secrets handling in CI must be tied to trust boundaries, not just to the presence of a secure branch.
Why This Matters for Security Teams
Deployment workflows are often treated as a safe automation layer, but they can become a high-risk path for secrets exposure when they execute code, fetch dependencies, or invoke deployment targets across trust boundaries. The risk is not limited to leaked passwords. It includes API keys, cloud tokens, signing credentials, and other secrets that can be abused for persistence or lateral movement. The NIST Cybersecurity Framework 2.0 is useful here because it frames this as a governance and control problem, not only a tooling problem.
Practitioners often assume that a protected branch, a reviewed merge request, or a locked-down runner is enough. That assumption breaks when workflow inputs, build steps, or deployment targets can be influenced by content outside the trusted boundary. A secrets risk appears whenever the pipeline can be induced to reveal credentials to code that was never meant to see them. In NHI terms, the workflow itself is acting like a non-human identity with authority, so its access needs the same scrutiny as any privileged service account. In practice, many security teams encounter this only after a credential has been used from an unexpected environment, rather than through intentional design of the pipeline trust model.
How It Works in Practice
CI deployment workflows usually hold secrets so they can authenticate to registries, cloud APIs, artifact stores, or production platforms. The exposure happens when a workflow step uses those secrets before the code, artifact, or external dependency has been fully trusted. That can occur through command injection in build scripts, malicious pull request content, compromised dependencies, or unvalidated environment variables that alter execution flow. Once the workflow executes an attacker-controlled command, the secret can be exfiltrated directly or used to mint additional access.
This is why best practice is to reduce standing secret exposure and bind credentials to the smallest possible trust boundary. Current guidance from the OWASP Non-Human Identity Top 10 aligns with treating pipeline credentials as high-value identities rather than inert configuration values. Practical controls usually include:
- Issuing short-lived credentials instead of long-lived static secrets where possible.
- Restricting secret availability to the exact job, environment, and step that needs it.
- Separating build, test, and deploy permissions so a compromise in one phase does not expose all secrets.
- Blocking untrusted code paths from accessing deployment secrets, including forked pull requests and unsanitised inputs.
- Using secret scanning, log redaction, and egress controls to limit accidental or deliberate disclosure.
For teams using modern automation, the key question is not whether the secret is stored securely, but whether the workflow can be tricked into presenting that secret to an untrusted execution context. This becomes especially relevant for agentic or highly dynamic pipelines, where automated steps may call tools, APIs, or shell commands with limited human oversight. These controls tend to break down when deployment logic is shared across multiple repositories and runner environments because trust boundaries become inconsistent and difficult to enforce.
Common Variations and Edge Cases
Tighter deployment controls often increase delivery friction, requiring organisations to balance release speed against the cost of additional approvals, credential rotation, and environment isolation. That tradeoff becomes sharper in fast-moving engineering teams, but it is usually cheaper than incident response after a compromised pipeline.
There is no universal standard for this yet, but current guidance suggests treating several environments as inherently higher risk. Self-hosted runners, shared build agents, and reusable workflow templates can widen the blast radius if secrets are inherited too broadly. The same applies when a deployment tool connects to third-party services that return detailed error output or command traces, because sensitive values may surface in logs even if the command itself never prints them.
Edge cases also arise in multi-stage release chains. A workflow may be safe during unit testing but unsafe during package signing, infrastructure provisioning, or production promotion if the later stage inherits earlier trust assumptions. Teams should also distinguish between secrets needed for machine-to-machine deployment and secrets used for human approval gates. Those two access patterns should not be managed the same way, especially where privileged non-human identities are involved. The safest pattern is to issue narrowly scoped credentials at the last responsible moment and revoke them as soon as the job completes. For organisations mapping this into a broader control set, the NIST CSF focus on protect, detect, and respond remains the most practical way to structure review and monitoring around deployment secrets.
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 and OWASP Agentic AI Top 10 address the attack and risk surface, while NIST CSF 2.0, NIST Zero Trust (SP 800-207) and NIST AI RMF set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST CSF 2.0 | PR.AC-4 | Deployment secrets must be limited to the right users and processes. |
| OWASP Non-Human Identity Top 10 | NHI-07 | CI jobs act as non-human identities that need lifecycle and privilege controls. |
| NIST Zero Trust (SP 800-207) | PA, PE | Zero Trust requires each workflow step to be verified before secret access. |
| NIST AI RMF | GOVERN | Automated workflows need ownership and accountability for secret handling decisions. |
| OWASP Agentic AI Top 10 | A2 | Dynamic or tool-using agents in pipelines can exfiltrate secrets through unsafe actions. |
Treat pipeline credentials as identities and enforce narrow scope, rotation, and revocation.