Skip to content

Expand hardcoded agent terminal security rules#48399

Merged
rtfeldman merged 1 commit intomainfrom
expand-hardcoded-rm-bans
Feb 4, 2026
Merged

Expand hardcoded agent terminal security rules#48399
rtfeldman merged 1 commit intomainfrom
expand-hardcoded-rm-bans

Conversation

@rtfeldman
Copy link
Contributor

@rtfeldman rtfeldman commented Feb 4, 2026

Expands the hardcoded security rules that block dangerous rm commands in the agent terminal tool.

Fixes #37343

New blocked patterns

  • rm -rf $HOME / rm -rf $HOME/ / rm -rf ${HOME} / rm -rf ${HOME}/
  • rm -rf . / rm -rf ./
  • rm -rf .. / rm -rf ../
  • rm -rf ~/ (previously only rm -rf ~ was blocked)

Flag handling improvements

  • Simplified the flag character class from [rRfF] to [rf] since the regex is already compiled with case-insensitive mode — less confusing, same behavior.
  • Added tests verifying that reversed flags (-fr), uppercase (RM -RF), split flags (-r -f), and chained commands all get caught.

Safe commands still allowed

Paths like rm -rf ./build, rm -rf ~/Documents, rm -rf $HOME/Documents, rm -rf ../some_dir, and rm -rf .hidden_dir are not blocked.

Release Notes:

  • Auto-block a wider range of agent terminal commands, e.g. rm -rf $HOME in addition to rm -rf ~

- Block rm -rf $HOME, rm -rf ${HOME}, rm -rf ., rm -rf .., and
  trailing-slash variants of all of the above
- Update existing ~ pattern to also block rm -rf ~/
- Simplify flag character classes from [rRfF] to [rf] since the regex
  is already case-insensitive
- Add comprehensive tests for flag ordering (-fr), uppercase (RM -RF),
  split flags (-r -f), and chained commands
@rtfeldman rtfeldman force-pushed the expand-hardcoded-rm-bans branch from c59fd89 to c581b24 Compare February 4, 2026 20:41
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 4, 2026
@rtfeldman rtfeldman marked this pull request as ready for review February 4, 2026 20:41
@rtfeldman rtfeldman enabled auto-merge (squash) February 4, 2026 20:41
@rtfeldman rtfeldman merged commit 477bb89 into main Feb 4, 2026
34 checks passed
@rtfeldman rtfeldman deleted the expand-hardcoded-rm-bans branch February 4, 2026 20:52
adb-sh pushed a commit to adb-sh/zed that referenced this pull request Feb 5, 2026
Expands the hardcoded security rules that block dangerous `rm` commands
in the agent terminal tool.

### New blocked patterns

- `rm -rf $HOME` / `rm -rf $HOME/` / `rm -rf ${HOME}` / `rm -rf
${HOME}/`
- `rm -rf .` / `rm -rf ./`
- `rm -rf ..` / `rm -rf ../`
- `rm -rf ~/` (previously only `rm -rf ~` was blocked)

### Flag handling improvements

- Simplified the flag character class from `[rRfF]` to `[rf]` since the
regex is already compiled with case-insensitive mode — less confusing,
same behavior.
- Added tests verifying that reversed flags (`-fr`), uppercase (`RM
-RF`), split flags (`-r -f`), and chained commands all get caught.

### Safe commands still allowed

Paths like `rm -rf ./build`, `rm -rf ~/Documents`, `rm -rf
$HOME/Documents`, `rm -rf ../some_dir`, and `rm -rf .hidden_dir` are
**not** blocked.

Release Notes:

- Auto-block a wider range of agent terminal commands, e.g. `rm -rf
$HOME` in addition to `rm -rf ~`
rtfeldman added a commit that referenced this pull request Feb 5, 2026
Expands the hardcoded security rules that block dangerous `rm` commands
in the agent terminal tool.

### New blocked patterns

- `rm -rf $HOME` / `rm -rf $HOME/` / `rm -rf ${HOME}` / `rm -rf
${HOME}/`
- `rm -rf .` / `rm -rf ./`
- `rm -rf ..` / `rm -rf ../`
- `rm -rf ~/` (previously only `rm -rf ~` was blocked)

### Flag handling improvements

- Simplified the flag character class from `[rRfF]` to `[rf]` since the
regex is already compiled with case-insensitive mode — less confusing,
same behavior.
- Added tests verifying that reversed flags (`-fr`), uppercase (`RM
-RF`), split flags (`-r -f`), and chained commands all get caught.

### Safe commands still allowed

Paths like `rm -rf ./build`, `rm -rf ~/Documents`, `rm -rf
$HOME/Documents`, `rm -rf ../some_dir`, and `rm -rf .hidden_dir` are
**not** blocked.

Release Notes:

- Auto-block a wider range of agent terminal commands, e.g. `rm -rf
$HOME` in addition to `rm -rf ~`
naaiyy added a commit to Glass-HQ/Glass that referenced this pull request Feb 16, 2026
Key changes:
- Semantic highlighting support (zed-industries#46356) - major new editor feature
- Edit predictions via Ollama (zed-industries#48233) - local AI edit predictions
- Side-by-side diff: staging/unstaging/restoring on LHS, hunk controls, gutter highlights
- Branch diff fix when committing/changing branches (zed-industries#48388)
- Settings UI: AI tool permissions page (zed-industries#48277)
- Version bump to v0.224 (kept our v0.0.1)
- Close toasts on middle mouse click (zed-industries#48208)
- DAP settings made optional (zed-industries#43647)
- REPL quality of life improvements (zed-industries#47533)
- Mercury accept/reject tracking (zed-industries#48306)
- Toolbar menu and EP menu telemetry (zed-industries#48225, zed-industries#48229)
- lsp::Symbol now includes container_name (zed-industries#46822)
- Nushell/Elvish/Rc always_allow patterns (zed-industries#48395)
- Agent terminal security rules expanded (zed-industries#48399)

Conflict resolution:
- collab/rpc.rs, collab_ui, collab editor_tests: deleted (collab removed)
- vim (yank, replace, test): deleted (vim removed)
- util/shell.rs: deleted (extracted to Obsydian-HQ/gpui)
- GPUI (app.rs, windows/platform.rs, platform_scheduler.rs): deleted (Obsydian)
- editor/items.rs: merged imports (added ExcerptId, ExcerptRange, kept SearchWithinRange)
- lsp_store.rs: added SemanticTokensData import, removed GlobalLogStore/LanguageServerKind
- proto.rs: added SemanticTokens to entity_messages, removed JoinProject/LeaveProject
- lsp_button.rs: kept empty server UI, added is_via_ssh check from upstream
- edit_prediction_button.rs: kept TitleBarItemView import
- vscode_import.rs: added semantic_token_rules, removed helix_mode (not in our struct)
- zed/Cargo.toml: kept v0.0.1

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI: CRITICAL SAFETY HOLE, AGENT CAN RUN rm - rf $HOME/ WITHOUT ANY WARNING!

1 participant