<?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: intothewild</title>
    <description>The latest articles on DEV Community by intothewild (@intothewild9).</description>
    <link>https://dev.to/intothewild9</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%2F4224610%2Fb26f010d-5aec-4307-8ff8-8861b95c1095.png</url>
      <title>DEV Community: intothewild</title>
      <link>https://dev.to/intothewild9</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/intothewild9"/>
    <language>en</language>
    <item>
      <title>Can an MCP Server Actually Help Prevent AI Agents From Leaking Secrets?</title>
      <dc:creator>intothewild</dc:creator>
      <pubDate>Sat, 07 Nov 2026 17:08:12 +0000</pubDate>
      <link>https://dev.to/intothewild9/can-an-mcp-server-actually-help-prevent-ai-agents-from-leaking-secrets-2jib</link>
      <guid>https://dev.to/intothewild9/can-an-mcp-server-actually-help-prevent-ai-agents-from-leaking-secrets-2jib</guid>
      <description>&lt;p&gt;I've been experimenting with MCP servers and AI coding agents while building an open-source project called StagedSec.&lt;/p&gt;

&lt;p&gt;One thing I've been thinking about is where security checks should happen when an AI agent works with a developer's repository.&lt;/p&gt;

&lt;p&gt;Most secret scanners operate on files, Git history, or commits. These are useful, but with AI agents, there's another interesting point: the moment an agent attempts to write something.&lt;/p&gt;

&lt;p&gt;Imagine an agent generating a configuration file containing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;API_KEY=sk_live_...
DATABASE_PASSWORD=...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A scanner can find these values later, but what if we could inspect the content before allowing the write?&lt;/p&gt;

&lt;p&gt;That's one of the ideas behind StagedSec.&lt;/p&gt;

&lt;h3&gt;
  
  
  What I'm experimenting with
&lt;/h3&gt;

&lt;p&gt;StagedSec currently has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Go-based secret detection engine.&lt;/li&gt;
&lt;li&gt;An MCP server that exposes scanning capabilities to AI agents.&lt;/li&gt;
&lt;li&gt;An agent hook that checks tool-call content.&lt;/li&gt;
&lt;li&gt;A CLI, Git integration, and VS Code extension.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is to make secret detection available closer to the point where the content is generated.&lt;/p&gt;

&lt;h3&gt;
  
  
  But there are still difficult problems
&lt;/h3&gt;

&lt;p&gt;I'm particularly interested in a few questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What happens when an agent splits a secret across multiple tool calls?&lt;/li&gt;
&lt;li&gt;How should a security hook handle repeated retries without making the agent workflow unusable?&lt;/li&gt;
&lt;li&gt;Can we detect encoded or obfuscated secrets without storing sensitive content?&lt;/li&gt;
&lt;li&gt;How much should an MCP server be responsible for enforcing security versus simply reporting findings?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These aren't completely solved problems in my implementation. I'm exploring them as I develop the project.&lt;/p&gt;

&lt;h3&gt;
  
  
  I'd like to hear from people working with MCP and AI agents
&lt;/h3&gt;

&lt;p&gt;If you're building MCP servers, AI coding tools, or developer security tooling, I'd genuinely like to hear how you're approaching these problems.&lt;/p&gt;

&lt;p&gt;I'm also looking for a few people willing to test the MCP integration and report what works or doesn't.&lt;/p&gt;

&lt;p&gt;Project: &lt;a href="https://gitlab.com/stagedsec/stagedsec" rel="noopener noreferrer"&gt;https://gitlab.com/stagedsec/stagedsec&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;MCP package: &lt;a href="https://www.npmjs.com/package/stagedsec-mcp-server" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/stagedsec-mcp-server&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is an early open-source project, and I'm interested in technical criticism just as much as positive feedback.&lt;/p&gt;

