Skip to content

Secrets Protection for AI Coding Tools ​

Executive Summary ​

AI coding assistants—Cursor, Windsurf, Claude Code, GitHub Copilot—routinely send code context to third-party LLM providers. That context often contains API keys, database credentials, private keys, and OAuth tokens embedded in source code and configuration files. GhostAI's Secrets Protection intercepts these secrets in real time at the point of transmission, before they ever reach an external model. Unlike traditional secret scanners that only detect leaks after code is committed, GhostAI prevents the leak from happening in the first place.


The Problem ​

Modern AI tools transmit substantial context to LLM providers. Cursor sends open files and project context via the OpenAI API; Claude Code sends file contents via the Anthropic Messages API. This context frequently includes AWS access keys, database connection strings, private keys, and API keys—either hardcoded or in environment variables. A single accidental paste can expose credentials to a third-party provider. Traditional scanners like GitGuardian and TruffleHog scan repositories after the fact; they cannot protect against secrets sent directly from an AI tool to a model provider before any commit occurs.


How GhostAI Solves It ​

GhostAI acts as a transparent proxy between AI coding tools and LLM providers. Every request passes through a detection pipeline that identifies 20+ secret types using pattern matching, high-entropy analysis, and configurable custom patterns. Secrets are replaced with reversible tokens before the request reaches any external model; responses are detokenized before returning to the developer. The experience remains seamless—developers keep coding—while secrets never leave their infrastructure.


Architecture ​

The proxy layer sits between the developer's AI tool and the LLM provider. A Secrets Detector scans all message content; a Policy Engine applies warn, block, or redact actions; a Token Vault stores reversible mappings. The system supports OpenAI-compatible (/v1/chat/completions), Anthropic-compatible (/v1/messages), and MCP protocols. No changes to the AI tool's core behavior are required—only the API base URL and key are pointed to GhostAI.


Supported Secret Types ​

CategoryExamples
CloudAWS Access Key, Google API Key
Source ControlGitHub Token, GitLab PAT
AI/MLOpenAI API Key
PaymentStripe (test + live)
CommunicationSlack, Twilio, SendGrid
DatabasesPostgreSQL, MySQL, MongoDB, Redis connection URLs
CryptographicRSA, EC, OpenSSH private keys
GenericHigh-entropy strings, env var secrets

High-entropy detection catches unknown secret formats. Custom patterns support internal formats (e.g., myco_prod_[A-Za-z0-9]{32}).


Protocol Support ​

  • OpenAI-compatible — Cursor, Windsurf, any OpenAI SDK
  • Anthropic-compatible — Claude Code, Anthropic SDK
  • MCP — Cursor MCP, Claude Desktop, n8n (scan, sanitize, restore tools)

Defense in Depth ​

  1. Input scanning — Secrets tokenized before reaching the LLM
  2. Response scanning — LLM output scanned for hallucinated or regurgitated secrets
  3. Context budget — Maximum secrets per request prevents bulk exfiltration
  4. Pre-commit hooks — Catch secrets before version control
  5. Canary tokens — Trackable fake secrets to detect provider leaks (Enterprise)

Deployment ​

GhostAI deploys on existing infrastructure: Docker, Kubernetes, AWS ECS/Fargate, or air-gapped environments. No new services or load balancers are required. Configure the AI tool to use GhostAI as the API base URL; all traffic flows through the proxy automatically.


Performance ​

OperationTarget
Input scanning<50ms P95
Response scanning<30ms P95
Workspace scan (10K files)<5s

Comparison: GhostAI vs Traditional Scanners ​

CapabilityGhostAIGitGuardianTruffleHogGitleaks
Real-time AI tool interceptionYesNoNoNo
Pre-transmission protectionYesNoNoNo
PII + Secrets combinedYesSecrets onlySecrets onlySecrets only
Reversible tokenizationYesN/AN/AN/A
OpenAI/Anthropic proxyYesNoNoNo
MCP serverYesNoNoNo
Secret manager integrationYesPartialNoNo
Canary tokensYesNoNoNo

Traditional scanners operate post-commit; GhostAI operates at the point of transmission. Both approaches are complementary—use GhostAI for real-time protection and scanners for repository hygiene.


GhostAI — Your secrets stay invisible.

SOC 2 Type II Certified | BAA Available | HIPAA-Ready