Skip to content

fix(shell): workspace lockdown bypass via non-obvious shell redirection #197

Description

@ilhamyunusbaihaqi-png

AgentOS version or commit

v2026.8.2 (commit before d3ef548)

Area

CLI

Reproduction steps

1. Enable workspace lockdown

agentos run --workspace /tmp/workspace --workspace-lockdown

2. Execute command with redirection WITHOUT space before operator

These bypass the lockdown (before fix):

echo malicious>/etc/passwd
cmd 2>/tmp/leak.txt

&/tmp/both.txt
true | cat >/tmp/out.txt
true; echo x >/tmp/out.txt
(echo x) >/tmp/out.txt

Expected behavior

All redirection operators (>, >>, 2>, 2>>, &>, &>>, 1>, 1>>) should be detected regardless of whitespace, and writes outside allowed workspace roots should be blocked with workspace_lockdown reason.

Actual behavior

test_shell_fuzz.py
shell_fix.py
test_shell_approval_policy.py

Redirections without leading whitespace (e.g., echo ok>file vs echo ok > file) were not parsed by _shell_write_targets(), allowing sandbox escape via shell redirection.

Environment

AgentOS: v2026.8.2 - Python: 3.12+ - OS: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: sandboxSandbox isolation, approvals, and execution safetyarea: securitySecurity-sensitive behavior requiring careful handlingpriority: p0Critical: security, data loss, or release-blocking impactstatus: needs triageNeeds severity, ownership, and scope assessmenttype: securityPotential vulnerability or security-sensitive work; follow SECURITY.md

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions