fix(security): sanitize env and redact output in quick commands + remove write-only _pending_messages#1806
Conversation
…ove write-only _pending_messages 1. Quick command exec ran in the gateway process's full environment without env sanitization or output redaction. A quick command like "env" or "printenv" would leak all API keys, OAuth tokens, and bot credentials to the messaging user. Fix: apply _sanitize_subprocess_env() before exec and redact_sensitive_text() on output before returning. 2. GatewayRunner._pending_messages was written on every interrupt (lines 1331-1334) but never read or consumed anywhere. The actual interrupt delivery uses adapter._pending_messages (a separate dict). Removed the write-only accumulation to prevent unbounded growth.
|
Orb Code Review (powered by GLM 5.1 on Orb Cloud) SummaryThis PR fixes two issues:
ArchitectureThe fix plugs a genuine security hole. Quick commands run in the gateway process which holds all provider API keys. Without sanitization, a command like
Defense-in-depth: env sanitization prevents credential injection into child processes; output redaction catches any secrets the command itself generates. IssuesWarning —
This is minor — the function is stable and the import is pragmatic. Not a blocker. Suggestion — The imports are done inside the function body ( Cross-file impact
No changes to the imported modules. No impact on other callers. Assessmentapprove ✅ — Important security fix with good test coverage. The credential leakage was a real vulnerability. The |
|
Merged via PR #23584. Your commits were cherry-picked onto current main with your authorship preserved ( |
Summary
Quick command exec leaks credentials —
type: execquick commands ran viacreate_subprocess_shell()in the gateway process's full environment. Unlike terminal_tool (which uses_sanitize_subprocess_env), quick commands had no env filtering or output redaction. A command likeenvwould return all API keys and bot tokens to the chat.Fix: apply
_sanitize_subprocess_env()before exec andredact_sensitive_text()on output._pending_messageswrite-only memory leak —GatewayRunner._pending_messageswas appended on every interrupt but never read. The actual interrupt delivery usesadapter._pending_messages(separate dict). Removed the dead writes to prevent unbounded growth.Test plan
test_exec_command_does_not_leak_credentials— sets OPENROUTER_API_KEY in env, runsenv, verifies key not in outputtest_exec_command_output_is_redacted— command outputs API key pattern, verifies redacted