Hacking News All articles
Investigation

Your Code Is Leaking: The Silent API Key Crisis Hiding in Plain Sight on GitHub

Hacking News
Your Code Is Leaking: The Silent API Key Crisis Hiding in Plain Sight on GitHub

Photo: developer coding laptop github security breach api keys, via www.armorcode.com

Imagine leaving your house keys under the doormat and then posting your home address on a billboard. That's essentially what thousands of developers across the US are doing every single day — and most of them have no idea it's happening.

Public GitHub repositories have quietly become one of the richest hunting grounds on the internet for attackers looking for a cheap, low-effort way into corporate infrastructure. API keys, OAuth tokens, database credentials, AWS access keys — they're all out there, committed to public repos by developers who either didn't know better or just moved too fast to care. The scary part? Automated tools are scanning for them 24 hours a day.

How Bad Is the Problem, Really?

Let's not sugarcoat it: the scale is staggering. Research from GitGuardian found that over 10 million secrets were exposed in public GitHub repositories in a single year — a number that has grown consistently year over year. That includes credentials tied to major cloud providers, payment processors, internal APIs, and enterprise SaaS platforms.

And it's not just small startups or solo developers making rookie mistakes. Fortune 500 companies, government contractors, and well-funded tech firms have all had credentials surface in public code. Sometimes it's a new hire who didn't realize their personal project was public. Sometimes it's a CI/CD pipeline misconfiguration. Sometimes it's just a developer in a hurry who hardcoded a token to "test something real quick" and forgot to clean it up before pushing.

The git history makes it worse. Even if someone catches the mistake and deletes the file, the credential can still live in the commit history — accessible to anyone who knows where to look.

The Attacker's Playbook

Here's how the exploitation pipeline actually works, and it moves fast.

Attackers — ranging from sophisticated nation-state groups to teenage script kiddies — use automated tools like truffleHog, gitleaks, and custom-built scrapers to continuously monitor GitHub for newly pushed commits containing patterns that match API key formats. AWS keys follow a predictable structure. Stripe keys start with sk_live_. Twilio auth tokens have their own fingerprint. These patterns are easy to regex-match at scale.

Once a live credential is identified, some tooling can automatically validate it — firing off a test API call to confirm the key is active — within minutes of the commit landing. From there, the attacker has options: they can drain cloud resources to mine crypto, exfiltrate customer data, pivot deeper into internal systems, or simply sell the verified credential on a dark web marketplace.

In documented cases involving exposed AWS keys, attackers spun up fleets of GPU instances for crypto mining within hours of discovery, leaving the victim with five- and six-figure cloud bills. Other incidents have led to full-scale data breaches where customer PII ended up for sale on forums.

Why Developers Keep Making This Mistake

It'd be easy to just blame developers, but that misses the real issue. The tooling and culture around secret management hasn't kept pace with how fast teams ship code.

Most developers are under pressure to move quickly. Environment variables and secrets managers add friction to local development workflows. Hardcoding a key feels like a "temporary" solution that somehow becomes permanent. And in large organizations, there's often no automated guardrail preventing a secret from making it into a commit in the first place.

GitHub itself has rolled out a native Secret Scanning feature that alerts repository owners when known credential formats are detected in public repos. Several major providers — AWS, Google, GitHub itself — participate in a partner program that automatically revokes certain token types when they're detected. But the program only covers a fraction of the credential formats in the wild, and it doesn't help with internal or proprietary API key formats.

What Security Teams Should Be Doing Right Now

If you're on a security team and you haven't audited your organization's GitHub presence recently, here's your wake-up call. These are the moves that actually matter:

Scan your entire git history, not just current code. Tools like truffleHog and gitleaks can recursively scan commit history across all branches. Run them against every repo your org owns — including archived ones. You will find things. It's not a question of if.

Set up pre-commit hooks. Enforce secret scanning at the developer's machine before code ever reaches a remote repository. Tools like detect-secrets from Yelp can be configured as a pre-commit check and integrated into your standard dev environment setup.

Implement secrets management infrastructure. AWS Secrets Manager, HashiCorp Vault, and Azure Key Vault exist for a reason. If your team is still hardcoding credentials in config files or environment variable files that get committed, it's time to fix the underlying workflow, not just play whack-a-mole with individual leaks.

Audit your GitHub organization settings. Make sure you know which repos are public versus private. Developers sometimes flip a private repo to public temporarily and forget to flip it back. Regular audits of repo visibility settings are a basic hygiene step that gets overlooked constantly.

Rotate first, investigate second. If you find an exposed credential, your first move is to revoke and rotate it immediately — before you spend time figuring out whether it was actually exploited. You can investigate the blast radius after the bleeding stops.

Monitor for anomalous API usage. Even if you rotate a key quickly, it's worth checking your API logs for unusual activity in the window the credential was exposed. Look for calls from unexpected IP ranges, unusual request volumes, or API methods your application doesn't normally use.

The Bigger Picture

This isn't a problem that's going away on its own. As organizations push more code to more repositories and development teams grow, the attack surface expands. The tools attackers use to find these credentials are getting faster and more sophisticated. And the value of a valid cloud credential — with potential access to production databases, customer data, and billing accounts — is only going up.

GitHub has made progress, and the ecosystem of developer security tooling has matured considerably in the last few years. But adoption is still uneven, and plenty of organizations are operating with no guardrails in place.

The credentials are out there right now. Some of them belong to companies that don't know they're compromised yet. The question for every security team is whether they're going to find their own exposure first — or wait for an attacker to find it for them.

All Articles

Related Articles

Ransomware Went Corporate: Inside the Underground Franchise Model Bleeding US Businesses Dry

Ransomware Went Corporate: Inside the Underground Franchise Model Bleeding US Businesses Dry