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 →
- Rotate the secret immediately at its source (DB password, API token, cloud key) and update the CI secret store.
- Delete the job log (GitHub Actions lets you delete a workflow run's logs).
- Check access logs for the secret's system for any unexpected use since it was printed.
- Find why masking failed. Common reasons: the secret was transformed (base64, URL-encoded, part of a JSON blob),
set -xechoed it, or a tool printed its config. - Prevent: register derived values for masking, avoid
set -xaround 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.
More on Security incidents
An AWS access key for a production IAM user was pushed to a public GitHub repo 20 minutes ago. What do you do in the first 30 minutes?AdvancedYou find pods in your cluster running a crypto miner. What do you do?AdvancedA critical CVE is announced in a library you use. You have 200 images across 40 repos. How do you find and patch everything fast?IntermediateGuardDuty reports an EC2 instance talking to a known command-and-control IP. What do you do?AdvancedYou discover an S3 bucket with customer data has been public for three months. What now?IntermediateAn engineer left the company three weeks ago and you find their access key was used yesterday. How do you respond and fix the process?Beginner