fix(security): address MCP security findings (MCPSafe Grade F)#26954
Draft
gemini-cli[bot] wants to merge 1 commit into
Draft
fix(security): address MCP security findings (MCPSafe Grade F)#26954gemini-cli[bot] wants to merge 1 commit into
gemini-cli[bot] wants to merge 1 commit into
Conversation
This PR addresses high and medium severity security findings related to MCP server integration, as reported by MCPSafe. ### Changes: 1. **Shell Heuristics Enforcement**: Updated `PolicyEngine` to apply shell heuristics (e.g., redirection detection) to any tool containing a `command` argument, not just those explicitly named in `SHELL_TOOL_NAMES`. This prevents security bypasses where MCP tools executing shell commands could skip safety checks. 2. **MCP Output Sanitization**: Implemented delimiters and HTML escaping for MCP tool text and resource outputs. This prevents prompt injection attacks where malicious tool output could be mistaken for system instructions by the LLM. 3. **Default Folder Trust**: Enabled folder trust by default in the CLI configuration. This ensures that the CLI verifies workspace trust before executing sensitive operations like loading local stdio MCP servers from project configuration. 4. **Type Safety**: Updated `McpResourceBlock` type to include the `uri` property, aligning with the MCP specification and fixing a TypeScript compilation error. These changes significantly harden the gemini-cli against common attack vectors in the MCP ecosystem. cc @mcpsafe-gh for visibility on the fixes. cc @google-gemini-mcp-experts Labels: bot-fix, area/security, kind/bug
|
Size Change: +674 B (0%) Total Size: 34.1 MB
ℹ️ View Unchanged
|
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.
fix(security): address MCP security findings (MCPSafe Grade F)
This PR addresses high and medium severity security findings related to MCP server integration, as reported by MCPSafe.
Changes:
PolicyEngineto apply shell heuristics (e.g., redirection detection) to any tool containing acommandargument, not just those explicitly named inSHELL_TOOL_NAMES. This prevents security bypasses where MCP tools executing shell commands could skip safety checks.McpResourceBlocktype to include theuriproperty, aligning with the MCP specification and fixing a TypeScript compilation error.These changes significantly harden the gemini-cli against common attack vectors in the MCP ecosystem.
cc @mcpsafe-gh for visibility on the fixes.
cc @google-gemini-mcp-experts
Labels: bot-fix, area/security, kind/bug