fix(security): harden MCP client and scanner against untrusted input#7
Merged
fix(security): harden MCP client and scanner against untrusted input#7
Conversation
- Bound io.ReadAll with LimitReader in HTTP and SSE transports to prevent memory exhaustion DoS - Validate SSE endpoint URLs against base origin to prevent SSRF attacks - Prevent symlink traversal in skill directory scanning with EvalSymlinks and path containment checks - Parse --control-server-H headers into ControlServerConfig to fix unused flag - Redact query parameters from URLs and sensitive args in debug log output - Add mutex to protect stdio stderr slice from data race - Extract shared HTTP error types to internal/httperrors to eliminate duplication - Expand secret prefix detection with 18 known API key patterns and entropy heuristic - Thread configurable timeout to session.call instead of hard-coded 30 seconds - Remove unused --mcp-oauth-tokens-path flag Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Export IsPath and RedactedValue from redact package for reuse - Remove duplicate isPath function from mcpclient/sanitize - Use redact.RedactedValue instead of hardcoded magic strings - Pre-lowercase secret prefixes to avoid repeated ToLower in loop - Cap stderr line accumulation at 10000 to prevent memory exhaustion Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
io.ReadAll()withLimitReaderin HTTP/SSE transports to prevent memory exhaustion DoS from malicious MCP serversnet/urlparsing to prevent SSRF attacksfilepath.EvalSymlinks()and path containment checks--control-server-Hheaders intoControlServerConfig(flag was defined but never wired up)sync.Mutexto protect stdio stderr slice from data raceClientError,NonRetryableError,SanitizeBodySnippet) tointernal/httperrors/to eliminate duplication between upload and analysis packages--server-timeoutthrough tosession.call()instead of hard-coded 30s--mcp-oauth-tokens-pathflag (dead code)Test plan
go test -race ./...)isWithinBaseboundary checkshttperrorspackagemake lintpasses with 0 issuesmake buildsucceeds🤖 Generated with Claude Code