Skip to main content

Sensitive Data Detection

MCPProxy includes automatic sensitive data detection to identify potential credential leakage, secrets exposure, and other security risks in AI agent tool calls. This feature helps protect against Tool Poisoning Attacks (TPA) and provides compliance auditing capabilities.

Overview

When AI agents interact with MCP tools, they may inadvertently expose sensitive information such as:

  • Credentials passed in tool arguments or returned in responses
  • API tokens leaked through error messages or debug output
  • Private keys embedded in configuration data
  • Database connection strings with embedded passwords

MCPProxy scans all tool call arguments and responses for sensitive data patterns, logging detections in the activity log for security review and compliance auditing.

Supported Detection Types

Cloud Credentials

ProviderPatternSeverity
AWS Access Key IDAKIA[0-9A-Z]{16}critical
AWS Secret Access Key40-character base64 stringscritical
GCP API KeyAIza[0-9A-Za-z-_]{35}critical
GCP Service AccountJSON with type: service_accountcritical
Azure Storage KeyBase64 storage account keyscritical
Azure Connection StringDefaultEndpointsProtocol=...critical

Private Keys

Key TypeDetection MethodSeverity
RSA Private Key-----BEGIN RSA PRIVATE KEY-----critical
EC Private Key-----BEGIN EC PRIVATE KEY-----critical
DSA Private Key-----BEGIN DSA PRIVATE KEY-----critical
OpenSSH Private Key-----BEGIN OPENSSH PRIVATE KEY-----critical
PGP Private Key-----BEGIN PGP PRIVATE KEY BLOCK-----critical
PKCS8 Private Key-----BEGIN PRIVATE KEY-----critical
Encrypted Private Key-----BEGIN ENCRYPTED PRIVATE KEY-----high

API Tokens

ServicePatternSeverity
GitHub Tokenghp_, gho_, ghu_, ghs_, ghr_ prefixescritical
GitHub Fine-grained Tokengithub_pat_ prefixcritical
GitLab Tokenglpat- prefixcritical
Stripe API Keysk_live_, sk_test_, rk_live_, rk_test_critical
Slack Tokenxoxb-, xoxp-, xoxa-, xoxr-critical
Slack Webhookhooks.slack.com/services/ URLshigh
SendGrid API KeySG. prefix with base64critical

LLM/AI Provider API Keys

ProviderPatternSeverity
OpenAIsk-, sk-proj-, sk-svcacct-, sk-admin- prefixescritical
Anthropicsk-ant-api03-, sk-ant-admin01- prefixescritical
Google AI/GeminiAIzaSy prefix (39 chars)critical
xAI/Grokxai- prefix (48+ chars)critical
Groqgsk_ prefix (52 chars)critical
Hugging Facehf_ prefix (37 chars)critical
Hugging Face Orgapi_org_ prefixcritical
Replicater8_ prefix (40 chars)critical
Perplexitypplx- prefix (53 chars)critical
Fireworks AIfw_ prefix (20+ chars)critical
Anyscaleesecret_ prefixcritical
Mistral AIKeyword context requiredhigh
CohereKeyword context requiredhigh
DeepSeeksk- with keyword contexthigh
Together AIKeyword context requiredhigh

Database Credentials

DatabasePatternSeverity
MySQLmysql://user:pass@hostcritical
PostgreSQLpostgres://user:pass@hostcritical
MongoDBmongodb://user:pass@host or mongodb+srv://critical
Redisredis://user:pass@host or rediss://high
Generic JDBCjdbc: URLs with credentialshigh

Credit Cards

Credit card numbers are detected using pattern matching combined with Luhn algorithm validation:

Card TypePatternSeverity
Visa4xxx-xxxx-xxxx-xxxxhigh
Mastercard5[1-5]xx-xxxx-xxxx-xxxxhigh
American Express3[47]xx-xxxxxx-xxxxxhigh
Discover6011-xxxx-xxxx-xxxxhigh
Luhn Validation

Credit card detection includes Luhn checksum validation to reduce false positives from random 16-digit numbers.

High-Entropy Strings

Strings with high Shannon entropy that may indicate secrets:

TypeCharacteristicsSeverity
Base64 SecretsHigh entropy, 20+ chars, base64 charsetmedium
Hex SecretsHigh entropy, 32+ chars, hex charsetmedium
Random TokensHigh entropy, mixed alphanumericlow

Sensitive File Paths

Detection of file paths that typically contain sensitive data:

CategoryExamplesSeverity
SSH Keys~/.ssh/id_rsa, ~/.ssh/id_ed25519high
Cloud Credentials~/.aws/credentials, ~/.config/gcloud/high
Environment Files.env, .env.local, .env.productionmedium
Key Files*.pem, *.key, *.p12, *.pfxhigh
Kubernetes Secretskubeconfig, ~/.kube/confighigh

Detection Categories and Severities

Categories

CategoryDescription
cloud_credentialsAWS, GCP, Azure credentials
private_keyRSA, EC, DSA, OpenSSH, PGP private keys
api_tokenGitHub, GitLab, Stripe, Slack, OpenAI tokens
auth_tokenJWT, Bearer tokens, session tokens
sensitive_filePaths to credential files
database_credentialDatabase connection strings with passwords
high_entropySuspicious high-entropy strings
credit_cardCredit card numbers (Luhn validated)

