Runbook · Security

Secrets in build logs: scope, rotate, purge, prevent

A credential printed by CI is not a log-hygiene problem. It is an exposure with a clock: every reader, artifact and fork already has it. This runbook is the scope-and-rotate path.

Command output

set -x, a verbose CLI, or an error dump prints the credential before anyone notices.

Masking misses

Base64, URL-encoding or a split value no longer matches the mask; the log looks safe and is not.

Artifacts and caches

.env, fixtures and build caches are downloadable long after the run.

Fork pull requests

pull_request_target plus untrusted checkout hands secrets to the PR author.

Detect

Find the value by prefix, not by pasting it

CommandWhat it finds
gh run view <id> --log > run.logA local copy you can grep without exposing the secret to a search engine.
grep -nE "AKIA|ghp_|github_pat_|sk_live_" run.logCommon credential prefixes in the run log.
grep -RIn "BEGIN .*PRIVATE KEY" artifact/Keys accidentally uploaded as artifacts.
gh api repos/<owner>/<repo>/actions/runs/<id>/artifactsEvery artifact attached to the run, and its retention.
Failure modes

Two free, three in the paid chapter

FM-01 · Masking misses a transformed value

The literal secret is masked; its base64 form is not. Rotate, then stop printing the request.

FM-03 · A fork PR runs with secrets

The privileged trigger plus untrusted checkout is the classic leak. Rotate and remove the trigger.

FM-02 · The artifact contains .env

Paid chapter: narrow upload paths, delete the artifact, rotate every value in it.

FM-04 · Cache crosses a trust boundary

Paid chapter: cache keys, fork restore, and what to rotate when the cache is poisoned.

FM-05 · Crash reporter dumps the environment

Paid chapter: redact the payload, disable debug in deployed builds.

Migration

Rotate, purge, prevent

StageWhat the paid chapter covers
RotateDependency order, revoking old keys, invalidating sessions.
PurgeLogs, artifacts, caches and the copies you cannot delete.
PreventRuntime injection, canary secret test, retention shorter than credential life.
Verification status
Reviewed 2026-11-16; no live exposure reproduced. Verified against the published sources listed below. The 7-day refund covers the gap.

Get the full runbook

Five failure modes, rotation order, purge limits and the prevention checklist.