<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: affan</title>
    <description>The latest articles on DEV Community by affan (@affansaas).</description>
    <link>https://dev.to/affansaas</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3821155%2Fad1315d3-be0d-4461-b765-7d63851caca6.png</url>
      <title>DEV Community: affan</title>
      <link>https://dev.to/affansaas</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/affansaas"/>
    <language>en</language>
    <item>
      <title>Why Developers Are Bad at Securing Their Own API Keys</title>
      <dc:creator>affan</dc:creator>
      <pubDate>Sun, 15 Mar 2026 17:06:13 +0000</pubDate>
      <link>https://dev.to/affansaas/why-developers-are-bad-at-securing-their-own-api-keys-3bim</link>
      <guid>https://dev.to/affansaas/why-developers-are-bad-at-securing-their-own-api-keys-3bim</guid>
      <description>&lt;p&gt;We spend hours making our apps secure for users.&lt;/p&gt;

&lt;p&gt;HTTPS everywhere. Encrypted databases. Two factor auth. Rate limiting.&lt;/p&gt;

&lt;p&gt;Then we store our own API keys in a Notion doc shared with the whole team.&lt;/p&gt;

&lt;p&gt;The irony is real and it costs developers and companies thousands of dollars every year in breaches, leaked infrastructure, and unauthorized charges.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Happens
&lt;/h2&gt;

&lt;p&gt;When you're building fast, security shortcuts feel harmless. You tell yourself:&lt;/p&gt;

&lt;p&gt;"I'll fix this later"&lt;/p&gt;

&lt;p&gt;"It's just a dev key"&lt;/p&gt;

&lt;p&gt;"Nobody will find this Notion link"&lt;br&gt;
But later never comes. And dev keys often have the same permissions as &lt;br&gt;
prod keys. That's the real problem.&lt;br&gt;
The truth is most developers treat API keys as an afterthought. You're focused on shipping features, fixing bugs, hitting deadlines. Security feels like a separate concern you'll deal with eventually. But API keys are not an eventually problem. They're a right now problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Real Cost of a Leaked API Key
&lt;/h2&gt;

&lt;p&gt;Before we get into mistakes, let's talk about what actually happens when a key gets exposed.&lt;/p&gt;

&lt;p&gt;AWS keys found by bots on GitHub have resulted in bills of $50,000 or more within hours. These bots are automated and run 24/7 scanning every public commit for patterns that look like API keys.&lt;/p&gt;

&lt;p&gt;Stripe keys can be used to issue fraudulent refunds or pull customer data. OpenAI keys get used to run expensive prompts at your expense. Twilio keys get used to send spam at scale billed to your account.&lt;/p&gt;

&lt;p&gt;The damage is not just financial. If customer data is accessed through an exposed key you're looking at potential GDPR violations, angry users, and &lt;br&gt;
reputation damage that's hard to recover from.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Most Common Mistakes Developers Make
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;API keys in .env files committed to GitHub&lt;br&gt;
This is the single most common mistake. You set up your project, create a .env file, add your keys, and forget to add .env to your .gitignore. One push and it's public. Even if you delete the file in the next commit, the key is still in your git history forever.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keys shared over Slack and never rotated&lt;br&gt;
Your teammate needs the Stripe key. You paste it in Slack. Now that key lives in your Slack history accessible to anyone in that channel, any admin, and any third party app connected to your Slack workspace. And it never gets rotated so it stays exposed indefinitely.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Same key used across dev and production&lt;br&gt;
This one feels convenient until it isn't. If your dev environment gets breached, your production app is compromised too. Always use separate keys for each environment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No record of which keys exist or where they are&lt;br&gt;
Ask yourself right now: how many API keys does your project use? Where is each one stored? When was each one last rotated? Most developers can't answer these questions and that's a serious risk.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keys never rotated after a team member leaves&lt;br&gt;
When someone leaves your team they take their memory of where keys are stored. If they still have access to those keys anywhere, you have a security gap until you rotate everything.&lt;br&gt;
What Actually Helps&lt;br&gt;
Start treating your API keys like passwords. You would never store passwords in a Notion doc. You would never share passwords over Slack. You would never use the same password everywhere.&lt;br&gt;
Same rules apply to API keys.&lt;br&gt;
Use environment variables everywhere. No keys in code, no keys in config files that get committed. Every key lives in environment variables set at the deployment level.&lt;br&gt;
Add .env to .gitignore before you write a single key. Do this first thing when you set up a project, not after.&lt;br&gt;
Create separate keys for dev, staging, and production. Every environment should have its own set of keys with only the permissions that environment &lt;br&gt;
actually needs.&lt;br&gt;
Keep all your keys in one organized secure place. This is the part most developers skip and it's the most important habit to build. When you know exactly where every key lives you can rotate them quickly, audit access, and respond fast if something gets exposed.&lt;br&gt;
Rotate keys regularly and immediately after any team changes. Treat key rotation like changing passwords. Do it on a schedule and always do it when someone leaves.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I got tired of managing keys across scattered places so I built Keydock, a simple secure vault for all your API keys with zero knowledge encryption so even the server can't read your keys.&lt;br&gt;
Try it free at keydock.cloud&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>security</category>
      <category>devtools</category>
      <category>programming</category>
    </item>
    <item>
      <title>API Key Security Best Practices Every Developer Should Know.</title>
      <dc:creator>affan</dc:creator>
      <pubDate>Thu, 12 Mar 2026 23:09:55 +0000</pubDate>
      <link>https://dev.to/affansaas/api-key-security-best-practices-every-developer-should-know-5262</link>
      <guid>https://dev.to/affansaas/api-key-security-best-practices-every-developer-should-know-5262</guid>
      <description>&lt;p&gt;You probably have API keys scattered everywhere right now.&lt;br&gt;
