Security hardening: fix auth bypass, SSRF, MCP vulnerabilities (issue #68)#70
Open
janhilgard wants to merge 3 commits intowaybarrios:mainfrom
Open
Security hardening: fix auth bypass, SSRF, MCP vulnerabilities (issue #68)#70janhilgard wants to merge 3 commits intowaybarrios:mainfrom
janhilgard wants to merge 3 commits intowaybarrios:mainfrom
Conversation
…rrios#68) Fix 17 security issues from comprehensive security audit: CRITICAL: - Add auth + rate limiting to Anthropic /v1/messages endpoints - Remove skip_security_validation bypass from MCP config - Add SSRF protection (_validate_url_safety) to image/video downloads HIGH: - Remove local file path traversal from process_image/video_input - Change trust_remote_code default to False (SimpleEngine, BatchedEngine, MLLM) - Add --trust-remote-code CLI flag for explicit opt-in - Route /v1/mcp/execute through ToolSandbox validation - Remove allow_unsafe bypass from MCPCommandValidator - Add interpreter arg validation (-c, -e) to MCP security - Add newline/CR injection detection to MCP patterns MEDIUM: - Add 100MB audio upload size limit - Add 10K char TTS input length limit - Change default host from 0.0.0.0 to 127.0.0.1 - Add max_tokens upper bound (128K) in SamplingParams - Remove CWD config paths (./mcp.json) from MCP search - Block high-risk MCP tools instead of just warning - Reject unknown STT/TTS models instead of passing through LOW: - Add periodic cleanup of stale clients in rate limiter - Sanitize exception details in error responses (500s) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests now verify that removed features (allow_unsafe, skip_security_validation) are properly rejected, and that high-risk tools raise MCPSecurityError instead of just logging a warning. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests for process_image_input and process_video_input updated to verify that local file paths are properly rejected (path traversal prevention). Co-Authored-By: Claude Opus 4.6 <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
Comprehensive security hardening addressing 17 of the 25 vulnerabilities identified in #68. This PR fixes all actionable items in a single commit.
CRITICAL fixes:
verify_api_key+check_rate_limitdependencies to/v1/messages,/v1/messages/count_tokens,/v1/status,/v1/cache/stats,/v1/cacheskip_security_validationbypass: Removed the field entirely fromMCPServerConfig— security validation always runs_validate_url_safety()that blocks private IPs, localhost, link-local, and cloud metadata endpoints beforedownload_image()/download_video()HIGH fixes:
Path.exists()local file checks fromprocess_image_input()/process_video_input()— API only accepts URLs and base64trust_remote_code=Truedefault: Changed toFalseinSimpleEngine,BatchedEngine, andMLXMultimodalLM; added--trust-remote-codeCLI flag for explicit opt-in/v1/mcp/executesandbox bypass: Now routes throughToolSandbox.validate_tool_execution()before executingallow_unsafebypass: Removedallow_unsafeparameter and all bypass code fromMCPCommandValidator${}expansion patterns to dangerous command/arg patterns; added interpreter argument validation (-c,-e,--eval)MEDIUM fixes:
127.0.0.1with warning when0.0.0.0used without--api-keySamplingParams.__post_init__()./mcp.jsonand./mcp.yamlfrom search paths (only~/.config/now)_check_high_risk_tool()to raiseMCPSecurityErrorinstead of just loggingLOW fixes:
detail=str(e)with"Internal server error"in 500 responsesNOT included (separate PRs):
Test plan
/v1/messagesreturns 401 without API key when--api-keyis sethttp://169.254.169.254/andhttp://localhost/process_image_input()MCPServerConfig(skip_security_validation=True)raisesTypeError--trust-remote-codeflag is required for models needing ituvx black vllm_mlx/— passesCloses #68
🤖 Generated with Claude Code