Summary
The shell_escape() functions in the CLI (crates/openshell-cli/src/run.rs, line 1787) and core (crates/openshell-core/src/forward.rs, line 474) use single-quote wrapping but do not reject null bytes or newlines.
In contrast, the server-side shell_escape() at crates/openshell-server/src/grpc.rs:3493 correctly rejects these characters via reject_control_chars().
A null byte can truncate a C-level shell parse, and newlines can break out of a single-quoted context when the command traverses multiple interpretation layers (e.g., SSH remote shell + bash -lc).
Impact
- Severity: Medium
- The CLI's
shell_escape is used in ProxyCommand construction (ssh.rs:117-122), doctor_exec (run.rs:1664-1665), and sync commands (ssh.rs:474-476, 544-545, 613-623).
Proposed Fix
Add null byte, newline, and carriage return rejection to both shell_escape functions, matching the server's stricter implementation. Return Result<String, ...> instead of String and propagate the error.
Note: This is related to #556 (structured protocol) but is a narrower, independently fixable issue.
Summary
The
shell_escape()functions in the CLI (crates/openshell-cli/src/run.rs, line 1787) and core (crates/openshell-core/src/forward.rs, line 474) use single-quote wrapping but do not reject null bytes or newlines.In contrast, the server-side
shell_escape()atcrates/openshell-server/src/grpc.rs:3493correctly rejects these characters viareject_control_chars().A null byte can truncate a C-level shell parse, and newlines can break out of a single-quoted context when the command traverses multiple interpretation layers (e.g., SSH remote shell +
bash -lc).Impact
shell_escapeis used inProxyCommandconstruction (ssh.rs:117-122),doctor_exec(run.rs:1664-1665), and sync commands (ssh.rs:474-476, 544-545, 613-623).Proposed Fix
Add null byte, newline, and carriage return rejection to both
shell_escapefunctions, matching the server's stricter implementation. ReturnResult<String, ...>instead ofStringand propagate the error.Note: This is related to #556 (structured protocol) but is a narrower, independently fixable issue.