## Problem Zed's terminal permission system validates commands using regex patterns against string representations of parsed commands. The `SimpleCommand::to_string()` method in brush-parser preserves the raw lexical form including shell quotes, causing pattern matching to fail on obfuscated commands. For example, all of these are semantically equivalent to `rm -rf /` in POSIX shells, but produced different strings from `to_string()` that bypassed the hardcoded deny pattern `rm\s+(-[rf]+\s+)*/\s*$`: | Input | `extract_commands()` returned | Matched deny pattern? | |---|---|---| | `rm -rf /` | `"rm -rf /"` | ✅ Yes | | `rm -rf '/'` | `"rm -rf '/'"` | ❌ No | | `'rm' -rf /` | `"'rm' -rf /"` | ❌ No | | `r'm' -rf /` | `"r'm' -rf /"` | ❌ No | | `rm -r'f' /` | `"rm -r'f' /"` | ❌ No | | `rm -rf \/` | `"rm -rf \\/"` | ❌ No | Both hardcoded deny patterns (Phase 2, which operates on extracted sub-commands) and user-configured `always_deny` patterns were affected. ## Fix Replace the `simple_command.to_string()` call in `extract_commands_from_simple_command` with manual construction that: 1. Iterates the command name (`word_or_name`) and word arguments from the suffix 2. Normalizes each word by parsing it into `WordPiece`s via `brush_parser::word::parse` 3. Reconstructs the semantic (unquoted) value from each piece: - `Text` — used as-is - `SingleQuotedText` — used as-is (brush-parser already strips the wrapping quotes) - `EscapeSequence` — leading `\` stripped to produce the unescaped character - `AnsiCQuotedText` — used as-is (brush-parser already evaluates `$'...'`) - `DoubleQuotedSequence` / `GettextDoubleQuotedSequence` — inner pieces recursively normalized - `TildePrefix` — preserved as `~` + suffix - `ParameterExpansion` / `CommandSubstitution` / `BackquotedCommandSubstitution` / `ArithmeticExpression` — original source text preserved so patterns like `\$HOME` and `\${HOME}` continue to match 4. Joins normalized words with spaces Falls back to the raw `word.value` if word parsing fails. ## Cross-shell safety The normalization operates on POSIX-parsed ASTs (brush-parser uses POSIX grammar), so it applies POSIX quoting rules. For non-POSIX shells (Nushell, PowerShell, Xonsh, Elvish, etc.) where quoting semantics differ, any mismatch results in false positives (overly cautious denials), never false negatives. This is the correct error direction for a security feature. When brush-parser fails to parse a non-POSIX command, `extract_commands` returns `None` and the existing fallback (raw-string matching with `allow_enabled=false`) handles it. (No release notes because granular tool permissions are still feautre-flagged.) Release Notes: - N/A
Zed
Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Installation
On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).
Other platforms are not yet available:
- Web (tracking issue)
Developing Zed
Contributing
See CONTRIBUTING.md for ways you can contribute to Zed.
Also... we're hiring! Check out our jobs page for open roles.
Licensing
License information for third party dependencies must be correctly provided for CI to pass.
We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:
- Is it showing a
no license specifiederror for a crate you've created? If so, addpublish = falseunder[package]in your crate's Cargo.toml. - Is the error
failed to satisfy license requirementsfor a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to theacceptedarray inscript/licenses/zed-licenses.toml. - Is
cargo-aboutunable to find the license for a dependency? If so, add a clarification field at the end ofscript/licenses/zed-licenses.toml, as specified in the cargo-about book.
Sponsorship
Zed is developed by Zed Industries, Inc., a for-profit company.
If you’d like to financially support the project, you can do so via GitHub Sponsors. Sponsorships go directly to Zed Industries and are used as general company revenue. There are no perks or entitlements associated with sponsorship.