Skip to content

fix(sandbox): block $HOME/$PWD shell expansions in workspace allowlist - #82

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/high-severity-issues-89ba
Draft

fix(sandbox): block $HOME/$PWD shell expansions in workspace allowlist#82
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/high-severity-issues-89ba

Conversation

@cursor

@cursor cursor Bot commented Sep 10, 2026

Copy link
Copy Markdown

Summary

HIGH workspace escape that survives open PRs #66/#68/#74 allowlist changes:

With sandbox.enabled + workspace_only, has_path_chars only flagged tokens starting with / ~ .. Concrete trigger on main (a057f0e):

cat $HOME/.shellclaw/auth_tokens.json
cat ${HOME}/.shellclaw/auth_tokens.json
cat $'\x2fetc\x2fpasswd'

/bin/sh expands these to absolute paths; sandbox_exec only unshares + chdirs (no chroot), so the shell tool could read gateway pairing tokens (and other host files) even when the workspace is not colocated with ~/.shellclaw (#79).

PR #68's embedded / scanner treats the slash in $HOME/... as a relative src/foo-style continuation (prev char is alphanumeric), so it does not catch this. PR #74's relative-token check joins workspace/$HOME/..., which does not exist, and leaves the command allowed at the allowlist layer.

Fix

In allowlist_check_shell_command:

  1. Treat $... tokens as path-like.
  2. Expand $HOME / ${HOME} / $PWD / ${PWD} (and ~) before the workspace check.
  3. Fail closed on ANSI-C quoting ($'...') and other $ / command-substitution forms under workspace_only.

Test plan

  • tests/test_allowlist — new test_workspace_only_blocks_home_env_expansion (HOME/PWD/ANSI-C blocked; bare relative notes.txt still allowed)
  • Manual PoC: cat $HOME/.shellclaw/auth_tokens.json now returns blocked=1 with expanded path in the reason
Open in Web View Automation 

cursoragent and others added 2 commits September 10, 2026 11:10
has_path_chars only flagged tokens starting with / ~ ., so workspace_only
skipped cat $HOME/.shellclaw/auth_tokens.json and ANSI-C $'\x2f...' paths.
Expand HOME/PWD forms and fail-closed on other $ expansions before the
workspace realpath check. Namespaces alone do not chroot the host FS.

Co-authored-by: esadrianno <esadrianno@gmail.com>
Double-quoted cat "$HOME/.shellclaw/auth_tokens.json" kept the quotes, so
has_path_chars skipped the token. Strip one surrounding quote pair before
the expand/workspace check. /bin/sh still expands the inner form.

Co-authored-by: esadrianno <esadrianno@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant