<?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: Selixe</title>
    <description>The latest articles on DEV Community by Selixe (@selixe).</description>
    <link>https://dev.to/selixe</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%2F3827801%2Fd79f14d9-a4b5-4a6e-b5a5-e49781bebfda.jpg</url>
      <title>DEV Community: Selixe</title>
      <link>https://dev.to/selixe</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/selixe"/>
    <language>en</language>
    <item>
      <title>Why your .env files are a security risk (and what to do instead)</title>
      <dc:creator>Selixe</dc:creator>
      <pubDate>Mon, 16 Mar 2026 17:32:48 +0000</pubDate>
      <link>https://dev.to/selixe/why-your-env-files-are-a-security-risk-and-what-to-do-instead-4h9o</link>
      <guid>https://dev.to/selixe/why-your-env-files-are-a-security-risk-and-what-to-do-instead-4h9o</guid>
      <description>&lt;h2&gt;
  
  
  Why your .env files are a security risk (and what to do instead)
&lt;/h2&gt;

&lt;p&gt;If you've been developing for more than a year, you've probably done at least one of these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Committed a &lt;code&gt;.env&lt;/code&gt; file to git by accident&lt;/li&gt;
&lt;li&gt;Sent a teammate your database URL over Slack&lt;/li&gt;
&lt;li&gt;Had a &lt;code&gt;.env.production&lt;/code&gt; file sitting on your laptop with live API keys&lt;/li&gt;
&lt;li&gt;Lost track of which machine has the "real" values&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of these feel like a big deal in the moment. Until they are.&lt;/p&gt;

&lt;h2&gt;
  
  
  The actual problem with .env files
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;.env&lt;/code&gt; file pattern works fine when you're the only developer and you never &lt;br&gt;
make mistakes. In practice that means it works fine for about five minutes.&lt;/p&gt;

&lt;p&gt;The real problems start when:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You have a team.&lt;/strong&gt; Now you need to share secrets somehow. Slack, email, Notion, &lt;br&gt;
a shared password manager — all of these are worse than you think. Someone leaves &lt;br&gt;
the company and you're not sure what they have. A Slack message with your Stripe &lt;br&gt;
key is sitting in a searchable archive forever.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You have multiple environments.&lt;/strong&gt; Now you have &lt;code&gt;.env.development&lt;/code&gt;, &lt;code&gt;.env.staging&lt;/code&gt;, &lt;br&gt;
&lt;code&gt;.env.production&lt;/code&gt;, and a 50% chance that at least one of them is out of date on &lt;br&gt;
at least one machine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You have multiple projects.&lt;/strong&gt; Now you have a folder of .env files somewhere and &lt;br&gt;
you're manually copying values between them and praying nothing drifts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You work across machines.&lt;/strong&gt; The values on your laptop and your desktop are &lt;br&gt;
different and you don't remember which one is right.&lt;/p&gt;
&lt;h2&gt;
  
  
  The git problem
&lt;/h2&gt;

&lt;p&gt;The most common disaster is the accidental commit. You add a new variable, forget &lt;br&gt;
to check &lt;code&gt;.gitignore&lt;/code&gt;, and push. Even if you catch it and remove it in the next &lt;br&gt;
commit, the key is in your git history forever. Anyone who clones that repo has it.&lt;/p&gt;

&lt;p&gt;GitHub's secret scanning catches some of this, but only for known patterns like &lt;br&gt;
AWS keys and Stripe keys. Your custom internal secrets are invisible to it.&lt;/p&gt;

&lt;p&gt;The standard advice is "just add .env to your .gitignore" but that's not enough. &lt;br&gt;
You also need to make sure every developer on your team has done the same, on every &lt;br&gt;
project, every time. One person forgets and you have a breach.&lt;/p&gt;
&lt;h2&gt;
  
  
  What actually fixes this
&lt;/h2&gt;

&lt;p&gt;The right solution has a few properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Secrets never live on disk in plaintext&lt;/li&gt;
&lt;li&gt;Secrets are centralized so there's one source of truth&lt;/li&gt;
&lt;li&gt;Access is controlled so people only see what they need&lt;/li&gt;
&lt;li&gt;Changes are audited so you know what changed and when&lt;/li&gt;
&lt;li&gt;It works with your existing workflow so people actually use it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are enterprise solutions for this — HashiCorp Vault, AWS Secrets Manager, &lt;br&gt;
Doppler. They're good if you're running infrastructure at scale. They're overkill &lt;br&gt;
if you're a small team trying to ship software without leaking your database &lt;br&gt;
credentials.&lt;/p&gt;
&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;p&gt;I got frustrated with this problem enough that I built &lt;br&gt;
&lt;a href="https://envmaster.dev" rel="noopener noreferrer"&gt;EnvMaster&lt;/a&gt; — a CLI tool that stores your variables &lt;br&gt;
encrypted in the cloud and injects them directly into any process.&lt;/p&gt;

&lt;p&gt;The workflow looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;envmaster project my-api
envmaster environment production
envmaster run &lt;span class="nt"&gt;--&lt;/span&gt; node server.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. No .env file on disk, no dotenv package in your project, no manual &lt;br&gt;
exports. The right variables are injected into the process and exist only in &lt;br&gt;
memory for the duration of the request.&lt;/p&gt;

&lt;p&gt;Everything is encrypted at rest with AES-256-GCM before it hits the database. &lt;br&gt;
Keys are stored separately from the data. Your plaintext values never persist &lt;br&gt;
to disk on our end.&lt;/p&gt;

&lt;p&gt;For teams it supports per-project roles so frontend developers never accidentally &lt;br&gt;
see backend secrets, and a full audit log so when something breaks in production &lt;br&gt;
you know instantly whether a variable change was the cause.&lt;/p&gt;

&lt;p&gt;There's a free tier and a Pro trial on every new account. No credit card required &lt;br&gt;
to start.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bottom line
&lt;/h2&gt;

&lt;p&gt;.env files are a fine pattern for a solo developer on a single project. The moment &lt;br&gt;
you add a second person, a second environment, or a second machine, the cracks &lt;br&gt;
start showing.&lt;/p&gt;

&lt;p&gt;The fix isn't complicated — centralize your secrets, encrypt them, control who can &lt;br&gt;
see them, and inject them at runtime. Whether you use EnvMaster or something else, &lt;br&gt;
the .env file era is worth leaving behind.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Built EnvMaster to solve this exact problem. Would love feedback from anyone &lt;br&gt;
who's dealt with the same mess.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>git</category>
      <category>security</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
