🔒 [Security] Enforce strong typing on MCP sandbox execution proxy#820
🔒 [Security] Enforce strong typing on MCP sandbox execution proxy#820Zoverions wants to merge 1 commit into
Conversation
The `sandbox_execute` endpoint previously passed arbitrary string arguments directly to the external Sandbox URL, bypassing strict type and payload validation. This commits introduces a Pydantic `SandboxExecutionRequest` model to strictly type check and whitelist allowed `language` inputs (`python`, `javascript`, etc) and explicitly restrict the `code` payload length before the payload is forwarded. A unit test was added to verify the strict language rejection flow.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
🎯 What: Adds strict strong-typing via Pydantic (
⚠️ Risk: The previous approach allowed arbitrary
SandboxExecutionRequest) to thesandbox_executeMCP endpoint, replacing the raw string parameter forwarding.languagestrings and unconstrainedcodepayloads to be blindly proxied to the execution sandbox. Given that the local AST validation was easily bypassed with obfuscation, allowing unvalidated data out of the proxy could lead to unexpected behavior or potential capability escalations if the sandbox parser fails or is abused.🛡️ Solution: Uses a Pydantic model with a
Literaltype to whitelist the supported languages and bounds the payload size. Any request with an unsupported language or oversized payload is rejected locally with aSecurity Halterror before hitting the sandbox proxy layer.PR created automatically by Jules for task 12534127304784554803 started by @Zoverions