feat(proxy,mcp): tool argument and network response DLP hardening#33
Merged
nnemirovsky merged 10 commits intomainfrom Apr 14, 2026
Merged
feat(proxy,mcp): tool argument and network response DLP hardening#33nnemirovsky merged 10 commits intomainfrom
nnemirovsky merged 10 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two new governance layers for data loss prevention.
ExecInspector (MCP gateway): structural inspection of tool arguments for exec-like tools. Detects trampolines (
bash -c,python -c), dangerous commands (rm -rf /,chmod 777,curl | sh, fork bombs), env overrides (GIT_SSH_COMMAND,LD_PRELOAD), and shell metacharacters. Runs between ContentInspector and the upstream call. Default glob patterns are anchored to the MCP__separator to avoid matching tools likeshellcheckorshellharden.Response DLP (HTTPS MITM): per-response scanning of buffered response bodies and headers using
InspectRedactRuleregexes from the policy store. Distinct from phantom token stripping, which protects outbound requests. This protects the agent from seeing real credentials that upstreams leak in responses.Key design points
sluice policy add redact <pattern> --replacement "...", Telegram/policy redact <pattern> [replacement], and HTTP APIPOST /api/ruleswithverdict: "redact". TOML import/export continues to work via[[redact]]blocks. SIGHUP reloads rebuild the engine and atomically swap viaatomic.Pointer.command,cmd,script,code, etc.), reconstructed argv (command+ joinedargs), smuggle slots (input,stdin,body,data,payload), and recursive descent into nested maps up to depth 8. Prose slots (description,notes,comment) are excluded to avoid false positives.io.LimitReadercapped atmaxProxyBody(16 MiB). Post-decompression size check as the final cap.Command/Argsare caught.exec_blockevents include only the category (trampoline, dangerous_cmd, env_override, metachar), never the raw match. Prevents audit logs from leaking credentials embedded in blocked payloads.Known limitation: streaming responses
Responses with
Content-Type: text/event-streamor bodies exceeding go-mitmproxy'sStreamLargeBodies(5 MiB) enter streaming mode, which skips the bufferedResponsecallback. DLP scanning is not applied to these responses. The current mitigation is a one-per-connection WARNING log when DLP rules are configured but a response streams. Proper stream-aware DLP (chunk-by-chunk regex with overlap buffering and mid-stream decompression) is listed in the plan's Future work.Wiring
cmd/sluice/main.goandcmd/sluice/mcp.go: constructmcp.NewExecInspector(nil)with defaults and pass intoGatewayConfig.ExecInspector.internal/proxy/server.go: loadInspectRedactRulesfrom the store at startup, propagate toSluiceAddon.SetRedactRules.UpdateInspectRulesreloads on SIGHUP.SluiceAddon.Response: runs OAuth phantom swap first, then DLP scan.Scope notes
The review phase expanded beyond the plan's original 6 tasks. Additions included compression bomb defense, stacked Content-Encoding support, deflate zlib wrapping, split-argv reconstruction, case-insensitive slots, wrapped schema recursion, chmod setuid coverage, combined short-flag trampoline detection, and CLI/Telegram redact commands. All additions are driven by review findings (phase 1 through 4 plus 6 codex iterations). See
docs/plans/completed/20260405-tool-network-dlp-hardening.mdfor the full task breakdown.