Skip to content

Add tool security rules that can't be overridden by settings#48209

Merged
rtfeldman merged 6 commits intomainfrom
hardcode-permissions
Feb 2, 2026
Merged

Add tool security rules that can't be overridden by settings#48209
rtfeldman merged 6 commits intomainfrom
hardcode-permissions

Conversation

@rtfeldman
Copy link
Contributor

@rtfeldman rtfeldman commented Feb 2, 2026

This change introduces hardcoded security rules for the terminal tool that cannot be bypassed by any setting, including always_allow_tool_actions.

Currently Blocked Commands

  • rm -rf / - Recursive deletion of root filesystem
  • rm -rf ~ - Recursive deletion of home directory

These rules are checked before the always_allow_tool_actions global flag, ensuring they can never be bypassed. The rules also check parsed sub-commands, so ls && rm -rf / is also blocked.

Release Notes:

  • Certain known-bad tool uses are now automatically blocked, such as the terminal tool attempting to run rm -rf / or rm -rf ~

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 2, 2026
@zed-industries-bot
Copy link
Contributor

zed-industries-bot commented Feb 2, 2026

Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- Added/Fixed/Improved ...

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against 14dbee3

@rtfeldman rtfeldman force-pushed the hardcode-permissions branch from a979d5b to d28a2d2 Compare February 2, 2026 19:31
@rtfeldman rtfeldman changed the title Add hardcoded security rules that cannot be overridden by settings Add tool security rules that can't be overridden by settings Feb 2, 2026
@rtfeldman rtfeldman force-pushed the hardcode-permissions branch from d28a2d2 to c6521a5 Compare February 2, 2026 19:41
This change introduces hardcoded security rules for the terminal tool that
cannot be bypassed by any setting, including `always_allow_tool_actions`.

Currently blocked commands:
- `rm -rf /` - Recursive deletion of root filesystem
- `rm -rf ~` - Recursive deletion of home directory

These rules are checked BEFORE the `always_allow_tool_actions` global flag,
ensuring they can never be bypassed. The rules also check parsed sub-commands,
so `ls && rm -rf /` is also blocked.

Key changes:
- `HARDCODED_SECURITY_RULES` static contains non-overridable patterns
- `check_hardcoded_security_rules()` runs before any user settings
- Tests updated to use non-blocked commands where appropriate
- New tests verify hardcoded rules cannot be bypassed
@rtfeldman rtfeldman force-pushed the hardcode-permissions branch from c6521a5 to f62f78a Compare February 2, 2026 19:57
@rtfeldman rtfeldman force-pushed the hardcode-permissions branch from 9422c01 to c3ae971 Compare February 2, 2026 21:02
@rtfeldman rtfeldman marked this pull request as ready for review February 2, 2026 22:10
@rtfeldman rtfeldman merged commit b62d73e into main Feb 2, 2026
27 checks passed
@rtfeldman rtfeldman deleted the hardcode-permissions branch February 2, 2026 22:10
rtfeldman added a commit that referenced this pull request Feb 3, 2026
Follow-up to #48209 - those
hardcoded rules are replacing these default settings, which will make
the rules clearer by removing the "override" scenario.

(No release notes because granular tool permissions are still behind a
feature flag.)

Release Notes:

- N/A
@KieranP
Copy link

KieranP commented Feb 5, 2026

So rm -rf /etc/../ then? :-P Ideally, the agent would only allow changes within the working directory, I can't think of any good reason why running agents in my project should modify files/paths outside...

@bbb651
Copy link
Contributor

bbb651 commented Feb 5, 2026

The rm -rf / regex doesn’t match rm -rf --no-preserve-root / nor rm -rf /*, or any other variants LLMs would actually try as rm -rf / doesn’t work on most systems.
(Of course in general this approach can never be exhaustive and I agree that it’s better to have it despite that, this is more critical because it’s likely to fail entirely on the first try)

adb-sh pushed a commit to adb-sh/zed that referenced this pull request Feb 5, 2026
…ustries#48209)

This change introduces hardcoded security rules for the terminal tool
that cannot be bypassed by any setting, including
`always_allow_tool_actions`.

## Currently Blocked Commands

- `rm -rf /` - Recursive deletion of root filesystem
- `rm -rf ~` - Recursive deletion of home directory

These rules are checked **before** the `always_allow_tool_actions`
global flag, ensuring they can never be bypassed. The rules also check
parsed sub-commands, so `ls && rm -rf /` is also blocked.

Release Notes:
- Certain known-bad tool uses are now automatically blocked, such as the
terminal tool attempting to run `rm -rf /` or `rm -rf ~`
adb-sh pushed a commit to adb-sh/zed that referenced this pull request Feb 5, 2026
Follow-up to zed-industries#48209 - those
hardcoded rules are replacing these default settings, which will make
the rules clearer by removing the "override" scenario.

(No release notes because granular tool permissions are still behind a
feature flag.)

Release Notes:

- N/A
rtfeldman added a commit that referenced this pull request Feb 5, 2026
Follow-up to #48209 - those
hardcoded rules are replacing these default settings, which will make
the rules clearer by removing the "override" scenario.

(No release notes because granular tool permissions are still behind a
feature flag.)

Release Notes:

- N/A
@rtfeldman
Copy link
Contributor Author

@KieranP @bbb651 Thanks! I've expanded these in other PRs, and I also just added #48647 to add tests for the scenarios you mentioned (although they were already covered by the follow-up PRs).

naaiyy added a commit to Glass-HQ/Glass that referenced this pull request Feb 16, 2026
Key changes:
- Reduce monomorphizations in GPUI app.rs (zed-industries#48014)
- Entities no longer implement Element directly, go through AnyElement (zed-industries#48217)
- D3D11 resource upload optimization (zed-industries#48282)
- Migrate features.edit_prediction_provider to edit_predictions.provider (zed-industries#48224)
- Make mercury and sweep non-experimental (zed-industries#48227)
- CompanionView consolidation in block_map (zed-industries#48223)
- Show memory used by language servers (zed-industries#48226)
- Settings links open sub pages (zed-industries#48212)
- Tool security rules that can't be overridden (zed-industries#48209)
- Add sweep_ai privacy mode setting (zed-industries#48220)
- Configurable REPL output size limits (zed-industries#47114)
- Fix .editorconfig files in subdirectories (zed-industries#48203)
- Security updates: bytes v1.11.1, jsonwebtoken v10
- Git UI: hide "View on GitHub" for stashes (zed-industries#48271)
- Indent guide fix in tree view with collapsed folders (zed-industries#48194)
- Edit prediction fixes and improvements

Conflict resolution:
- collab/completion.rs, collab/rpc.rs: deleted (collab removed)
- vim/search.rs: deleted (vim removed)
- livekit_api/Cargo.toml: deleted (livekit removed)
- GPUI files: deleted from Glass (handled in Obsydian-HQ/gpui)
- migrations: combined both ours (m_2026_02_06) and upstream (m_2026_02_02, m_2026_02_03)
- project.rs: kept collab functions removed, restored handle_create_file_for_peer for remote dev
- lsp_store.rs: removed collab-only set_language_server_statuses_from_proto
- proto.rs: kept CreateFileForPeer, removed CreateChannel/CreateChannelResponse
- remote_servers.rs: merged import lists (kept native button imports + added Action)

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.

4 participants