Jul 01, 2024
Get featured on Geeklore.io
Geeklore is in very early stages of development. If you want to help us grow, consider letting us sponsor you by featuring your tool / platform / company here instead of this text. 😊
Hey everyone! It's Saad Fazal here, and today I want to talk about something that I've been noticing more and more on GitHub: the alarming lack of security awareness among some developers. As much as I love the collaborative spirit of open-source, it's crucial that we all take security seriously. I was messing around on GitHub, just doing some casual searches, and guess what I found? Yep, OpenAI API keys scattered around in public repos like confetti at a New Year's party. If you're thinking, "Oh no, not me!"—think again. Here's the search query I used:
(path:*.xml OR path:*.json OR path:*.properties OR path:*.sql OR path:*.txt OR path:*.log OR path:*.tmp OR path:*.backup OR path:*.bak OR path:*.enc OR path:*.yml OR path:*.yaml OR path:*.toml OR path:*.ini OR path:*.config OR path:*.conf OR path:*.cfg OR path:*.env OR path:*.envrc OR path:*.prod OR path:*.secret OR path:*.private OR path:*.key) AND (access_key OR secret_key OR access_token OR api_key OR apikey OR api_secret OR apiSecret OR app_secret OR application_key OR app_key OR appkey OR auth_token OR authsecret) AND ("sk-" AND (openai OR gpt))
Exposing your API keys is like leaving your wallet on the sidewalk. Sure, someone might just ignore it, but chances are, someone’s going to pick it up and go on a spending spree with your hard-earned cash. And trust me, those OpenAI bills can rack up fast!
So, I was once testing the newly released OpenAI Vision using the API, and in a classic "whoops" moment, I accidentally put my Python code in a loop. It kept taking screenshots of my desktop and sending POST requests to the OpenAI Vision API. Within just 5 minutes, I was charged $93. Talk about an expensive lesson in debugging!
Leaving your keys out in the open can lead to unauthorized access to your systems. It’s not just about the money—you could be giving hackers the keys to your kingdom. They can wreak havoc, steal data, or worse.
Imagine a potential employer or client stumbling upon your exposed keys. Awkward, right? It doesn’t exactly scream “I’m a responsible developer.” Keeping your credentials secure is a must for maintaining your professional image.
Store your keys in environment variables instead of hardcoding them in your files. This keeps them out of your source code and reduces the risk of accidental exposure.
Make sure your .gitignore
file is properly configured to exclude sensitive files like .env
. This prevents them from being committed to your repository.
Use secrets management tools provided by cloud providers or services like AWS Secrets Manager, Azure Key Vault, or HashiCorp Vault. These tools help you manage and access your secrets securely.
Regularly audit your repositories for accidental exposures. Use tools like TruffleHog, GitGuardian, or similar to scan your codebase for sensitive information.
Just because a repository is private doesn't mean it's safe to store your credentials there. If your account gets compromised, so do all your private repos. Treat them with the same level of security as you would a public repo.
Let's all take a moment to reflect on our security practices. It's easy to overlook these details, but the implications can be severe. By taking proactive steps, we can protect our projects, our finances, and our reputations.
I hope this blog post helps raise awareness about the importance of security on GitHub. Let's work together to make our projects safer and more secure. If you have any thoughts or additional tips, feel free to share them! Stay secure, stay vigilant, and happy coding!
Latest Comments
Security is often disregarded by companies... and the reason is that companies don't think they would ever be the target. And if they *are* the target... well, they can always pay the price AFTER it happens. Business only care about stats, graphs, cost optimization, etc... good post. Also - there are mass bots crawling public GIT repos and scan for exposed API keys.
Absolutely! I just provided an example with the openai_api_key, but there are more secrets involved, such as Google and YouTube credentials, cookies files for accounts like Twitter, etc. I also made some mistakes, but I got the chance to discuss them. I didn't know writing a blog could be this fun. 😂
I am glad you are enjoying it :))