Automation creates speed, but persistent secrets storage creates avoidable exposure. When build systems can retrieve credentials only during execution, organisations reduce the chance of long-lived secrets leaking into code, logs, or shared files. This approach also narrows the blast radius if a pipeline or script is compromised, because access is temporary and task-scoped.
Why JIT access changes the security model for automation
Automation and build pipelines are most useful when they can move fast without carrying long-lived secrets around with them. Just-in-time access changes the model from “store once, reuse forever” to “obtain only when needed, use briefly, then expire.” That matters because pipelines are high-churn environments, and anything persistent tends to be copied, cached, echoed, or inherited more widely than teams expect.
Persistent secrets are not just a storage problem, they are an exposure problem. A credential that sits in a repo variable, file, image layer, or shared runner can outlive the job that needs it and remain usable after the original task is over. By contrast, JIT access makes the credential’s lifetime match the work, which is a better fit for automation that is meant to be transient and repeatable.
For pipelines that interact with privileged systems, the security issue is not whether a secret is convenient, it is whether it can be reused outside the intended execution window. That is why patterns such as temporary role activation, short-lived tokens, and secret retrieval at execution time are so widely preferred in modern build and deployment design. They reduce the chance that automation becomes a standing access path.
One useful way to think about this is that JIT access preserves automation, but removes standing privilege. The pipeline still authenticates and performs its work, yet it does not need a durable credential that remains valid between runs. That distinction is especially important when multiple jobs, environments, or teams share the same runners or orchestration layer.
Where teams want a broader implementation view, the Privileged Access Management Guide and the Just-in-Time Access and Zero Standing Privilege Guide both frame JIT as a way to replace always-on privilege with task-scoped elevation. For secret handling specifically, the Secrets Management Guide explains why dynamic retrieval and secretless patterns are often safer than storing credentials in the pipeline itself.
What can go wrong when secrets persist in build systems
Persistent storage creates a larger attack surface because the credential can leak through more than one path. Logs, environment dumps, debug output, cached artifacts, copied scripts, and inherited runner state can all expose the same secret long after the job that used it has completed. Once that happens, the credential is often valid in places the original operator never intended.
The second problem is blast radius. If an attacker compromises a pipeline, a runner, or a script execution context, a persistent secret can be reused later against production systems, SaaS services, or cloud control planes. That turns a single build compromise into a broader identity and access event, especially when the secret is powerful enough to deploy code, change infrastructure, or read sensitive data.
Persistence also complicates rotation. Long-lived secrets are harder to inventory, harder to prove unused, and more likely to be embedded in multiple places at once. The result is a control gap: even after a secret is rotated in one system, replicas may still exist in scripts, caches, backups, or downstream jobs.
The Guide to the Secret Sprawl Challenge is directly relevant here because CI/CD exposure and hardcoded credentials are common failure modes. The Guide to NHI Rotation Challenges adds the operational angle: rotation is necessary, but it becomes much more manageable when secrets are short-lived rather than buried in many persistent copies.
How to design pipelines around ephemeral credentials instead of stored secrets
The practical design goal is to make credential access conditional on execution, not on possession of a stored value. In mature implementations, the pipeline authenticates to a trusted issuer or broker, receives a scoped credential for the job, and loses that credential automatically after the run or at expiration. That makes the secret useful to the task and far less useful to anyone who later copies the job context.
Good designs also separate identity from storage. The pipeline should prove who or what it is, then receive a narrowly scoped token or certificate rather than retrieving a reusable password from a central pile. This is especially effective when the credential is audience-bound, short-lived, and limited to one environment, one repository, or one deployment action.
The operational check is simple: if the job can still function after the secret expires, the access was probably too broad. If the job needs the same credential days later, the team may have built convenience at the expense of containment. JIT access is strongest when it is paired with least privilege, clear expiry, and explicit task boundaries.
If you need implementation references, the Secrets Management Guide supports secretless and dynamic-secret patterns, while the API Key Management Guide is useful when build systems still depend on API-based automation and the keys must be scoped, rotated, and revoked cleanly. For a standards-based view of ephemeral or tokenised access, RFC 6749: The OAuth 2.0 Authorization Framework and RFC 8705: OAuth 2.0 Mutual-TLS Client Authentication and Certificate-Bound Access Tokens both illustrate how machine access can be made more bounded than shared secret storage.
Risk and Threat Considerations
Build and automation credentials are attractive targets because they often sit close to deployment, infrastructure, and data access. If attackers obtain a persistent secret, they may not need to break the pipeline again, they can simply reuse the credential until it is detected and revoked. That is why long-lived secrets create both exposure and persistence risk.
Failure mechanism: A credential stored for convenience is copied into logs, artifacts, configuration files, or shared runners, then reused after compromise because it does not expire quickly enough or is valid in too many places.
Impact: The compromise can extend from one job or script to production systems, cloud resources, or third-party services, increasing the chance of lateral movement, unauthorized change, and difficult-to-contain blast radius.
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 addresses the attack and risk surface, while NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-02 — Secret Leakage | Build pipelines commonly leak stored credentials into logs, files, and artifacts. |
| NHI-05 — Overprivileged NHI | Pipeline access should be task-scoped to avoid unnecessary standing privilege. | |
| NHI-07 — Long-Lived Secrets | The question directly contrasts persistent secrets with JIT credential use. | |
| Recommendation — Use short-lived credentials and remove static secrets from pipeline storage. Limit automation credentials to the smallest feasible scope and duration. Replace long-lived pipeline secrets with expiring, job-scoped credentials. | ||
| NIST SP 800-53 Rev 5 | IA-5 — Authenticator Management | Credential lifecycle, rotation, and expiration are central to this question. |
| IA-9 — Service Identification and Authentication | Automation and build systems authenticate as non-human actors to other systems. | |
| AC-6 — Least Privilege | JIT access is a least-privilege pattern for privileged automation. | |
| Recommendation — Enforce expiration, rotation, and secure handling for automation authenticators. Issue scoped, short-lived authenticator material for services and workloads. Grant only the permissions required for the current pipeline task. | ||
| CIS Controls v8 | CIS-5 — Account Management | Persistent secrets and standing access are account-lifecycle problems in automation. |
| CIS-3 — Data Protection | Secrets in logs, artifacts, and files are a direct data-exposure issue. | |
| Recommendation — Inventory automation accounts and remove standing access wherever possible. Prevent credential exposure in logs, artifacts, caches, and configuration. | ||
Practitioner Guidance
What to prioritise: Treat any credential that survives beyond a single job as a design exception, not the default. The first question is whether the pipeline can obtain a short-lived credential at execution time, because that changes both exposure and recovery.
What to verify: Confirm the credential has a real expiry, task scope, and environment boundary, and that it is not copied into logs, cache layers, or reusable runner state. If the same secret is needed across unrelated jobs, the access pattern is too broad.
Common mistake: Teams often secure storage but leave the credential long-lived. That reduces casual leakage, but it does not solve reuse after compromise. The stronger control is to reduce the lifetime and reuse potential of the credential itself.
Practitioner takeaway: The right question is not where to store the secret most safely, but whether the automation can work with a credential that disappears as soon as the task is done.
Related resources from NHI Mgmt Group
- What breaks when organisations rely on persistent access instead of just-in-time controls?
- How should security teams implement just-in-time secret access for workloads that need both cloud credentials and application secrets?
- What is the difference between centralized secrets storage and secrets access automation?
- What happens when third-party access is managed through standing credentials instead of just-in-time approval?
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on September 28, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org