Skip to content
FaradAiLab Logo FaradAiLab
• FaradAiLab Security Research

Preventing API Key and PII Leaks in MCP Tool Calls with Deterministic DLP

Configure linear-time RE2 Data Loss Prevention in FaradAiWire to block or redact credentials in AI agent tool arguments and responses.

#DLP #MCP #Secret Scanning #Zero Trust

Coding agents and autonomous workflows frequently read .env files, shell histories, or production logs and pass those strings straight into external MCP tool arguments—exposing cloud credentials and PII to third-party servers.

Deterministic Request & Response Scanning

FaradAiWire executes its Data Loss Prevention (dlp) filter at OrderDLP = 50 on the Proxy Ingress (127.0.0.1:19410), scanning serialized JSON payloads in linear time via Go’s RE2 engine before a tool runs and again on the returned tool response.

Depending on your risk tolerance per pattern or agent profile, each rule enforces one of four actions:

  • block: Terminates the tools/call immediately with JSON-RPC error -32004 (ErrDLPViolation), naming only the matched rule without echoing the secret.
  • mask: Replaces matched spans with a placeholder ([REDACTED:<NAME>] in agent overrides) and lets the sanitized payload continue.
  • hitl: Pauses request execution (up to 60 seconds) for operator approval (-32000 if denied or timed out).
  • audit: Records the detection in the audit trail without modifying the payload.

Known Limits to Design Around

Transparent engineering means knowing what regex DLP does and does not catch:

  • No base64 or split-secret decoding: DLP scans the serialized JSON string and percent-decoded variants (block, hitl, audit), not base64/hex encodings or multi-part obfuscated secrets.
  • Masking vs. URL encoding: mask does not redact percent-encoded variants in payloads.
  • hitl is request-only: Response-path hitl rules are skipped rather than paused.
  • Latency scales with payload size and pattern count: RE2 runs in linear time, with no fixed hard-coded millisecond guarantee enforced in code.

Next Steps

  • See full pattern precedence, agent dlp.json overrides, and troubleshooting in the DLP Filter Reference.
  • Route Claude Code, Cursor, Windsurf, or custom SDK agents through port 19410 using the Agent & IDE Setup Guide.

Protect your agent workflows today

Test this vulnerability against FaradAiWire locally with our CLI or apply for FaradAiLab Enterprise Edition private beta.