A developer on my team committed AWS credentials to a public repo. We caught it in 9 minutes. The damage was already done.
I want to be specific about the timeline because it matters.
10:14 AM - Developer pushes a commit with an .env file that includes an AWS access key and secret. It was supposed to be in gitignore. It wasn't.
10:17 AM - Our automated secret scanner flags the commit and alerts the security channel.
10:19 AM - I see the alert and start the rotation procedure. Revoke the key, check CloudTrail for unauthorized usage.
10:23 AM - Key is revoked. Total exposure time: 9 minutes. We felt good about that response.
10:41 AM - CloudTrail shows that in those 9 minutes, someone spun up 38 EC2 instances in a region we don't use. All m5.xlarge. All running crypto mining software. The estimated cost for the 18 minutes they were running before we terminated them was $240. The billing for the API calls to launch them was another $80.
What I learned: bots scrape GitHub's public event stream in real time. Not minutes. Seconds. They're specifically looking for patterns that match AWS keys, Stripe keys, database connection strings. The moment your commit hits the public API, it's already being parsed.
9 minutes is fast. 9 minutes was not fast enough. The only response time that works is zero, which means the credential should never have been in the commit. Every other defense is a fallback.
We now run a pre-commit hook that blocks any push containing strings that match common secret patterns. It adds about 2 seconds to every commit. Nobody complains. The alternative costs $320 and a very uncomfortable meeting with the VP of engineering.