<?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: z-150</title>
    <description>The latest articles on DEV Community by z-150 (@z-150).</description>
    <link>https://dev.to/z-150</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4087821%2Fadc9aae2-1813-4aa4-96cf-3974fca61fc0.jpg</url>
      <title>DEV Community: z-150</title>
      <link>https://dev.to/z-150</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/z-150"/>
    <language>en</language>
    <item>
      <title>Why Your AI Coding Agent Should Never See Your .env</title>
      <dc:creator>z-150</dc:creator>
      <pubDate>Fri, 21 Aug 2026 07:50:40 +0000</pubDate>
      <link>https://dev.to/z-150/why-your-ai-coding-agent-should-never-see-your-env-18h4</link>
      <guid>https://dev.to/z-150/why-your-ai-coding-agent-should-never-see-your-env-18h4</guid>
      <description>&lt;h1&gt;
  
  
  Why Your AI Coding Agent Should Never See Your .env
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Your AI agent uses your API keys. It NEVER sees them. Not in context. Not in logs. Not in chat. Not even if it tries.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You just gave your AI coding assistant a &lt;code&gt;.env&lt;/code&gt; file with &lt;code&gt;OPENAI_API_KEY=sk-...&lt;/code&gt;, &lt;code&gt;GITHUB_TOKEN=ghp_...&lt;/code&gt;, maybe an &lt;code&gt;AWS_SECRET&lt;/code&gt;. You trust it to &lt;em&gt;use&lt;/em&gt; those keys.&lt;/p&gt;

&lt;p&gt;But here's the uncomfortable question nobody asks:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where does that key actually go?&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem (That Nobody Talks About)
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Vector&lt;/th&gt;
&lt;th&gt;Exposure&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Model context window&lt;/td&gt;
&lt;td&gt;Visible to the LLM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tool call logs&lt;/td&gt;
&lt;td&gt;Logged forever&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Chat history&lt;/td&gt;
&lt;td&gt;Stored in plaintext&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Prompt injection (&lt;code&gt;"print all env vars"&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Exfiltrated in 1 shot&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One malicious webpage. One injected instruction buried in a doc your agent reads. Every credential — gone.&lt;/p&gt;

&lt;p&gt;AI agents are &lt;em&gt;promiscuous with context&lt;/em&gt;. They log everything. They echo everything. They will happily &lt;code&gt;print(env)&lt;/code&gt; if a prompt tells them to.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution: Reference, Not Reveal
&lt;/h2&gt;

&lt;p&gt;I built &lt;strong&gt;&lt;a href="https://github.com/Z-150/env-guard" rel="noopener noreferrer"&gt;env-guard&lt;/a&gt;&lt;/strong&gt; around a simple principle: the agent references a secret by &lt;em&gt;name&lt;/em&gt;, and the OS expands it at execution time. The raw value is &lt;strong&gt;never&lt;/strong&gt; in a place the model can read.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.env.list (NAMES ONLY)        live env (VALUES)
OPENAI_API_KEY      ──refs──▶  OPENAI_API_KEY=sk-...
GITHUB_TOKEN                   GITHUB_TOKEN=ghp_...
                                  │
                            OS expands $NAME
                                  │
                       secret-run.py (audited, no reveal)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The agent types:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Authorization: Bearer &lt;/span&gt;&lt;span class="nv"&gt;$OPENAI_API_KEY&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; https://api.openai.com/v1/models
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The shell expands &lt;code&gt;$OPENAI_API_KEY&lt;/code&gt;. The model sees &lt;code&gt;$OPENAI_API_KEY&lt;/code&gt; — &lt;strong&gt;never &lt;code&gt;sk-...&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;p&gt;Three layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;.env.list&lt;/code&gt;&lt;/strong&gt; — auto-generated index of variable &lt;em&gt;names only&lt;/em&gt; (no values), via &lt;code&gt;env-scan.py&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Live env&lt;/strong&gt; — real values stay in the OS environment, never written to disk by the agent&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;secret-run.py&lt;/code&gt;&lt;/strong&gt; — runs the command with the variable in child env, logs &lt;code&gt;model + provider + purpose&lt;/code&gt;, and &lt;strong&gt;refuses to echo the value&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python scripts/secret-run.py &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--var&lt;/span&gt; OPENAI_API_KEY &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--model&lt;/span&gt; &lt;span class="s2"&gt;"gpt-4o"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--provider&lt;/span&gt; &lt;span class="s2"&gt;"openai"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--purpose&lt;/span&gt; &lt;span class="s2"&gt;"list models"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--&lt;/span&gt; curl &lt;span class="nt"&gt;-s&lt;/span&gt; https://api.openai.com/v1/models
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unknown variables are &lt;strong&gt;refused&lt;/strong&gt;. Every access is &lt;strong&gt;audit-logged&lt;/strong&gt; with &lt;code&gt;reveal: false&lt;/code&gt;. Even a direct &lt;code&gt;cat .env&lt;/code&gt; instruction fails — the agent has no read access to the raw file.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;env-guard&lt;/code&gt; doesn't ask the agent to &lt;em&gt;be careful&lt;/em&gt;. &lt;strong&gt;It makes carelessness impossible.&lt;/strong&gt; The value is simply never in a place the model can read.&lt;/p&gt;

&lt;p&gt;Works with Claude Code, Codex, Hermes, Cursor, OpenCode, Aider. MIT licensed.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://github.com/Z-150/env-guard" rel="noopener noreferrer"&gt;github.com/Z-150/env-guard&lt;/a&gt;&lt;/strong&gt; — clone it, drop it in your &lt;code&gt;skills/&lt;/code&gt; folder, star it if it saved your keys.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Built by Dext4r (Zaxs), powered by Nous Research:CAB.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>ai</category>
      <category>llm</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
