A secret was printed in plain text in a CI job log. What do you do?

BeginnerScenarioSecurity incidents
Answer

Situation read → Anyone with read access to the repo or CI may have seen it. Rotate it; deleting the log isn't enough.

What I'd do →

  1. Rotate the secret immediately at its source (DB password, API token, cloud key) and update the CI secret store.
  2. Delete the job log (GitHub Actions lets you delete a workflow run's logs).
  3. Check access logs for the secret's system for any unexpected use since it was printed.
  4. Find why masking failed. Common reasons: the secret was transformed (base64, URL-encoded, part of a JSON blob), set -x echoed it, or a tool printed its config.
  5. Prevent: register derived values for masking, avoid set -x around secrets, and prefer OIDC so there's no secret to print.
echo "::add-mask::$(echo -n "$TOKEN" | base64)"

Why → Masking only matches the exact string; any transformation slips through.

Interview tip → Say "rotate first, then clean up"; deleting the log first is the wrong order.

All Real-World Interview questions Roadmap: Interview readiness

More on Security incidents