.env files. Notion docs. Slack messages. Maybe even a sticky note &lt;br&gt;
somewhere.&lt;/p&gt;

&lt;p&gt;And honestly most developers do. It happens gradually. One project becomes two becomes ten and suddenly you have OpenAI keys, Stripe keys, AWS keys, Twilio keys, and GitHub tokens living in six different places with no clear ownership or rotation schedule.&lt;/p&gt;

&lt;h2&gt;
  
  
  One mistake can expose your entire app to the world. Here's what you should actually be doing and why each practice matters.
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Never Commit API Keys to GitHub&lt;br&gt;
This is the most common mistake and the one with the fastest consequences.&lt;br&gt;
GitHub has automated bots that scan every public commit for patterns that look like API keys. They run 24/7. By the time you notice you pushed a key, someone has already grabbed it. AWS keys have led to bills of $50,000 or more within a single day this way.&lt;br&gt;
How to fix it: Add .env to your .gitignore before you create it. Not after, before. Make this the first thing you do when setting up any project. Also consider using a tool like git-secrets that blocks commits containing credential patterns.&lt;br&gt;
Even if you're working on a private repo, get into this habit. Private repos can become public, get forked, or have their access compromised.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Never Hardcode Keys in Your Codebase&lt;br&gt;
This one seems obvious but happens constantly, especially when you're moving fast and just want to test something quickly.&lt;br&gt;
The problem is hardcoded keys end up in version history forever even after you delete them. Anyone with access to your repo can run git log and find the key. Anyone who ever cloned the repo has it locally.&lt;br&gt;
How to fix it: Always use environment variables. Every language and framework has a way to read from environment variables. There is no situation where hardcoding a key is the right move.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Separate Dev and Production Keys&lt;br&gt;
Your development keys and production keys should never be the same string.&lt;br&gt;
If your dev environment gets compromised, maybe through a dependency vulnerability or a misconfigured server, your production app stays completely safe if you're using separate keys. If they're the same key, one breach means everything is exposed.&lt;br&gt;
How to fix it: Create separate API keys for each environment in every service you use. Most services let you create multiple keys with different permission levels. Take 5 minutes to set this up properly from the start.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the Principle of Least Privilege&lt;br&gt;
Every API key should only have the permissions it actually needs. Nothing more.&lt;br&gt;
If your key only needs read access to a service, don't create it with write access too. If your key only needs to access one specific resource, don't give it access to everything.&lt;br&gt;
This limits the blast radius if a key gets exposed. An attacker with a read-only key can see data but can't delete it, write to it, or escalate their access.&lt;br&gt;
How to fix it: When creating API keys, go through the permission settings carefully. It takes an extra few minutes but dramatically reduces your risk exposure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Rotate Your Keys Regularly&lt;br&gt;
Keys are like passwords. The longer they stay unchanged the more risk you carry, even if you've never had a breach.&lt;br&gt;
You don't know who has seen your key over time. Old team members, contractors, third party tools, services you integrated and then stopped using. Regular rotation cleans all of that up.&lt;br&gt;
How to fix it: Rotate keys every 90 days as a baseline. Rotate immediately after any of these events: an employee or contractor leaves, a key gets accidentally exposed anywhere, you stop using an integration, or you suspect any kind of breach.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Know Where Every Key Lives&lt;br&gt;
If someone asked you right now to list every API key your project uses and where each one is stored, how long would it take you to answer?&lt;br&gt;
If it's more than a few seconds you have a visibility problem. You can't protect what you can't see. You can't rotate what you can't find. You can't revoke access to what you don't know exists.&lt;br&gt;
How to fix it: Keep all your keys in one organized secure place. A proper secrets manager gives you a single source of truth for every key, who has access to it, when it was last rotated, and which service it belongs to.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Have a Response Plan for Exposed Keys&lt;br&gt;
Most developers wait until a key gets exposed to figure out what to do. By then it's too late.&lt;br&gt;
Know in advance: which keys are most critical, how to revoke and regenerate each one, and who needs to be notified if a key is compromised.&lt;br&gt;
How to fix it: Take 30 minutes to document your key rotation process for each service you use. Store that documentation somewhere accessible so you can act fast when you need to.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I learned most of this the hard way across multiple projects with dozens of API keys scattered everywhere. That's why I built Keydock, a simple secure vault to store and manage all your API keys with zero knowledge AES-256-GCM encryption.&lt;/p&gt;

&lt;p&gt;Try it free at keydock.cloud&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>security</category>
      <category>devtools</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
