I lost $93 while testing the newly released Open AI vision
Saad Fazal
Posted on July 2, 2024
Introduction
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))
Why This is a Big Deal
Financial Risks
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!
My Funny Mishap with OpenAI Vision
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!
Security Breaches
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.
Professional Reputation
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.
Steps to Secure Your API Keys
Use Environment Variables
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.
Git Ignore
Make sure your .gitignore
file is properly configured to exclude sensitive files like .env
. This prevents them from being committed to your repository.
Secrets Management
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.
Regular Audits
Regularly audit your repositories for accidental exposures. Use tools like TruffleHog, GitGuardian, or similar to scan your codebase for sensitive information.
Private Repos Aren't Safe Either
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.
Conclusion
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!
Posted on July 2, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.