Lesson 7 of 13 · 15m
Source Code and Secret Leaks
GitHub code search, trufflehog, and gitleaks turn commit history into infrastructure disclosure — and found keys get reported, never used.
Developers leak their infrastructure into public code long before any breach makes the news. API keys in commit history, .env files pushed to public repos, CI logs with bearer tokens, Docker image layers containing private certificates, gists pasted to share a config with a coworker. GitHub is the highest-density OSINT source on the internet for exactly one reason: the people leaking things there don't think of it as publishing.
GitHub as a sensor
The current code search takes qualifiers worth memorizing. org:target path:.env finds environment files committed inside an organization's repos. org:target content:"AKIA" hunts AWS access key IDs — the AKIA prefix is structurally enforced by AWS, so it almost never false-positives. path:wp-config.php, path:id_rsa, content:"BEGIN OPENSSH PRIVATE KEY" each surface a different failure mode. Gists search separately and leak at a higher rate, because people treat gists as ephemeral — they are not.
The same search run against a person's repos rather than an org's is how handles pivot into infrastructure: a leaked DATABASE_URL in a side project's commit names the hosting provider, the database name, and sometimes the internal hostname convention.
History never dies
Deleting a file in a new commit removes it from the file listing, not the repository. The blob persists in history, in forks that cloned it before the deletion, in GitHub's public event data archived to GH Archive on BigQuery, and in dangling objects reachable by commit SHA long after the UI forgets them. The 2019-era lesson everyone cites — keys deleted in commit n+1 are readable at commit n — is still true today.
Two scanners do the work for you. gitleaks detect --source . --verbose walks full history for ~140 known secret formats plus entropy outliers. trufflehog git file:///path/to/repo does the same and goes a step further — it can verify whether discovered credentials are still live against their issuers. Run both; their rule sets differ enough to find different things.
This already happened, repeatedly
Uber, 2016. Attackers found AWS credentials in a private GitHub repository, used them against S3, and pulled records on 57 million riders and drivers. Uber paid $100,000 framed as a bug bounty, had the attackers sign NDAs, and disclosed nothing — until it came out. Former security chief Joe Sullivan was convicted of obstruction of justice and covering up a felony in October 2022. The credential was leaked; the cover-up was the crime.
Toyota, September 2022. A source repository on GitHub containing an access key to a customer-data source was left public for nearly five years — December 2017 to September 2022. Roughly 296,000 customers' data sat reachable through a repo anyone could read.
These are not edge cases. Credential-in-repo is the single most common real-world leak class, and it is visible to anyone who searches.
What you do with a found key
Nothing that authenticates. The instinct to "check if it's live" by calling the AWS API is using the credential — unauthorized access regardless of how public the leak was, and your IP in the target's CloudTrail. The correct workflow:
- Record the artifact: repo URL, file path, commit SHA, and the exposure window from commit dates.
- Fork or archive the evidence via your normal ledger process — Wayback captures the commit page;
git clonepreserves the history. - Report through the target's published disclosure channel —
security.txt(RFC 9116) at/.well-known/security.txtfirst, then their security contact.
Finding a live credential makes you a witness, not a user. The same pipeline pointed inward — trufflehog and gitleaks in your own CI, pre-commit hooks catching keys before they land — is the control this technique argues for.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Healthcare Ransomware: Why Hospitals Can't Patch Fast Enough
The criminals behind the attack claim to have shared 400GB of patient data. The NHS stated it is working swiftly to confirm the validity of these files. The ransomware attack on the UK's National Health Service (NHS) continues to disrupt health services in London, with a significant amount of…
The 23andMe Breach Was Credential Stuffing
The joint investigation will thoroughly examine the extent of the data exposure in the massive breach and determine if 23andMe had sufficient safeguards in place to protect this sensitive information. UK and Canadian authorities have announced a collaborative investigation into the DNA testing…
How Fake Law-Enforcement Requests Steal Your Data
The hackers– who may have links to cybercrime group Lapsus$ – are said to have compromised accounts to make emergency data requests on people's accounts that are using Apple and Facebook services. Apple and Facebook parent company Meta provided user data to cybercriminals last year who…
LAPSUS$: How Teenagers Breached Microsoft and Okta
Claire Tills, senior research engineer at Tenable, describes the methods of the hacking group Lapsus$ as bold, illogical and poorly thought out. The criminals attacked renowned companies such as Microsoft, Samsung, Nvidia, Vodafone, Ubisoft and Okta. They stole data and sometimes used ransomware…