Our Recommended VPNs
Chosen after real-world testing across speed, privacy, and streaming. Each ranking is independent — we buy every VPN at retail and test it ourselves.
Fastest speeds, audited no-logs, 6000+ servers
Unlimited devices, CleanWeb blocker, 100+ countries
Swiss privacy laws, open-source, free tier
Lifetime plans, 10 devices, ad blocker
We earn a commission when you click “Get” buttons, at no extra cost to you. Read our affiliate disclosure
The $20 Billion Problem
Leaked API keys and secrets are one of the most common and costly security failures. GitGuardian scans found over 10 million secrets exposed in public GitHub repositories in 2025. A single leaked AWS key can result in thousands of dollars in unauthorized charges within hours.
If you're a developer working remotely, your API keys are even more at risk — you're working on shared networks, personal devices, and multiple machines.
The Cardinal Rules
- Never commit secrets to git. Not even "temporarily"
- Never hard-code secrets in source code. Not even for testing
- Never share secrets via Slack, email, or chat. Use a secrets manager
- Always use environment variables for configuration
- Rotate keys immediately if you suspect exposure
Setting Up .gitignore Correctly
Before you write any code, ensure your .gitignore blocks all secret files:
# Environment files
.env
.env.local
.env.*.local
.env.production
.env.staging
# Cloud provider credentials
*.pem
*.key
credentials.json
serviceAccountKey.json
# IDE-specific
.idea/
.vscode/settings.json
Using Environment Variables
Instead of:
// NEVER DO THIS
const API_KEY = "sk-abc123...";
Do this:
// CORRECT
const API_KEY = process.env.API_KEY;
And store the actual value in .env:
API_KEY=sk-abc123...
Secrets Managers for Teams
For teams, environment variables alone aren't enough. Use a secrets manager:
| Tool | Type | Best For | Price | |------|------|----------|-------| | GitHub Secrets | Built-in | GitHub Actions CI/CD | Free | | Doppler | SaaS | Multi-environment sync | Free tier | | HashiCorp Vault | Self-hosted/Cloud | Enterprise | Free (OSS) | | AWS Secrets Manager | Cloud | AWS workloads | $0.40/secret/month | | 1Password Secrets Automation | SaaS | Teams using 1Password | Included in business plan |
GitHub Secret Scanning
GitHub automatically scans for known secret patterns (API keys, tokens, passwords) in your repositories. Enable push protection to block commits containing secrets:
- Repository Settings > Security > Code security and analysis
- Enable "Secret scanning"
- Enable "Push protection" — this prevents commits with detected secrets from being pushed
What to Do If a Secret Is Leaked
- Revoke the key immediately — don't just remove it from the code
- Generate a new key from the provider's dashboard
- Update all services using the old key
- Check for unauthorized usage in the provider's logs
- Clean git history using
git filter-repo(not just removing from current commit) - Audit access logs for suspicious activity during the exposure window
Remember: removing a secret from the latest commit does NOT remove it from git history. The old commit still contains it.
How We Verified
Practices based on OWASP API Security Top 10, GitHub security documentation, and GitGuardian research. Tools verified with current versions. April 2026.
Continue learning
Related Guides
How to Share Passwords Safely: Stop Using Slack and Email (2026)
Secure methods for sharing passwords, API keys, and credentials with teammates. Password manager sharing, Bitwarden Send, and one-time links.
Device Encryption Guide: Protect Your Data If Your Laptop Is Lost (2026)
How to enable full-disk encryption on Windows, Mac, iOS, and Android. Your data stays secure even if your device is stolen.
Endpoint Security for Remote Workers: Beyond Antivirus (2026)
Your devices are endpoints in the security chain. Modern endpoint protection goes beyond antivirus — here's what you need in 2026.
Was this guide helpful?
What's next
Keep exploring
Sources & Citations
- 1GitHub: Secret scanning — docs.github.com
- 2OWASP: API Security Top 10
- 3GitGuardian: State of Secrets Sprawl 2026

