google-gemini / google-gemini/gemini-cli

Policy bypass: shell-wrapper flags skip inner command re-check

Open
#29,202 1 comment 0 reactions 0 assignees View on GitHub
area/enterprise kind/bug priority/p2 status/manual-triage status/need-information
Dominant language
TypeScript
Stars
107k
Forks
14.6k
Avg merge
2d 3h
Merged PRs (30d)
45

Description

## Summary

`stripShellWrapper` only recognizes bare `bash -c` / `powershell [-NoProfile] -Command`. With any extra wrapper flag (`bash -x -c`, `bash --noprofile -c`, `powershell -NoProfile -ExecutionPolicy Bypass -Command`, combined `-xc`), the input comes back unchanged — and the policy engine only re-checks the inner command when stripping changed something. So the inner command escapes all policy scrutiny while the gate sees just `bash` / `powershell`.

Real runs:

- `stripShellWrapper('bash -c "rm -rf /"')` → `'rm -rf /'` (re-checked)
- `stripShellWrapper('bash -x -c "rm -rf /"')` → unchanged (never re-checked)
- `stripShellWrapper('powershell -NoProfile -ExecutionPolicy Bypass -Command "..."')` → unchanged

## Root cause

The wrapper regex enumerates exact flag sequences instead of tolerating the flags each shell accepts before `-c` / `-Command`.

## Expected

Wrapper flags (short clusters incl. combined `-xc`, long options, `-Name value` pairs) are tolerated so the inner command is always what the policy sees. Known residual: `-X value` pairs with a space-separated value on POSIX (`bash -o pipefail -c`) still don't strip.

Contributor guide

Open the contributing guide

Research direction

Start by locating stripShellWrapper and the policy-engine call site that conditionally re-checks the inner command. Read the existing wrapper regex and its tests, then cover extra shell flags, combined short flags, and PowerShell option pairs; done means these forms expose the inner command for policy checks while the stated POSIX -X value case remains a known residual.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.