feat(security): add data flow security with agent hook integration (Spec 027)#293
feat(security): add data flow security with agent hook integration (Spec 027)#293
Conversation
…pec 027) Detect and prevent data exfiltration by tracking how data flows between internal tools (Read, databases) and external tools (WebFetch, Slack). Operates in two modes: proxy-only (universal, any agent) and full mode with agent hook integration for intercepting agent-internal tool calls. Key components: - Tool/server classifier with internal/external/hybrid/unknown categories - Content hasher using SHA256 per-field extraction for flow matching - Flow tracker with session-scoped origin recording and edge detection - Policy evaluator with configurable actions (allow/warn/ask/deny) - Session correlator linking agent hook sessions to MCP proxy sessions - Hook CLI commands (install/uninstall/status/evaluate) for Claude Code - POST /api/v1/hooks/evaluate REST endpoint - Activity logging for hook_evaluation and flow_summary event types - Web UI nudge system for hook installation when in proxy-only mode - E2E tests for both proxy-only and hook-enhanced flow detection Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Deploying mcpproxy-docs with
|
| Latest commit: |
ec787a4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8f408303.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://027-data-flow-security.mcpproxy-docs.pages.dev |
…ints Add proper swag annotations to hooks.go and activity.go query params, then regenerate oas/swagger.yaml via make swagger instead of manual edits. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 21685803329 --repo smart-mcp-proxy/mcpproxy-go
|
- Remove unused extractNormalizedArgHashes/extractNormalizedStrings funcs - Use tagged switch instead of if/else chain on decision string - Skip ProxyOnlyDetection test under race detector (pre-existing supervisor race in AddServer/SetConfig path) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code reviewFound 3 issues:
mcpproxy-go/internal/security/flow/tracker.go Lines 80 to 123 in ec787a4
mcpproxy-go/internal/runtime/runtime.go Lines 535 to 570 in ec787a4
mcpproxy-go/internal/runtime/runtime.go Lines 182 to 214 in ec787a4 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
|
Opened #299 as a stacked PR with fixes for the 3 issues identified in the code review:
All 34 flow tests pass with 🤖 Generated with Claude Code |
Summary
mcpproxy hook install/uninstall/status/evaluate) for Claude Code integrationKey Components
internal/security/flow/classifier.go): Categorizes tools/servers as internal, external, hybrid, or unknown using name heuristics and config overridesinternal/security/flow/hasher.go): SHA256 per-field extraction from JSON for content flow matching without storing raw datainternal/security/flow/tracker.go): Session-scoped origin recording and flow edge detection with configurable policiesinternal/security/flow/policy.go): Configurable actions (allow/warn/ask/deny) with graceful degradation in proxy-only mode (ask→warn)internal/security/flow/correlator.go): Links agent hook sessions to MCP proxy sessions via argument hash matchingcmd/mcpproxy/hook_cmd.go): Install/uninstall/status/evaluate commands for Claude Code agent hooksinternal/httpapi/hooks.go):POST /api/v1/hooks/evaluateendpoint for hook event processinghook_evaluationandflow_summaryactivity types with full metadatamcpproxy doctoroutputArchitecture
Test plan
internal/security/flow/...(25 tests),internal/httpapi/...,internal/runtime/...go test -race ./internal/security/flow/...passes cleanlyTestE2E_FlowSecurity_ProxyOnlyDetection)TestE2E_FlowSecurity_HookEnhancedDetection) — verifies deny decision withflow_type=internal_to_external,risk_level=hightest-api-e2e.sh— no regressions (61/71 pass, 10 failures pre-existing)verify-oas-coverage.sh— new endpoint documentedvue-tsc --noEmitpasses cleanly🤖 Generated with Claude Code