</description>
      <category>agents</category>
      <category>ai</category>
      <category>mcp</category>
      <category>security</category>
    </item>
    <item>
      <title>4 mistakes I made building a Claude Code security hook (and how to avoid them)</title>
      <dc:creator>intothewild</dc:creator>
      <pubDate>Wed, 04 Nov 2026 16:51:22 +0000</pubDate>
      <link>https://dev.to/intothewild9/4-mistakes-i-made-building-a-claude-code-security-hook-and-how-to-avoid-them-2l44</link>
      <guid>https://dev.to/intothewild9/4-mistakes-i-made-building-a-claude-code-security-hook-and-how-to-avoid-them-2l44</guid>
      <description>&lt;p&gt;Claude Code can run a command of yours before every tool call: a PreToolUse hook. It’s a great place for guardrails, but it’s easy to get subtly wrong. I built one that blocks secrets, and these are the lessons. (Check the current Claude Code hooks docs for exact field names, since they can change.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How a hook works, in 30 seconds&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Claude Code sends the tool call to your command as JSON on stdin, containing the tool name and its input. For a file write that includes the path and the content. Your command either lets it through or denies it.&lt;/p&gt;

&lt;p&gt;Registering a hook looks like this in .claude/settings.json:&lt;/p&gt;

&lt;p&gt;json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"PreToolUse"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Write|Edit|MultiEdit|NotebookEdit|Bash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"your-hook"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The matcher decides which tools trigger it. Include Bash, or the agent can bypass your file checks with echo "KEY=..." &amp;gt; file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mistake 1: Emitting “allow” when everything looks fine&lt;/strong&gt;&lt;br&gt;
My first version printed an “allow” decision for clean calls. That sounds harmless, but an explicit allow can skip the user’s normal permission prompts. A guardrail should only ever remove permission, never grant it.&lt;/p&gt;

&lt;p&gt;Fix: for a clean call, print nothing and exit 0. Only speak up to deny.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mistake 2: Assuming any non-zero exit blocks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Claude Code, exit code 2 blocks the call, but exit code 1 is treated as a non-blocking error. If your hook crashes on bad input and exits 1, the tool call goes ahead. Decide deliberately:&lt;/p&gt;

&lt;p&gt;Can’t parse the input → exit 1 (non-blocking), with a message on stderr.&lt;br&gt;
Found a problem → deny, either with a JSON permissionDecision: "deny" or exit 2.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mistake 3: Letting the agent exempt itself&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Many scanners support a comment like # allow to ignore a line. That’s fine for humans, but an agent can just write the comment next to its own secret. In agent mode I ignore inline allow comments and only honor the allowlist in the config file, which the human controls.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mistake 4: Failing open on big input&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If the input is too large to scan, the easy choice is to let it through. Then a huge file becomes a free bypass. I cap input at 16 MiB and block anything larger, telling the agent to split the content. A check that silently covers only part of the content reports a false “clean”.&lt;/p&gt;

&lt;h2&gt;
  
  
  And most critical what not to put in the deny message
&lt;/h2&gt;

&lt;p&gt;When you block, the message goes back to the model. Don’t include the real secret. I show only a masked form like AKIA************WZVB, so the credential never enters the model’s context a second time.&lt;/p&gt;

&lt;p&gt;The project&lt;/p&gt;

&lt;p&gt;I turned all of this into a free, local, open-source tool called StagedSec, and the hook is one command: stagedsec agent-hook --print-config prints the settings snippet. It’s early (v0.1), and I list its limits in the README, including that split or encoded secrets aren’t detected yet.&lt;/p&gt;

&lt;p&gt;If you’ve built Claude Code hooks, what surprised you? I’m especially curious about edge cases around multi-edit calls.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://gitlab.com/stagedsec/stagedsec" rel="noopener noreferrer"&gt;https://gitlab.com/stagedsec/stagedsec&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>go</category>
      <category>security</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>I Built a Local Secret Scanner That Intercepts AI Coding Agents Before They Write to Disk</title>
      <dc:creator>intothewild</dc:creator>
      <pubDate>Tue, 03 Nov 2026 16:01:02 +0000</pubDate>
      <link>https://dev.to/intothewild9/i-built-a-local-secret-scanner-that-intercepts-ai-coding-agents-before-they-write-to-disk-4h3j</link>
      <guid>https://dev.to/intothewild9/i-built-a-local-secret-scanner-that-intercepts-ai-coding-agents-before-they-write-to-disk-4h3j</guid>
      <description>&lt;p&gt;AI coding agents are incredibly fast, remarkably helpful, and completely unaware of which strings are secrets.&lt;br&gt;
Existing scanners like Gitleaks and TruffleHog are excellent tools, but they primarily catch secrets after they have already been written to disk—whether that is locally at commit time or downstream in your CI pipeline.&lt;/p&gt;

&lt;p&gt;Once an autonomous agent is in your loop, that window is too wide. Tools like Claude Code and Cursor will happily paste a live API key directly into a file or an unmasked curl command if they aren't stopped. I wanted a way to check content before the write operation even happens.&lt;br&gt;
So I built StagedSec.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it does&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;StagedSec uses a single detection engine that intercepts secret leaks at three critical development points:&lt;/p&gt;

&lt;h2&gt;
  
  
  Where      How it works
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Terminal&lt;/strong&gt;&lt;br&gt;
             stagedsec scan runs as a pre-commit hook checking exactly what is staged.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Editor&lt;/strong&gt;&lt;br&gt;
    A native VS Code extension highlights secrets as you type and provides rotation guides.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI Agent&lt;/strong&gt;&lt;br&gt;
    A Claude Code hook and a Model Context Protocol (MCP) server inspect content right inside the agent's write loop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Design Philosophy
&lt;/h2&gt;

&lt;p&gt;• 100% Local Execution: Everything runs directly on your machine.&lt;br&gt;
• Zero Overhead: No accounts to create, no tracking, and no external telemetry.&lt;br&gt;
• The Single Network Exception: There is a completely opt-in --verify-aws flag. When enabled, it reaches out to check if an identified AWS key is actually live. It is entirely turned off by default.&lt;/p&gt;

&lt;h2&gt;
  
  
  Current State &amp;amp; Honest Limitations (Roast Me)
&lt;/h2&gt;

&lt;p&gt;This is currently at version v0.1.&lt;br&gt;
To be completely transparent about where it stands:&lt;br&gt;
• It has about 70 detection rules compared to Gitleaks’ ~220.&lt;br&gt;
• On a fresh, untuned set of token types, its current hit rate is roughly 50%.&lt;br&gt;
• The complete benchmark harness—including the exact test cases where the scanner currently loses—is included directly in the repository. I'd much rather you see where it fails directly from me.&lt;br&gt;
The project is written in Go and is entirely MIT licensed.&lt;br&gt;
I would love to get the community's feedback on this. Specifically, opening issues regarding false positives or missed secrets in your own agent workflows is the most helpful thing you can give me right now to improve the ruleset.&lt;br&gt;
Main Repository: &lt;a href="https://gitlab.com/stagedsec/stagedsec" rel="noopener noreferrer"&gt;https://gitlab.com/stagedsec/stagedsec&lt;/a&gt;&lt;br&gt;
github repo: &lt;a href="https://github.com/stagedsec/stagedsec" rel="noopener noreferrer"&gt;https://github.com/stagedsec/stagedsec&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>security</category>
      <category>discuss</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
