<?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: Utku Gulbardak</title>
    <description>The latest articles on DEV Community by Utku Gulbardak (@uttywotty).</description>
    <link>https://dev.to/uttywotty</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%2F3867966%2Faf6ad068-3c10-4748-8732-98dfe8b69840.jpg</url>
      <title>DEV Community: Utku Gulbardak</title>
      <link>https://dev.to/uttywotty</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/uttywotty"/>
    <language>en</language>
    <item>
      <title>I built security guardrails for Claude Code after it almost leaked my credentials.</title>
      <dc:creator>Utku Gulbardak</dc:creator>
      <pubDate>Wed, 08 Apr 2026 14:15:15 +0000</pubDate>
      <link>https://dev.to/uttywotty/i-built-security-guardrails-for-claude-code-after-it-almost-leaked-my-credentials-2md8</link>
      <guid>https://dev.to/uttywotty/i-built-security-guardrails-for-claude-code-after-it-almost-leaked-my-credentials-2md8</guid>
      <description>&lt;p&gt;Claude Code is powerful. It has full access to your file system, &lt;br&gt;
your shell, and everything in between.&lt;/p&gt;

&lt;p&gt;That's also what makes it dangerous.&lt;/p&gt;
&lt;h2&gt;
  
  
  The problem nobody is talking about
&lt;/h2&gt;

&lt;p&gt;When you run Claude Code, you're giving an AI agent the ability to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read your &lt;code&gt;.env&lt;/code&gt; files and credentials&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;rm -rf&lt;/code&gt; on your project directory&lt;/li&gt;
&lt;li&gt;Execute &lt;code&gt;git push --force&lt;/code&gt; without asking&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;curl&lt;/code&gt; your files to external servers&lt;/li&gt;
&lt;li&gt;Install packages from untrusted sources&lt;/li&gt;
&lt;li&gt;Access your SSH keys, AWS credentials, database configs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of this requires the AI to be malicious. One hallucination, &lt;br&gt;
one misunderstood instruction, one edge case — and your secrets &lt;br&gt;
are in a log file somewhere.&lt;/p&gt;

&lt;p&gt;I discovered this while running AI coding agents on production &lt;br&gt;
intelligence pipelines. Credential leaks aren't theoretical in &lt;br&gt;
that environment. I needed something deterministic, not advisory.&lt;/p&gt;

&lt;p&gt;So I built AgentGuard.&lt;/p&gt;
&lt;h2&gt;
  
  
  How it works — three enforcement layers
&lt;/h2&gt;

&lt;p&gt;The core insight is defense-in-depth. No single layer is enough.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 1 — Behavioral rules (CLAUDE.md)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;18 security rules Claude Code reads at session start. Covers &lt;br&gt;
sensitive files, credentials, SQL safety, XSS, PII, and scope &lt;br&gt;
boundaries. Advisory only — the AI might still attempt violations, &lt;br&gt;
which is why we need layers 2 and 3.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 2 — Permission denials (settings.json)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;70+ hard deny rules built into Claude Code's permission system. &lt;br&gt;
Blocks file access and command execution at the platform level &lt;br&gt;
before anything else runs. The AI cannot override these.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 3 — Hook scripts (deterministic enforcement)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;8 bash scripts that intercept every single tool call. They inspect &lt;br&gt;
the command or file path using regex pattern matching and block &lt;br&gt;
with exit code 2 if it matches a dangerous pattern. Full incident &lt;br&gt;
logging to &lt;code&gt;~/.claude/guardrail-blocks.log&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Even if the AI ignores the behavioral rules, the deterministic &lt;br&gt;
layers will block prohibited actions.&lt;/p&gt;
&lt;h2&gt;
  
  
  What gets blocked
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Category&lt;/th&gt;
&lt;th&gt;Examples&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Sensitive files&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;.env&lt;/code&gt;, credentials, SSL certs, SSH keys, cloud configs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dangerous commands&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;rm -rf&lt;/code&gt;, &lt;code&gt;sudo&lt;/code&gt;, &lt;code&gt;chmod 777&lt;/code&gt;, &lt;code&gt;DROP TABLE&lt;/code&gt;, pipe-to-shell&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Git operations&lt;/td&gt;
&lt;td&gt;All &lt;code&gt;git&lt;/code&gt; commands — agent writes them as text, you run them&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data exfiltration&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;curl&lt;/code&gt;/&lt;code&gt;wget&lt;/code&gt; uploads, &lt;code&gt;base64&lt;/code&gt; of secrets, &lt;code&gt;netcat&lt;/code&gt; channels&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Untrusted packages&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;pip&lt;/code&gt;/&lt;code&gt;npm&lt;/code&gt; from git URLs, custom registries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Environment escape&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;ssh&lt;/code&gt;, &lt;code&gt;docker run/exec&lt;/code&gt;, &lt;code&gt;terraform apply/destroy&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PII in code&lt;/td&gt;
&lt;td&gt;SSNs, credit card numbers, Korean RRNs&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  Why not just use Claude Code's built-in permissions?
&lt;/h2&gt;

&lt;p&gt;The built-in permission system (Layer 2) is part of what we use — &lt;br&gt;
but it's glob-pattern only, no context awareness.&lt;/p&gt;

&lt;p&gt;The hook scripts add what the permission system can't do: &lt;br&gt;
context-aware regex inspection. So we can block &lt;code&gt;base64 .env&lt;/code&gt; &lt;br&gt;
but allow &lt;code&gt;base64 image.png&lt;/code&gt;. That contextual blocking is what &lt;br&gt;
the native deny rules miss.&lt;/p&gt;
&lt;h2&gt;
  
  
  Install in 2 minutes
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/opsight-intelligence/agentguard
&lt;span class="nb"&gt;cd &lt;/span&gt;agentguard
./install.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Restart Claude Code. That's it.&lt;/p&gt;

&lt;p&gt;Prerequisites: &lt;code&gt;jq&lt;/code&gt; must be installed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;macOS: &lt;code&gt;brew install jq&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Ubuntu/Debian: &lt;code&gt;sudo apt install jq&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Verify it's working
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./verify.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Checks all hooks are present, unmodified, executable, and &lt;br&gt;
registered correctly.&lt;/p&gt;
&lt;h2&gt;
  
  
  88 automated tests
&lt;/h2&gt;

&lt;p&gt;Every hook has both blocked and allowed test cases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./test.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because security tooling without tests is just hope.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;p&gt;The community edition (free, Apache 2.0) covers the developer &lt;br&gt;
workstation. The Pro tier adds CI/CD agents that run on every &lt;br&gt;
Pull Request — scanning, auto-fixing, and blocking merges when &lt;br&gt;
critical issues are found.&lt;/p&gt;

&lt;p&gt;Built by Opsight Intelligence.&lt;/p&gt;

&lt;p&gt;Repo: github.com/opsight-intelligence/agentguard&lt;/p&gt;

&lt;p&gt;Questions, issues, feedback welcome — open an issue or &lt;br&gt;
comment below.&lt;/p&gt;

</description>
      <category>claudeai</category>
      <category>security</category>
      <category>devtools</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
