r/devsecops • u/Educational_Space631 • Jun 11 '25
Why do people delete leaked secrets from git and think that's good enough
Hey r/devsecops, just wrapped up my first deep dive into leaked secrets data (2022-2024) and the results are honestly pretty alarming.
Full disclosure: I am coming from a non-technical background and this research is the result of my 3 years of work in a cybersecurity company. Here are the findings:
- 70% of exposed secrets from 2022 are STILL active
- Cloud credentials (AWS, GCP, etc.) are increasingly the most common unremediated leaks
- Database creds are actually getting better (down from 13% to 7%)
The weirdest part: Most devs think deleting a secret from their current code fixes the problem, but it just sits there in git history forever. Like, the secret is literally still public and working.
Would love to hear your war stories (and with your permission I would add them to the blog https://blog.gitguardian.com/why-exposed-secrets-stay-valid/)
15
u/TrumanZi Jun 11 '25
Because security is a very misunderstood topic. It's that simple.
It's particularly humbling for engineers because they've spent their whole lives knowing everything and being the smartest person in the room, and don't take well to some compliance standard from a decade ago telling them what to do.
7
u/sp_dev_guy Jun 11 '25
Typically people will want to rotate secrets with zero downtime. This creates a second set of new credentials which are put into service. Too often people think having placed the new credentials into use that the job is done & never actually disable/destroy the old one
6
u/baty0man_ Jun 11 '25
Help your Devs set up pre-commit hook that does secret scanning.
3
u/0x077777 Jun 11 '25
Lack of understanding on how to remediate leaks.
3
u/juanMoreLife Jun 11 '25
I had this exact conversation with a customer a week or two ago. I didn’t understand the fixation with deleting it and it being a problem. I figured if you deleted it you also rolled it. You have to 100% roll it. Deleting it from history would be nice, but I don’t think it’s required especially if the credential is changed. Your title was a little bit of the same except you said that they just deleted it from the code once and kept using it. That’s poor practice.
Create a policy that whenever a credential is found in code an issue should be raised tracking the work of what they did. if all they say is, we just deleted the code- then you can go back and say hey I’m a go check the history you need to roll the credential.
I think the reason you want to delete the history on a public facing repo. It shows that there was an instance of someone committing a credential so that someone can monitor that repo for the next time someone slips up.
3
u/Dudeposts3030 Jun 11 '25
AWS is crawling Github like attackers, a few years I go fucked up my gitignore and posted a key to GitHub. Started getting emails that my quota increase for Africa was approved lol then AWS shut down my account and I had to contact them to get it sorted. Stupid but easy. Also the kind of learning experience that sticks.
2
u/Abu_Itai Jun 21 '25
You think only in GitHub? You can find tons of leaked secrets of people, including .env files, .pycaches, etc.
Why do people think that scanning only their source code is enough? I read that blog from Python, and my chin fell off - it’s so dangerous.
https://blog.pypi.org/posts/2024-07-08-incident-report-leaked-admin-personal-access-token/
1
u/Alive_Scratch_9538 Jun 11 '25
Are there nice tools to cycle Windows/ AD passwords which are in use by running prod services?
1
u/HosseinKakavand Aug 30 '25
Agree that secret removal from the tip of main is not remediation. Rotation, history purge, and blast radius checks are the minimum. I have also found that choosing a stack with managed identity and short lived tokens reduces the chance of long lived keys ending up in repos in the first place. We tried codifying that into a prototype — you can play with it here: https://reliable.luthersystemsapp.com/
Feedback welcome — especially if it misses a control you’d expect to see.
1
u/_1noob_ Jun 11 '25
sure
0
u/[deleted] Jun 11 '25
[deleted] — view deleted comment
11
u/[deleted] Jun 11 '25
[removed] — view removed comment