Fix: Block Shell tool regex denylist bypass leading to command injection (CVE-2026-2256)#880
Fix: Block Shell tool regex denylist bypass leading to command injection (CVE-2026-2256)#880alcholiclg merged 4 commits intomainfrom
Conversation
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 delivers a critical security update by fixing a command injection vulnerability in the shell execution tool. The core change involves migrating shell command execution to a Docker-isolated sandbox environment, which provides a stronger security boundary than previous regex-based filtering. Additionally, the handling of shell commands has been refined to automatically wrap complex commands for safer execution, and related project configurations and documentation have been updated to reflect these architectural changes. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
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 refactors the shell execution mechanism by replacing a regex-based denylist with a Docker sandbox isolation model, effectively mitigating host-level command injection (CVE-2026-2256). However, the implementation introduces new security risks, specifically the lack of authentication for the Jupyter Kernel Gateway within the sandbox, which allows unauthenticated code execution, and excessively high tool call timeouts that could lead to Denial of Service. Additionally, there are general issues related to timeout consistency and hardcoded mirror configurations that could impact maintainability and portability.
| RUN sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources \ | ||
| && apt-get update -o Acquire::Retries=5 \ | ||
| && apt-get install -y --no-install-recommends \ | ||
| curl \ | ||
| git \ | ||
| build-essential \ | ||
| && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ | ||
| && apt-get install -y --no-install-recommends nodejs \ | ||
| && apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Configure npm to use a Chinese mirror. Comment out this line if not needed. | ||
| RUN npm config set registry https://registry.npmmirror.com/ | ||
|
|
||
| # Install Jupyter kernel gateway (required by sandbox) | ||
| RUN pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com \ | ||
| jupyter_kernel_gateway \ |
There was a problem hiding this comment.
The Dockerfile hardcodes the use of specific mirror registries (e.g., mirrors.aliyun.com for Debian, npm, and PyPI). While this might speed up builds in certain network environments, it reduces the portability of the Docker image and might not be suitable for all users or organizations with different network configurations or security policies. Consider making these mirror configurations configurable via build arguments or environment variables, or removing them to rely on official sources by default, as suggested in the comments.
Change Summary
Fixes CVE-2026-2256: Shell tool command execution could be abused via regex denylist bypass when using subprocess.run(..., shell=True).
Mitigates by moving shell execution into an isolated Docker sandbox, preventing host-level command execution even if filtering is bypassed.
Related issue number
Checklist
pre-commit installandpre-commit run --all-filesbefore git commit, and passed lint check.