Add anonymous sandbox for unauthenticated MCP requests#44
Conversation
PR SummaryHigh Risk Overview Tool behavior is gated for anonymous sessions: write/identity-affecting tools (e.g., MCP resources now surface anonymous-aware payloads (e.g., Reviewed by Cursor Bugbot for commit 9d9fb73. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
Reviewed by Cursor Bugbot for commit 9d9fb73. Configure here.
| default: | ||
| return "" | ||
| } | ||
| } |
There was a problem hiding this comment.
Duplicated inferFederationProvider diverges between middleware and handler
High Severity
inferFederationProvider is duplicated across mcp_auth.go and tools_lifecycle.go with divergent logic. The middleware version matches both "claude" and "anthropic" for the anthropic provider, but the handler version only matches "claude". For agentType = "anthropic" with multiple federation providers, hasConfiguredFederationCredential returns true (bypassing anonymous session creation), but the handler's configuredFederationCredential fails to resolve a provider, resulting in a "missing user token" error. configuredFederationProviders is similarly duplicated with different strings.TrimSpace semantics.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 9d9fb73. Configure here.
| entry.minuteCount++ | ||
| entry.hourCount++ | ||
| return true | ||
| } |
There was a problem hiding this comment.
Anonymous rate limiter entries never evicted, unbounded growth
Medium Severity
The anonymousAccessLimiter map (entries) grows without bound because entries are never removed. Window counters reset on new time windows, but the map keys (one per unique client IP) accumulate indefinitely. In production, this is an unbounded memory leak proportional to the number of distinct client addresses seen over the process lifetime.
Reviewed by Cursor Bugbot for commit 9d9fb73. Configure here.
| return host | ||
| } | ||
| return strings.TrimSpace(r.RemoteAddr) | ||
| } |
There was a problem hiding this comment.
Rate limit keyed on spoofable X-Forwarded-For header
Medium Severity
clientAddress trusts the X-Forwarded-For header directly, which clients can trivially spoof. An anonymous user can bypass the per-IP rate limit entirely by rotating this header value on each request, defeating the anonymous sandbox rate limiting protection.
Reviewed by Cursor Bugbot for commit 9d9fb73. Configure here.


Summary
evalops_check_actionavailable in dry-run modeTesting
go test ./internal/agentmcp ./internal/http -count=1go test ./... -count=1GOTOOLCHAIN=go1.26.0 go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest run ./...