Skip to content

Ensure shellExecutionService.ts respects enableInteractiveShell: false and implements high-fidelity native bridge stability by handling non-UTF-8 bytes in the string serialization layer or when the buffer exceeds heap limits for string conversion #27419

Description

@stevescherer-sherpa

What happened?

Describe the Bug

We have identified three critical issues in the ShellExecutionService that affect stability, correctness, and security in automated or non-interactive environments (such as agent loops):

  1. Hangs in Non-Interactive Loops: When enableInteractiveShell: false is set, the terminal environment is not fully restricted. Pagers (like less) and terminal colorizers can still trigger and block execution indefinitely waiting for manual user keypresses.
  2. Native Bridge Crashes / OOM on Large Outputs: When a command produces a high-volume telemetry surge (e.g., >10MB), converting the massive buffer to string all at once in the native TTY bridge or child process stream triggers process-level segmentation faults or heap overflows.
  3. Security Leak (GIT_CONFIG_ Bypass)*: In non-interactive mode, GIT_CONFIG_* environment variables are bypassed and restored directly from raw process.env even if they were correctly redacted by the sanitization layer due to sensitive content (e.g., GitHub OAuth tokens).

Expected Behavior

  1. Non-interactive configuration should strictly enforce TERM=dumb, PAGER=cat, and GIT_PAGER=cat to prevent blocking pagers.
  2. Output streams should be processed incrementally in stable 1MB chunks (without truncating or discarding data) to maintain native bridge stability and prevent OOMs.
  3. Environment variable sanitization should be respected for all variables, including GIT_CONFIG_*, without any bypass loops.

Additional Context

We have prepared a complete fix for this including robust unit tests for chunking and split UTF-8 boundary decoding, and a native PTY integration test harness. I will link a Pull Request shortly.

What did you expect to happen?

Expected Behavior

  1. Non-interactive configuration should strictly enforce TERM=dumb, PAGER=cat, and GIT_PAGER=cat to prevent blocking pagers.
  2. Output streams should be processed incrementally in stable 1MB chunks (without truncating or discarding data) to maintain native bridge stability and prevent OOMs.
  3. Environment variable sanitization should be respected for all variables, including GIT_CONFIG_*, without any bypass loops.

Client information

\u2502 About Gemini CLI                                                                                               \u2502
\u2502                                                                                                                \u2502
\u2502 CLI Version                            0.45.0-nightly.20260521.g854f811be-git.3cc7e5b                          \u2502
\u2502 Git Commit                             3cc7e5b                                                                 \u2502
\u2502 Model                                  Auto (Gemini 3)                                                         \u2502
\u2502 Sandbox                                no sandbox                                                              \u2502
\u2502 OS                                     linux  

Login information

No response

Anything else we need to know?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status
    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions