Situation: a deployment secret appeared in a build log
A SaaS product team discovers that a token capable of deploying an application was printed by a continuous integration job. The same token is referenced by scheduled builds and may be embedded in a past log bundle downloaded by a support engineer. The immediate decision is not just to change a value in a secret store. The team must establish which permissions the token granted, whether it was exposed outside the intended audience, which jobs still depend on it and how to recover safely without losing release integrity. This is an authorised runbook for a fictional test pipeline. The instructions should be adapted to actual tooling by qualified operators and should never be trialled with production customer secrets in a shared environment.
Appoint an incident coordinator, pipeline owner, identity administrator, release engineer and service owner. The coordinator keeps a timeline and decides when to escalate beyond a contained operational leak. The identity administrator controls key invalidation and privileged role review. The release engineer ensures that replacement credentials can reach the correct build and deployment systems. The service owner approves the business risk of pausing deployments. Define the incident’s known facts: token identifier or fingerprint, first visible log, job run, repository or pipeline access policy, secret scope and current expiry. Do not paste the token itself into the incident ticket or chat transcript.
Locate copies before claiming containment
Inspect the build job’s normal log, downloadable raw log, artefact store, shared cache, error telemetry, support attachments and any external notification that reproduced the output. A redaction rule added today may not remove earlier exported copies. Record where copies may exist, their retention settings and who had permission to read them during the exposure window. Where audit evidence is unavailable, state the uncertainty rather than declaring that nobody accessed the log. The investigation should distinguish a token that merely resembled a credential from one that was valid at the time. Validation must avoid using the leaked secret in an unauthorised system; the identity owner should inspect the issuer and policy records instead.
The team should calculate the token’s effective capabilities, including service accounts it could impersonate, deployment environments it could modify, stored secrets it could read and artefacts it could sign or publish. A token labelled “CI” may have indirect production authority through a build runner or package repository. Map each path from token to receiving action. If a contractor or external support portal had access to the logs, review its actual access trail and contract scope. Do not conclude compromise solely because a secret was visible; separately assess use, potential use and unknown access. Evidence of an unauthorised deployment is a more serious finding than an exposed but unused scoped test token.
Decide which activity to stop first
Pause vulnerable publication jobs where a leaked token could let another party modify a release. Preserve the last trusted build, repository commit, runner configuration and artefact signatures before changing the environment. The release owner must decide whether to freeze all deployments, restrict only one environment or continue low-risk tasks with an alternate credential. An indiscriminate shutdown may prolong customer impact while failing to address a compromised artefact store. Record the purpose and expiry of each temporary restriction. Where a token has production deployment authority, prioritise preventing further unauthorised changes rather than collecting unlimited additional logs while leaving the credential active.
The identity administrator revokes or disables the known token using the issuer’s actual mechanism and checks for derived sessions, cloned credentials or alternate credentials created while it was valid. A short TTL is helpful only if the service actually rejects expired tokens at the enforcement boundary. Where revocation cannot invalidate already issued session credentials, determine their maximum lifetime and apply compensating restrictions. Confirm the change with a denial test using a designated synthetic credential in a test environment. A “secret rotated” message from the vault is not proof that the old token is unusable in the deployment API.
Replace the credential without recreating the weakness
Issue the narrowest viable replacement permission and prefer short-lived workload identity federation where the pipeline and receiving service support it. Bind the credential to a specific repository, environment, job identity or audience as appropriate to the platform. Avoid issuing a new standing global administrator token just because it is quick to configure. Update the secret reference in the approved pipeline configuration, confirm encryption and access rules in the store, and ensure the value is not passed to shell tracing, unmasked exceptions or downloadable diagnostics. Do not push the new token through a repository commit or ad hoc email message to make builds run again.
Use a staged test deployment to a disposable environment with synthetic application data. Verify that the new identity can read the required package and deploy only to its intended test target. Attempt a deliberately prohibited deployment to a second environment; it must fail with an attributable denial. Check that the log redaction mechanism handles known output paths but do not depend on redaction as the primary security control. A secret that never reaches a log is more defensible than one that is printed and masked by an unreliable pattern. Capture the identity policy version, source commit, job run and receiving-system authorisation event.
Rebuild trust in the artefacts
A leaked token could enable tampering with packages or deployment manifests, depending on its actual permissions. Compare affected build outputs to independently trusted source commits, provenance records and available digital signatures. Identify releases produced during the uncertain interval and determine whether they require rebuilding from a clean runner. Re-running the same potentially compromised workspace is not necessarily a fresh build. Preserve evidence of the original image digest and the rebuilt digest, and document whether they differ for legitimate reproducibility reasons. Where a trusted signing service is separate from the deployment token, verify that boundary. If the leaked identity could alter signatures or signing configuration, increase the review scope accordingly.
Inspect runner persistence and caches. A build that reuses a contaminated cached dependency or attacker-modified intermediate artefact can reproduce an unsafe package even after token rotation. In the test scenario, initialise a clean runner, pin approved dependencies, rebuild the sample product and test the deployed application against expected checksums and behaviour. Check downstream release notes, container registry tags and rollback references so the team does not inadvertently redeploy an untrusted build later. Any production release decision belongs to the service owner and release authority; the runbook should not imply that cryptographic signatures alone prove the code is safe.
Validate service continuity through positive and negative cases
Run four acceptance cases. An authorised synthetic pipeline deploys the expected test build; the new service identity is recorded and no secret appears in logs. The revoked token attempts a prohibited test deployment and is denied at the target API. A job from an unapproved repository or branch attempts to request the new workload identity and is refused. Finally, a pipeline exception deliberately prints a secret-shaped dummy value and the logging controls handle it according to policy, with no real key involved. Each test should include run ID, expected outcome, actual receiving-system event, artefact digest and reviewer. An HTTP success from the CI control plane is not proof that target permissions were correct.
Exercise the rollback if the replacement identity breaks a legitimate deployment. The approved rollback should restore service using a different safe credential or a prevalidated trusted release, not reactivate the leaked token. If the team cannot deploy safely, maintain the release freeze and escalate the business consequence. Recovery must preserve the ability to explain what ran in production during the exposure window. A new credential that supports releases while losing that attribution is not a complete recovery. The service owner should understand which environments remain blocked and why, rather than receiving only a technical statement that “rotation finished”.
Record the decision and prevent recurrence
The final incident pack contains the exposure window, copy locations, effective permissions, evidence of use or non-use, revoked identities, replacement configuration, trusted artefact verification and unresolved uncertainties. Assign separate outcomes for credential invalidation, release integrity and customer-data assessment. A leaked deployment token may not have read data directly but might have allowed publication of code that later handled it; that pathway deserves a reasoned assessment. Legal or customer notification decisions require appropriate specialist review and should not be inferred automatically from the presence of a token in a log.
After the immediate work, redesign the pipeline so that sensitive credentials are retrieved only when needed and cannot be echoed by ordinary logging commands. Reduce persistent scopes, apply environment approvals, restrict which jobs can assume a deploy identity and schedule a clean-room recovery exercise. Review other pipelines that copied the same configuration pattern, with an evidence-based sample rather than a declaration that all secrets are safe. Rehearse a failure of the central identity provider as well: the build system should fail safely instead of falling back to an undisclosed permanent credential. The measure of success is the ability to show precisely which identity deployed which trusted artefact, and that the exposed credential no longer performs any authorised deployment action.
Sources and further reading
Explore Next Defence expertise
Next Defence can help organisations assess the technical and business exposure examined in saas ci/cd secret leakage: a practical containment and rotation runbook. Our team can review the available source records, test the relevant access or operational controls and work with accountable owners to deliver safe scope verification, coordinated rotation and retired-token negative test.