Commit dfe3cbb
feat(security): add sensitive data detection for tool calls (Spec 026) (#289)
* feat(security): add sensitive data detection for tool calls (Spec 026)
Implement automatic scanning of tool call arguments and responses for
secrets, credentials, and sensitive data patterns including:
- Cloud credentials (AWS, GCP, Azure)
- Private keys (RSA, EC, DSA, OpenSSH, PGP)
- API tokens (GitHub, GitLab, Stripe, Slack, OpenAI)
- Database connection strings (MySQL, PostgreSQL, MongoDB)
- Credit card numbers (with Luhn validation)
- Sensitive file paths (.ssh/, .aws/, .env files)
- High-entropy strings (potential secrets)
Key features:
- Async detection integrated with ActivityService
- REST API filtering (sensitive_data, detection_type, severity params)
- CLI flags: --sensitive-data, --detection-type, --severity
- Web UI: detection badges, severity indicators, detail drawer
- Configurable categories and custom patterns support
- Event bus integration for real-time notifications
Also fixes CLI socket path detection bug where os.Stat was called
with unix:// prefix, causing fallback to HTTP with wrong port.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(security): add LLM provider API keys and doctor status
- Add sensitive data detection status to `mcpproxy doctor` output
- Include SensitiveDataDetection in DefaultConfig() for new installs
- Add detection patterns for 14 LLM/AI providers:
- Google AI/Gemini (AIzaSy prefix)
- xAI/Grok (xai- prefix)
- Groq (gsk_ prefix)
- Hugging Face (hf_, api_org_ prefixes)
- Replicate (r8_ prefix)
- Perplexity (pplx- prefix)
- Fireworks AI (fw_ prefix)
- Anyscale (esecret_ prefix)
- Mistral AI (keyword context)
- Cohere (keyword context)
- DeepSeek (sk- with keyword)
- Together AI (keyword context)
- Improve OpenAI pattern (sk-proj-, sk-svcacct-, sk-admin-)
- Improve Anthropic pattern (sk-ant-api03-, sk-ant-admin01-)
- Add comprehensive tests with dynamic key construction
- Update documentation with new provider patterns
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* test(security): add comprehensive tests for LLM API key detection
Add extensive test coverage for all 15 LLM provider API key patterns:
- TestLLMKeysInJSONContext: Keys in JSON configuration files
- TestLLMKeysInYAMLContext: Keys in YAML configuration files
- TestLLMKeysInCodeSnippets: Keys in Python/JS/Shell code examples
- TestLLMKeysFalsePositivePrevention: Ensures patterns don't over-match
- TestLLMKeysWithMixedAlphanumeric: Realistic mixed-case key patterns
- TestLLMKeysInLogOutput: Keys exposed in error messages and logs
- TestOpenAIAnthropicImprovedPatterns: All OpenAI/Anthropic variants
- TestAllLLMPatternsExist: Validates all expected patterns are registered
Tests cover:
- OpenAI (sk-, sk-proj-, sk-svcacct-, sk-admin-)
- Anthropic (sk-ant-api03-, sk-ant-admin01-)
- Google AI/Gemini (AIzaSy)
- xAI/Grok (xai-)
- Groq (gsk_)
- HuggingFace (hf_, api_org_)
- Replicate (r8_)
- Perplexity (pplx-)
- Fireworks AI (fw_)
- Anyscale (esecret_)
- Mistral, Cohere, DeepSeek, Together AI (keyword context)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(security): reduce false positives and deduplicate detections
- Add deduplication to AddDetection() to prevent duplicate type+location
- AWS secret key pattern now requires keyword context (aws_secret_access_key=,
AWS_SECRET_KEY:, secretAccessKey:) to avoid matching random base64 in RSA keys
- Azure client secret pattern now requires keyword context (AZURE_CLIENT_SECRET=,
client_secret:, clientSecret:) to avoid false positives
- Update tests to reflect context-required behavior
- Add TestResult_AddDetection_Deduplication test
Before: id_rsa showed 9 detections (including aws_secret_key false positives)
After: id_rsa shows 3 detections (rsa_private_key, private_key, high_entropy)
Before: .env showed 29 detections (many duplicates)
After: .env shows 9 unique detections
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: add sensitive data detection to activity log documentation
- Add sensitive data detection section to activity-log.md
- Document detection metadata structure and filtering options
- Add cross-reference to sensitive-data-detection.md
- Update sidebars.js with sensitive data detection page
- Update intro.md and AGENTS.md references
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs(spec): add specification for sensitive data detection (Spec 026)
- spec.md: Feature specification and requirements
- plan.md: Implementation plan
- tasks.md: Task breakdown
- data-model.md: Data model design
- research.md: Research notes
- quickstart.md: Quick start guide
- contracts/: API contracts
- checklists/: Implementation checklists
- MANUAL_TESTING_PLAN.md: Manual testing guide
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent 55b0861 commit dfe3cbb
67 files changed
Lines changed: 17567 additions & 45 deletions
File tree
- cmd/mcpproxy
- docs
- cli
- configuration
- features
- frontend/src
- types
- views
- internal
- config
- contracts
- httpapi
- runtime
- security
- patterns
- server
- storage
- oas
- specs/026-pii-detection
- checklists
- contracts
- test
- website
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
307 | 382 | | |
308 | 383 | | |
309 | 384 | | |
| |||
394 | 469 | | |
395 | 470 | | |
396 | 471 | | |
| 472 | + | |
| 473 | + | |
397 | 474 | | |
398 | 475 | | |
399 | 476 | | |
0 commit comments