Severities

SeverityDescriptionAction
criticalDirect credential exposure, immediate riskInvestigate immediately
highSensitive data that could enable accessReview within 24 hours
mediumPotentially sensitive, context-dependentReview during audit
lowInformational, may be false positiveMonitor trends

Activity Log Integration

When sensitive data is detected, it is recorded in the activity log metadata:

{
"id": "01JFXYZ123ABC",
"type": "tool_call",
"server_name": "filesystem-server",
"tool_name": "read_file",
"status": "success",
"timestamp": "2025-01-15T10:30:00Z",
"metadata": {
"sensitive_data_detected": true,
"sensitive_data": [
{
"type": "aws_access_key",
"category": "cloud_credentials",
"severity": "critical",
"location": "response",
"context": "AKIA...XXXX (redacted)"
},
{
"type": "private_key",
"category": "private_key",
"severity": "critical",
"location": "response",
"context": "RSA PRIVATE KEY detected"
}
]
}
}
Redaction

Detected sensitive values are automatically redacted in the activity log to prevent secondary exposure. Only the type, category, and partial context are stored.

Web UI Usage

The Activity Log page in the web UI provides filtering and visualization for sensitive data detections.

Filtering by Sensitive Data

  1. Navigate to Activity Log in the sidebar
  2. Use the Sensitive Data filter dropdown to show only activities with detections
  3. Filter by severity level (critical, high, medium, low)
  4. Click on an activity row to view detection details

Detection Indicators

Activities with sensitive data detections are marked with visual indicators:

  • Red shield icon for critical severity
  • Orange warning icon for high severity
  • Yellow info icon for medium severity
  • Gray info icon for low severity

Detail View

Clicking on an activity with detections shows:

  • List of all detected sensitive data types
  • Location (arguments or response)
  • Redacted context for verification
  • Timestamp and duration

CLI Usage

List Activities with Sensitive Data

# Show all activities with sensitive data detections
mcpproxy activity list --sensitive-data

# Filter by severity
mcpproxy activity list --sensitive-data --severity critical

# Combine with other filters
mcpproxy activity list --sensitive-data --server github-server --status success

View Detection Details

# Show full details including sensitive data metadata
mcpproxy activity show 01JFXYZ123ABC

# JSON output for scripting
mcpproxy activity show 01JFXYZ123ABC --output json

Export for Compliance

# Export activities with sensitive data for security review
mcpproxy activity export --sensitive-data --output security-audit.jsonl

# Export critical severity only
mcpproxy activity export --sensitive-data --severity critical --output critical-findings.jsonl

Summary Statistics

# Show sensitive data detection summary
mcpproxy activity summary --period 24h

# Output includes detection counts by category and severity

Configuration

Sensitive data detection is enabled by default. Configure via mcp_config.json:

{
"sensitive_data_detection": {
"enabled": true,
"scan_arguments": true,
"scan_responses": true,
"severity_threshold": "low",
"categories": {
"cloud_credentials": true,
"private_key": true,
"api_token": true,
"auth_token": true,
"sensitive_file": true,
"database_credential": true,
"high_entropy": true,
"credit_card": true
}
}
}
SettingDefaultDescription
enabledtrueEnable/disable sensitive data detection
scan_argumentstrueScan tool call arguments
scan_responsestrueScan tool call responses
severity_threshold"low"Minimum severity to log (low, medium, high, critical)
categories.*trueEnable/disable specific detection categories

See Configuration for complete reference.

Cross-Platform Support

Sensitive file path detection adapts to the operating system:

PlatformPath Patterns
macOS~/Library/, ~/.ssh/, ~/.aws/, ~/.config/
Linux~/.ssh/, ~/.aws/, ~/.config/, /etc/ssl/private/
Windows%USERPROFILE%\.ssh\, %USERPROFILE%\.aws\, %APPDATA%\

Path detection normalizes separators and expands home directory references for consistent cross-platform detection.

Security Best Practices

Compliance Auditing

Use sensitive data detection for regular security audits:

# Weekly security audit export
mcpproxy activity export \
--sensitive-data \
--start-time "$(date -v-7d +%Y-%m-%dT00:00:00Z)" \
--output weekly-security-audit.jsonl

# Generate summary report
mcpproxy activity summary --period 7d --output json > weekly-summary.json

Real-time Monitoring

Monitor for critical detections in real-time:

# Watch for sensitive data detections
mcpproxy activity watch --sensitive-data --severity critical

Integration with SIEM

Export activity logs for integration with Security Information and Event Management (SIEM) systems:

# Continuous export for SIEM ingestion
mcpproxy activity export --format json --output - | \
your-siem-forwarder --input -

Incident Response

When a critical detection is identified:

  1. Review the activity: mcpproxy activity show <id>
  2. Identify the source: Check server name and tool name
  3. Assess impact: Determine if credentials were exposed externally
  4. Rotate credentials: If exposed, rotate the affected credentials immediately
  5. Investigate root cause: Review how sensitive data entered the tool call

Prevention Recommendations

  1. Use Docker isolation for untrusted servers with network_mode: "none"
  2. Enable quarantine for new servers added by AI agents
  3. Review tool descriptions for potential data exfiltration patterns
  4. Set up alerts for critical severity detections
  5. Regular audits of activity logs for security compliance