Skip to content

fix(sandbox): pass proxy env vars to seatbelt sandbox process#20788

Closed
aishop-lab wants to merge 1 commit intogoogle-gemini:mainfrom
aishop-lab:fix/sandbox-proxy-env-19187
Closed

fix(sandbox): pass proxy env vars to seatbelt sandbox process#20788
aishop-lab wants to merge 1 commit intogoogle-gemini:mainfrom
aishop-lab:fix/sandbox-proxy-env-19187

Conversation

@aishop-lab
Copy link
Copy Markdown

Summary

Fixes #19187

  • The sandboxEnv object with HTTP_PROXY/HTTPS_PROXY env vars is created when GEMINI_SANDBOX_PROXY_COMMAND is set (line 136-151), but was never passed to the spawn() call for the sandbox-exec process (line 194)
  • Sandboxed commands could not see proxy configuration, making the *-proxied seatbelt profiles unusable
  • Fix: add env: sandboxEnv to the spawn options, matching how the Docker sandbox path already passes proxy vars via --env flags (lines 399-408)

Test plan

  • All 8 existing sandbox tests pass
  • ESLint and Prettier checks pass
  • Manual test: run with GEMINI_SANDBOX_PROXY_COMMAND and SEATBELT_PROFILE=permissive-proxied, verify curl commands inside sandbox respect proxy

The sandboxEnv object with HTTP_PROXY/HTTPS_PROXY env vars is created
when GEMINI_SANDBOX_PROXY_COMMAND is set, but was never passed to the
sandbox-exec spawn call. This caused sandboxed commands to not see
proxy configuration, making the *-proxied seatbelt profiles unusable.

Fix: pass env: sandboxEnv to spawn() so proxy env vars reach the
sandboxed process. This matches the Docker sandbox path which already
passes proxy vars via --env flags.

Fixes google-gemini#19187
@aishop-lab aishop-lab requested a review from a team as a code owner March 1, 2026 20:54
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 addresses a critical issue where proxy environment variables were not being correctly applied to sandboxed processes. By ensuring that the 'sandboxEnv' object is passed during process creation, it resolves a limitation that prevented sandboxed commands from respecting proxy configurations, thereby enabling the proper functioning of proxy-dependent sandbox profiles.

Highlights

  • Proxy Environment Variables: The 'sandboxEnv' object, containing 'HTTP_PROXY' and 'HTTPS_PROXY' environment variables, was being created but not passed to the 'spawn()' call for the 'sandbox-exec' process.
  • Sandbox Functionality: This oversight prevented sandboxed commands from correctly utilizing proxy configurations, rendering '*-proxied' seatbelt profiles unusable.
  • Fix Implementation: The fix involves explicitly adding 'env: sandboxEnv' to the 'spawn' options, aligning with how Docker sandbox paths already handle proxy variable propagation.
Changelog
  • packages/cli/src/utils/sandbox.ts
    • Added the 'env: sandboxEnv' option to the 'spawn' call for the 'sandbox-exec' process.
Activity
  • All 8 existing sandbox tests have passed.
  • ESLint and Prettier checks have passed.
  • A manual test plan is outlined to verify proxy functionality within the sandbox using 'GEMINI_SANDBOX_PROXY_COMMAND' and 'SEATBELT_PROFILE=permissive-proxied'.
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.

@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 1, 2026

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.

@gemini-cli gemini-cli bot added the area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt label Mar 1, 2026
Copy link
Copy Markdown
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 addresses a bug where proxy environment variables were not being passed to the macOS sandbox-exec process. The change correctly adds the env: sandboxEnv option to the spawn call, ensuring that proxy settings configured via GEMINI_SANDBOX_PROXY_COMMAND are respected. This aligns the behavior of the seatbelt sandbox with the Docker-based sandbox and fixes the functionality for proxied profiles on macOS.

@aishop-lab
Copy link
Copy Markdown
Author

I have signed the CLA. Could you please re-check? All commits use the same email (mananp8114@gmail.com) that is linked to my signed CLA.

@aishop-lab
Copy link
Copy Markdown
Author

Hey — just wanted to flag that this came up in the context of #20397 (the network proxy PR). The proxy layer sets up HTTP_PROXY/HTTPS_PROXY vars through setupProxyEnvironment(), but right now those vars never actually make it into the sandboxed child process since spawn() only gets {stdio: 'inherit'} without the env.

Seatbelt still enforces at the kernel level so the sandbox itself isn't broken, but anything inside it that relies on proxy env vars to route traffic just silently does nothing. Small fix but it unblocks the proxy integration path.

Happy to address any review feedback!

@aishop-lab
Copy link
Copy Markdown
Author

cc @gsquared94 — this fixes the proxy env vars not reaching seatbelt sandbox processes (issue #19187). Small change but it's a blocker for the proxy integration path in #20397. Would appreciate a look when you get a chance!

@gemini-cli
Copy link
Copy Markdown
Contributor

gemini-cli bot commented Mar 16, 2026

Hi there! Thank you for your interest in contributing to Gemini CLI.

To ensure we maintain high code quality and focus on our prioritized roadmap, we have updated our contribution policy (see Discussion #17383).

We only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. All other community pull requests are subject to closure after 14 days if they do not align with our current focus areas. For this reason, we strongly recommend that contributors only submit pull requests against issues explicitly labeled as 'help-wanted'.

This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding and for being part of our community!

@gemini-cli gemini-cli bot closed this Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MacOS sandbox ignores proxy configuration

2 participants