Skip to content

feat: add strict seatbelt profiles and remove unusable closed profiles#18876

Merged
SandyTao520 merged 2 commits intomainfrom
st/sandbox
Feb 12, 2026
Merged

feat: add strict seatbelt profiles and remove unusable closed profiles#18876
SandyTao520 merged 2 commits intomainfrom
st/sandbox

Conversation

@SandyTao520
Copy link
Contributor

@SandyTao520 SandyTao520 commented Feb 12, 2026

Summary

Add new strict-open and strict-proxied seatbelt sandbox profiles that restrict both file reads and writes to the working directory. Remove permissive-closed and restrictive-closed profiles that block all network, making the CLI unusable.

Details

Existing restrictive-* profiles use (allow file-read*) which allows reading the entire filesystem. The new strict profiles whitelist reads to only TARGET_DIR, essential HOME dotfiles (.gemini, .npm, .cache, .nvm, .config), and system paths (/usr, /bin, /Library, etc.). Uses (allow file-read-metadata) globally for Node.js path traversal without exposing file contents.

The *-closed profiles block all outbound network which prevents API calls entirely — removed as unusable.

Related Issues

#18007

How to Validate

  1. SEATBELT_PROFILE=strict-open gemini — verify CLI starts and works
  2. Ask the model to run ls ~ — should get "Operation not permitted"
  3. Ask the model to run ls . — should work normally
  4. npx vitest run packages/cli/src/utils/sandbox.test.ts packages/cli/src/utils/sandboxUtils.test.ts — 25 tests pass

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@SandyTao520 SandyTao520 requested a review from a team as a code owner February 12, 2026 03:57
@gemini-cli
Copy link
Contributor

gemini-cli bot commented Feb 12, 2026

Hi there! Thank you for your contribution to Gemini CLI.

To improve our contribution process and better track changes, we now require all pull requests to be associated with an existing issue, as announced in our recent discussion and as detailed in our CONTRIBUTING.md.

This pull request is being closed because it is not currently linked to an issue. Once you have updated the description of this PR to link an issue (e.g., by adding Fixes #123 or Related to #123), it will be automatically reopened.

How to link an issue:
Add a keyword followed by the issue number (e.g., Fixes #123) in the description of your pull request. For more details on supported keywords and how linking works, please refer to the GitHub Documentation on linking pull requests to issues.

Thank you for your understanding and for being a part of our community!

@gemini-cli gemini-cli bot closed this Feb 12, 2026
@gemini-cli
Copy link
Contributor

gemini-cli bot commented Feb 12, 2026

Hi @SandyTao520, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this.

We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines.

Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed.

Thank you for your understanding and for being a part of our community!

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @SandyTao520, 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 significantly refines the macOS seatbelt sandbox profiles for the CLI, prioritizing security and usability. It introduces new 'strict' profiles that enforce much tighter controls over file system access, limiting reads and writes to only necessary directories and files. Concurrently, it removes older 'closed' profiles that were impractical due to their complete network blocking. These changes aim to provide a more secure and functional sandboxing environment for the application.

Highlights

  • New Strict Seatbelt Profiles: Introduced strict-open and strict-proxied macOS seatbelt sandbox profiles to enhance security by significantly restricting file system access.
  • Removed Unusable Profiles: Deprecated and removed permissive-closed and restrictive-closed profiles, which blocked all network traffic and rendered the CLI unusable.
  • Granular File System Access: The new strict profiles whitelist file reads to the working directory, essential HOME dotfiles, and critical system paths, moving away from broad file-read* permissions.
  • Node.js Path Traversal: Added (allow file-read-metadata) globally to support Node.js module resolution and path traversal without exposing file contents.
  • Network Configuration: The strict-open profile allows all outbound network traffic, while strict-proxied specifically routes outbound traffic through a proxy on localhost:8877.
Changelog
  • packages/cli/src/utils/sandbox-macos-permissive-closed.sb
    • Removed the profile as it was deemed unusable due to blocking all network traffic.
  • packages/cli/src/utils/sandbox-macos-restrictive-closed.sb
    • Renamed to sandbox-macos-strict-open.sb to reflect its new, stricter file access policies and open network configuration.
    • Updated file read permissions from a broad (allow file-read*) to a highly specific whitelist of directories including the target directory, temporary/cache directories, essential home dotfiles, included directories, and common system paths.
    • Added (allow file-read-metadata) to permit path traversal for Node.js module resolution without granting full file content access.
    • Modified network policy to allow all outbound network traffic, contrasting with the previous 'closed' state.
  • packages/cli/src/utils/sandbox-macos-strict-proxied.sb
    • Added a new seatbelt profile designed for strict file access with proxied outbound network traffic.
    • Configured file read permissions to be highly restrictive, similar to strict-open, allowing access only to specified directories and essential system paths.
    • Included (allow file-read-metadata) for Node.js path traversal.
    • Enabled outbound network traffic specifically through a proxy on localhost:8877.
  • packages/cli/src/utils/sandboxUtils.ts
    • Removed permissive-closed and restrictive-closed from the list of BUILTIN_SEATBELT_PROFILES.
    • Added strict-open and strict-proxied to the list of BUILTIN_SEATBELT_PROFILES.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@SandyTao520 SandyTao520 reopened this Feb 12, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces new, more secure strict-open and strict-proxied seatbelt sandbox profiles for macOS, which significantly improve security by restricting file reads to specific whitelisted paths and removing unusable *-closed profiles. However, the new strict-proxied profile currently allows unnecessary write access to sensitive user configuration files like .gitconfig and .npm. This could be leveraged for sandbox escape and should be addressed for tighter security. Additionally, while outside the scope of this PR, potential command injection vulnerabilities were noted in sandbox.ts and sandboxUtils.ts and are recommended for a separate security-focused PR.

@github-actions
Copy link

github-actions bot commented Feb 12, 2026

Size Change: +5.55 kB (+0.02%)

Total Size: 24.3 MB

Filename Size Change
./bundle/sandbox-macos-permissive-closed.sb 0 B -1.03 kB (removed) 🏆
./bundle/sandbox-macos-restrictive-closed.sb 0 B -3.29 kB (removed) 🏆
./bundle/sandbox-macos-strict-open.sb 4.82 kB +4.82 kB (new file) 🆕
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB +5.02 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 24.3 MB +31 B (0%)
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B

compressed-size-action

@SandyTao520 SandyTao520 requested a review from a team as a code owner February 12, 2026 18:23
@SandyTao520 SandyTao520 added this pull request to the merge queue Feb 12, 2026
Merged via the queue into main with commit 2e91c03 Feb 12, 2026
26 of 27 checks passed
@SandyTao520 SandyTao520 deleted the st/sandbox branch February 12, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants