<?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: Hemanath_K</title>
    <description>The latest articles on DEV Community by Hemanath_K (@hemanath_dev).</description>
    <link>https://dev.to/hemanath_dev</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%2F4250111%2Fbc4d8338-41e0-4f41-8e55-78877c0c3182.png</url>
      <title>DEV Community: Hemanath_K</title>
      <link>https://dev.to/hemanath_dev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hemanath_dev"/>
    <language>en</language>
    <item>
      <title>I built a 15µs Rust hook that stops API keys before they hit ~/.zsh_history or AI agent logs.

Quick question for fellow devs:
Have you ever accidentally leaked a token in your terminal? 🦀</title>
      <dc:creator>Hemanath_K</dc:creator>
      <pubDate>Tue, 17 Nov 2026 15:37:17 +0000</pubDate>
      <link>https://dev.to/hemanath_dev/i-built-a-15us-rust-hook-that-stops-api-keys-before-they-hit-zshhistory-or-ai-agent-logs-50hm</link>
      <guid>https://dev.to/hemanath_dev/i-built-a-15us-rust-hook-that-stops-api-keys-before-they-hit-zshhistory-or-ai-agent-logs-50hm</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/hemanath_dev/i-built-a-15us-rust-hook-to-stop-api-keys-from-leaking-into-shell-history-ai-agents-44lm" class="crayons-story__hidden-navigation-link"&gt;I Built a 15µs Rust Hook to Stop API Keys from Leaking into Shell History &amp;amp; AI Agents&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/hemanath_dev" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4250111%2Fbc4d8338-41e0-4f41-8e55-78877c0c3182.png" alt="hemanath_dev profile" class="crayons-avatar__image" width="96" height="96"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/hemanath_dev" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Hemanath_K
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Hemanath_K
                
                
              
              &lt;div id="story-author-preview-content-5058227" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/hemanath_dev" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4250111%2Fbc4d8338-41e0-4f41-8e55-78877c0c3182.png" class="crayons-avatar__image" alt="" width="96" height="96"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Hemanath_K&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/hemanath_dev/i-built-a-15us-rust-hook-to-stop-api-keys-from-leaking-into-shell-history-ai-agents-44lm" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Nov 17&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/hemanath_dev/i-built-a-15us-rust-hook-to-stop-api-keys-from-leaking-into-shell-history-ai-agents-44lm" id="article-link-5058227"&gt;
          I Built a 15µs Rust Hook to Stop API Keys from Leaking into Shell History &amp;amp; AI Agents
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/rust"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;rust&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/security"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;security&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/cli"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;cli&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ai"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ai&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/hemanath_dev/i-built-a-15us-rust-hook-to-stop-api-keys-from-leaking-into-shell-history-ai-agents-44lm" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;2&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/hemanath_dev/i-built-a-15us-rust-hook-to-stop-api-keys-from-leaking-into-shell-history-ai-agents-44lm#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            3 min read
          &lt;/small&gt;
          
          &lt;div class="only-sidebar-menu-item trusted-visible-block print-hidden align-center"&gt;
                
                    
                
          &lt;/div&gt;

        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;/div&gt;


</description>
      <category>cybersecurity</category>
      <category>rust</category>
      <category>security</category>
    </item>
    <item>
      <title>I Built a 15µs Rust Hook to Stop API Keys from Leaking into Shell History &amp; AI Agents</title>
      <dc:creator>Hemanath_K</dc:creator>
      <pubDate>Tue, 17 Nov 2026 15:06:55 +0000</pubDate>
      <link>https://dev.to/hemanath_dev/i-built-a-15us-rust-hook-to-stop-api-keys-from-leaking-into-shell-history-ai-agents-44lm</link>
      <guid>https://dev.to/hemanath_dev/i-built-a-15us-rust-hook-to-stop-api-keys-from-leaking-into-shell-history-ai-agents-44lm</guid>
      <description>&lt;p&gt;Every secret scanner on the market today runs &lt;strong&gt;after&lt;/strong&gt; the damage has already happened.&lt;/p&gt;

&lt;p&gt;Tools like GitGuardian, TruffleHog, and pre-commit hooks check your code when you type &lt;code&gt;git commit&lt;/code&gt; or push to CI. But if you accidentally paste a token or database string into your shell:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It is already written in plain text to &lt;code&gt;~/.zsh_history&lt;/code&gt; or &lt;code&gt;~/.bash_history&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;It was broadcast live on your screen during a Zoom or Google Meet demo.&lt;/li&gt;
&lt;li&gt;Autonomous AI coding agents (like Claude Code or Cursor) already cached your terminal buffer into local workspace configs (&lt;code&gt;.claude/settings.local.json&lt;/code&gt;).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I wanted a privacy guard that lives directly inside the terminal execution loop and stops secrets &lt;strong&gt;at the keystroke level before commands ever touch persistent disk&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;&lt;a href="https://github.com/hemanathk636/secretguard" rel="noopener noreferrer"&gt;SecretGuard&lt;/a&gt;&lt;/strong&gt; in Rust.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡ 15.68 Microseconds Latency
&lt;/h2&gt;

