feat(cli): add native gVisor (runsc) sandboxing support#21062
feat(cli): add native gVisor (runsc) sandboxing support#21062scidomino merged 9 commits intogoogle-gemini:mainfrom
Conversation
- Add 'runsc' to the list of valid sandbox commands. - Implement 'runsc' logic in 'start_sandbox', using 'docker run --runtime=runsc'. - Add Linux-only platform checks for 'runsc' execution. - Add validation for 'runsc' and 'docker' binaries when 'runsc' is selected. - Provide a tip for users using '--runtime=runsc' via 'SANDBOX_FLAGS'. - Update documentation and add unit tests for configuration and execution. Co-authored-by: Kartik Angiras <angiraskartik@gmail.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces native support for gVisor (runsc) as a sandboxing option within the Gemini CLI, enhancing process isolation for Linux users. By explicitly configuring Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces native support for gVisor (runsc) sandboxing, which is a great enhancement for security on Linux systems. However, it contains a high-severity command injection vulnerability in the proxy container startup logic due to unsanitized string concatenation in a shell command, which should be addressed by using array-based argument passing for process spawning. Additionally, there is a suggestion to address code duplication in validation logic for improved maintainability, which is supported by the rule regarding trusting internally managed configurations.
…pport - Refactor proxy container command to use structured argument array and disable shell execution to prevent command injection. - Remove redundant platform check for runsc in sandbox.ts (handled in config). - Update and clean up corresponding unit tests.
Resolved conflicts to include both gVisor (runsc) and LXC sandboxing: - Added both 'runsc' and 'lxc' to valid sandbox commands - Updated SandboxConfig type to support both options - Combined sandbox.ts logic to handle both lxc and runsc paths - Merged documentation sections for both sandbox types - Updated test expectations to include both commands
|
@scidomino PTAL |
|
This may take a while since I've never set up gvisor on my machine before. |
|
Thanks for the PR adding native gVisor sandboxing support! It looks great overall, especially the secure refactor of the proxy container spawn logic to use I have a couple of minor suggestions before we merge:
Other than that, the platform checks, binary requirements, and test coverage look excellent. Please let me know if you have any questions! |
|
Hi @scidomino, thanks for the review! Removed the migration tip and relevant test cases. PTAL! |
|
Hi @dtometzki, thanks for raising this! You're not doing anything wrong — this is a known limitation when using Recommended fix: Switch to Docker when you need IDE integration Also worth noting — the error message you're seeing is unfortunately misleading. It's not an issue with your extension setup, but rather a known incompatibility between gVisor's network stack and the IDE connection mechanism. We should improve that message to make this clearer. |
…i#21062) Co-authored-by: Zheyuan <zlin252@emory.edu> Co-authored-by: Kartik Angiras <angiraskartik@gmail.com>
…i#21062) Co-authored-by: Zheyuan <zlin252@emory.edu> Co-authored-by: Kartik Angiras <angiraskartik@gmail.com>
…i#21062) Co-authored-by: Zheyuan <zlin252@emory.edu> Co-authored-by: Kartik Angiras <angiraskartik@gmail.com>
…i#21062) Co-authored-by: Zheyuan <zlin252@emory.edu> Co-authored-by: Kartik Angiras <angiraskartik@gmail.com>

Summary
This PR adds native support for gVisor (via
runsc) as a sandboxing provider. Users on Linux can run Gemini CLI with stronger process isolation by leveraging gVisor's user-space kernel.runsc is not auto-detected—it must be explicitly set (e.g.
GEMINI_SANDBOX=runscorsandbox: "runsc"). If you currently use Docker with custom args such asSANDBOX_FLAGS="--runtime=runsc", consider switching to the native runsc support instead.Details
runscto theSandboxConfigcommand type union andVALID_SANDBOX_COMMANDS.sandbox: "runsc"is set, the CLI runsdocker run --runtime=runsc ...; no auto-detection—runsc is used only when explicitly configured.config.commandfor env propagation.SANDBOX_FLAGScontains--runtime=runscbut the sandbox command is plaindocker, the CLI logs a tip to use native runsc upport (sandbox: "runsc") instead.docs/cli/sandbox.md(setup, prerequisites, install/configure/verify) and README to state that runsc is not auto-detected.packages/cli/src/config/sandboxConfig.test.tsandpackages/cli/src/utils/sandbox.test.ts.Related Issues
Fixes #15875
How to Validate
npm run buildnpx vitest run packages/cli/src/config/sandboxConfig.test.ts packages/cli/src/utils/sandbox.test.ts(ornpm test -w @google/gemini-cli -- src/config/sandboxConfig.test.ts src/utils/sandbox.test.ts)GEMINI_SANDBOX=runsc gemini "your prompt".--runtime=runscin the spawn args).Pre-Merge Checklist