Because credentials are often written there as part of ordinary engineering work, not as a separate incident. Environment variables get persisted into profile files, installers write tokens into software directories, troubleshooting leaves values in logs, and runners cache job artefacts in workspaces that survive long enough to be discovered later.
Why this keeps happening in ordinary engineering workflows
Host filesystems and build agents are designed to make work fast, repeatable, and debuggable, so they naturally become temporary storage for values that were meant to be short-lived. The problem is that “temporary” often means long enough for another process, another job, or another user context to read them later. That turns routine convenience into recurring secret exposure.
The exposure is not usually a single failure point. It is the accumulation of normal engineering behaviours: environment variables copied into shell profiles, installers writing tokens into application directories, logs capturing values during troubleshooting, and CI runners preserving workspace artefacts between jobs. Each one is defensible in isolation, but together they create a persistent trail of credentials on systems that are assumed to be ephemeral.
Build agents make this worse because they are trusted to execute many tasks in succession. If a runner reuses disks, caches, workspaces, or containers, a secret written for one job can remain reachable by later jobs with different privileges or different code provenance. On shared or poorly isolated infrastructure, that becomes a straightforward path from convenience to unintended access.
Where the exposure is created on the host
On host filesystems, secrets usually appear in places engineers do not think of as secret stores. Shell startup files, application configuration files, package caches, crash dumps, command histories, temp directories, and installer logs all become possible landing zones. The exposure persists because these paths are part of the normal operating environment, not treated as security-sensitive artefacts.
The important pattern is that many of these writes happen indirectly. A developer may not intentionally save a token, but a tool can echo it into output, cache it in a profile update, or include it in a diagnostic bundle. Once written, the secret may be copied into backups, synced into artefact storage, or left behind after the original process exits. That is why the issue recurs even when no one believes they are “storing secrets on disk.”
Build systems amplify the same pattern through job logs, checked-out source trees, dependency caches, and archived outputs. For practitioners, the relevant question is not whether a secret can be written somewhere during execution, but whether the platform guarantees that it is removed, isolated, and unreadable after the job ends. Without that guarantee, the filesystem becomes part of the attack surface.
Why build agents and runners turn one leak into many
Build agents are especially prone to repetition because they run at scale and follow the same patterns thousands of times. If one pipeline step leaks a credential into a workspace, every subsequent build on that runner may inherit the same exposure unless the environment is fully cleaned. That creates a recurring exposure model, not a one-off incident model.
Isolation quality is the key variable. A single-tenant runner with enforced cleanup behaves very differently from a pooled runner with reused workspaces, shared caches, or long-lived containers. The more shared the environment, the more a secret written for one build becomes discoverable by another build, another branch, or another team. This is why build infrastructure is often a secrecy problem as much as a software delivery problem.
Security teams should treat build-agent persistence as a control issue, not a housekeeping issue. Once a runner can retain state across jobs, any secret written to disk can become recoverable by later code paths, log collectors, or incident responders. For an implementation perspective, the Secret Sprawl challenge is a useful lens on how CI/CD exposure, hardcoded values, and remediation gaps reinforce one another. Secrets management guidance helps frame the same issue around centralisation, rotation, and reducing the need to place sensitive values on host storage in the first place.
Risk and Threat Considerations
Recurring exposure matters because it creates a low-friction path for accidental disclosure and post-compromise discovery. Even if no attacker is present at the moment a secret is written, any later compromise of the host, runner, backup set, or job artefact store can turn that residue into usable access.
Failure mechanism: secrets persist in files, caches, logs, or workspaces longer than intended, then are recovered by later jobs, operators, backups, malware, or anyone with filesystem access.
Impact: the result can be account takeover, lateral movement, repository access, API abuse, or repeated secret reuse across environments when the same value is copied into multiple jobs or hosts.
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 API Security Top 10 address the attack and risk surface, while CIS Controls v8 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-02 — Secret Leakage | Host files and runners leaking tokens is direct secret leakage. |
| NHI-07 — Long-Lived Secrets | Recurrence is driven by secrets persisting beyond the intended job window. | |
| NHI-08 — Environment Isolation | Shared runners and reused workspaces make one job's secret visible to another. | |
| Recommendation — Eliminate plaintext secrets from host storage and job artefacts. Shorten secret lifetime and rotate values that may persist on disk. Isolate build environments and prevent cross-job workspace reuse. | ||
| CIS Controls v8 | CIS-3 — Data Protection | Secrets written to files, logs, and artefacts require data-handling controls. |
| CIS-8 — Audit Log Management | Troubleshooting output and logs are a common persistence path for credentials. | |
| Recommendation — Restrict sensitive data storage in logs, caches, and artefact paths. Protect logs from containing or retaining secrets and scrub them promptly. | ||
| NIST SP 800-53 Rev 5 | IA-5 — Authenticator Management | Tokens and credentials on hosts require lifecycle and rotation controls. |
| AU-9 — Protection of Audit Information | Build logs and diagnostics can retain secret material if not protected. | |
| SI-11 — Error Handling | Troubleshooting and error output often become unintended secret storage. | |
| Recommendation — Rotate authenticators and remove any that are exposed on build systems. Protect logs from disclosure and sanitize sensitive output before retention. Prevent error handling from writing sensitive values to persistent outputs. | ||
| OWASP API Security Top 10 | API2 — Broken Authentication | Exposed tokens and API keys on hosts directly weaken authentication security. |
| API9 — Improper Inventory Management | Recurrence grows when hidden copies of secrets are not inventoried. | |
| Recommendation — Replace exposed host-stored tokens with safer authentication mechanisms. Inventory where secrets are stored so hidden copies can be removed. | ||
Practitioner Guidance
What to verify: Check whether your runners, images, and host build paths are actually wiped between jobs, including caches, temp files, log bundles, and workspace archives. If cleanup depends on best effort rather than enforced deletion, treat the environment as stateful.
Decision rule: If a secret can authenticate to production, assume filesystem persistence is a material exposure and rotate or remove the secret before relying on post-job deletion alone. If the value only appears in transient logs, still validate whether those logs are shipped, retained, or searchable elsewhere.
Common mistake: Teams often fix the source of the leak but leave the residue in artefact storage, backups, or runner caches. That makes the original issue look resolved while the exposure path remains intact.
Practitioner takeaway: The practical goal is not to prevent every write, it is to ensure that no build path can leave reusable secret material behind after the job boundary has passed.
Related resources from NHI Mgmt Group
- Why do AI agents create a bigger secret exposure problem than ordinary automation?
- Why do unpinned security tools in build pipelines create outsized risk for identity and secret exposure?
- Why do host filesystems increase the risk of secret exposure in modern infrastructure?
- What is the difference between rotating a secret and revoking access?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on October 5, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org