&lt;p&gt;When building a pre-exec shell hook, speed is everything. If the hook introduces even a 20ms lag, your terminal feels sluggish.&lt;/p&gt;

&lt;p&gt;SecretGuard is compiled with aggressive release profile optimizations (&lt;code&gt;opt-level = 3&lt;/code&gt;, &lt;code&gt;lto = true&lt;/code&gt;, &lt;code&gt;codegen-units = 1&lt;/code&gt;, &lt;code&gt;panic = "abort"&lt;/code&gt;):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Average Scan Latency:&lt;/strong&gt; &lt;strong&gt;15.68 µs (0.016 milliseconds)&lt;/strong&gt; across 1,000 synthetic commands.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Binary Footprint:&lt;/strong&gt; &lt;strong&gt;1.56 MB&lt;/strong&gt; standalone static binary.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero Network / 100% Offline:&lt;/strong&gt; Never connects to external servers, zero telemetry.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔍 How Detection Works
&lt;/h2&gt;

&lt;p&gt;SecretGuard uses a dual-engine architecture to catch both known formats and raw unformatted secrets:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Compiled Signature Engine
&lt;/h3&gt;

&lt;p&gt;Matches known SaaS tokens in sub-microsecond time using a compiled &lt;code&gt;regex::RegexSet&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OpenAI / Anthropic (&lt;code&gt;sk-proj-...&lt;/code&gt;, &lt;code&gt;ant-api-...&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;AWS Access Keys (&lt;code&gt;AKIA...&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;GitHub Personal Access Tokens (&lt;code&gt;ghp_...&lt;/code&gt;, &lt;code&gt;github_pat_...&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Stripe live/test API keys (&lt;code&gt;sk_live_...&lt;/code&gt;, &lt;code&gt;rk_live_...&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Slack bot tokens &amp;amp; webhooks (&lt;code&gt;xoxb-...&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;PostgreSQL, MySQL, MongoDB URIs with embedded passwords&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Contextual Shannon Entropy ($H \ge 3.6$)
&lt;/h3&gt;

&lt;p&gt;For arbitrary passwords and non-standard tokens, SecretGuard calculates character probability distributions using Shannon Entropy:&lt;/p&gt;

&lt;p&gt;$$H(X) = -\sum_{i=1}^{n} P(x_i) \log_2 P(x_i)$$&lt;/p&gt;

&lt;p&gt;To eliminate false positives, it automatically discounts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UUIDs (&lt;code&gt;550e8400-e29b-41d4-a716-446655440000&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Git commit SHA-1 / SHA-256 hashes&lt;/li&gt;
&lt;li&gt;Hexadecimal color codes and standard system paths&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🛠️ CLI Toolkit
&lt;/h2&gt;

&lt;p&gt;SecretGuard is more than just a background hook:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Live Shell Hook
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Attach to your active Zsh session&lt;/span&gt;
secretguard hook zsh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you hit Enter on a command containing an API key, SecretGuard flags the secret, strips it from shell history, and saves you from a leak.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. One-Click History Scrubbing
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;secretguard clean-history
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finds and scrubs historical tokens already trapped inside &lt;code&gt;~/.zsh_history&lt;/code&gt; or &lt;code&gt;~/.bash_history&lt;/code&gt;, creating an automatic timestamped backup first.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. AI Coding Agent Protection
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;secretguard protect-agent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Scans &lt;code&gt;.claude/&lt;/code&gt; and &lt;code&gt;.cursor/&lt;/code&gt; workspace directories to ensure cached environment variables and MCP credentials aren't accidentally committed to Git.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Real-Time Cloaked Wrappers
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;secretguard wrap &lt;span class="s2"&gt;"curl -H 'Authorization: Bearer sk-proj-...' https://api.openai.com/v1/models"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Masks stdout tokens on the fly during screen shares, video recordings, and conference talks.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Instant Diagnostics
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;secretguard doctor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Runs a health check verifying hook status, history hygiene, agent config security, and engine benchmark in under 10ms.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Quick Install
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Via Homebrew (macOS / Linux):
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew tap hemanathk636/tap &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; brew install secretguard
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Via One-Line Installer:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -fsSL https://raw.githubusercontent.com/hemanathk636/secretguard/main/install.sh &lt;span class="o"&gt;|&lt;/span&gt; bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Via Cargo:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo install --git https://github.com/hemanathk636/secretguard.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🔗 Links &amp;amp; Feedback
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/hemanathk636/secretguard" rel="noopener noreferrer"&gt;hemanathk636/secretguard&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interactive Web Sandbox &amp;amp; Entropy Visualizer:&lt;/strong&gt; &lt;a href="https://hemanathk636.github.io/secretguard/" rel="noopener noreferrer"&gt;hemanathk636.github.io/secretguard&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I would love to hear feedback from the developer community! What edge cases, token formats, or terminal shells would you like to see supported next? If you find it useful, a star on GitHub means the world! ⭐&lt;/p&gt;

</description>
      <category>rust</category>
      <category>security</category>
      <category>cli</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
