Dev.to Security 🔐 Cybersecurity 👁 0 📖 2 min read

Your AI coding agents store your .env keys in plaintext — so I built a 1.8 GB/s Rust scrubber

Every time Claude Code, Codex CLI, Cursor, Antigravity, Windsurf, OpenCode, or Aider reads a .env file, runs env, or logs an API error, those live keys get written permanently into plaintext .jsonl transcripts and caches

Every time Claude Code, Codex CLI, Cursor, Antigravity, Windsurf, OpenCode, or Aider reads a .env file, runs env, or logs an API error, those live keys get written permanently into plaintext .jsonl transcripts and caches on your disk (~/.claude/projects/, ~/.codex/sessions/, ~/.cursor/, ~/.gemini/antigravity/brain/, etc.).

I audited my own machine and found 286 MB of local AI agent transcripts across 4 tools — with real live keys sitting in plaintext.

So I built agent-scrub — a zero-dependency, 100% offline Rust CLI + Browser Scanner + Agent Skill (MIT).

What it does

  • Auto-discovers 8+ AI coding agents on Windows, macOS, and Linux (+ opt-in --include-shell for bash, zsh, fish, and PowerShell history).
  • 27 high-precision secret rules + Shannon entropy & placeholder filtering (Anthropic, OpenAI, xAI, OpenRouter, Google/Gemini, AWS, GitHub, GitLab, Stripe Live, Slack, Discord, npm, PyPI, Hugging Face, Groq, DB URI passwords, PEM private keys, JWTs).
  • 1.83 GB/s two-stage SIMD Rust engine (RegexSet pure-ASCII literal prefilter + rayon parallel scanning). Scanned 1,682 real local files (286.7 MB) in 1.64 seconds.
  • Zero-leak guarantee — never prints raw credentials (always masked like sk-or-...393a), 100% offline, zero telemetry.
  • Safe atomic redaction — agent-scrub redact defaults to dry-run. Passing --apply replaces secrets in-place via atomic temp-file rename with [REDACTED:agent-scrub:<RULE_ID>] (keeping JSONL syntax 100% valid) and saves timestamped backups to ~/.agent-scrub/backups/.

Try it in 5 seconds

Option 1 — 100% offline Browser Scanner (zero install, zero uploads):

https://rm-rf-enjoyer163.github.io/agent-scrub/

Option 2 — Prebuilt native binaries (Windows / macOS / Linux):

https://github.com/rm-rf-enjoyer163/agent-scrub/releases/tag/v1.0.1

# Audit all installed AI coding agents (read-only)
agent-scrub scan

# Dry-run preview
agent-scrub redact

# Apply atomic redactions with automatic backups
agent-scrub redact --apply

Option 3 — Install as an Agent Skill (Claude Code / Cursor / Codex / Antigravity):

npx skills add rm-rf-enjoyer163/agent-scrub

Why the two-stage SIMD prefilter mattered

In v1.0.0, compiling all 27 full regexes with Unicode \b and large bounded repetitions ({36,255}) directly into a single RegexSet caused real multi-megabyte JSONL files to slow down dramatically. Splitting detection into a pure-ASCII literal RegexSet prefilter ((?-u) — compiled by Rust's regex crate into SIMD Teddy/Aho-Corasick) followed by targeted rule extraction with length bounds checked in Rust pushed throughput to 1,827 MB/s on Linux CI and 1,760 MB/s on a 12-thread desktop.

Would love feedback on any other AI coding agents or secret formats I should add next!

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.