Skip to content

fix(sandbox): preserve workdir for shell command lists - #1

Closed
hsusul wants to merge 473 commits into
mainfrom
fix/sandbox-shell-workdir-command-lists
Closed

fix(sandbox): preserve workdir for shell command lists#1
hsusul wants to merge 473 commits into
mainfrom
fix/sandbox-shell-workdir-command-lists

Conversation

@hsusul

@hsusul hsusul commented Sep 8, 2026

Copy link
Copy Markdown
Owner

This pull request fixes exec_command so the configured working directory applies to the complete POSIX shell command list.

Root cause

The tool generated cd <workdir> && <cmd>. Shell operators in <cmd> are parsed together with that &&, so a command list beginning with a background job can continue after the directory change in a way that runs later commands from the sandbox root. If cd fails, semicolon, newline, and background command lists can still execute from the wrong directory.

Reproduction

With workdir=project and cmd="true; printf expected > marker", the old wrapper writes marker in the workspace root when project is missing. With an existing directory and cmd="true & wait; printf expected > marker", the old wrapper also writes in the workspace root.

Solution

The wrapper now emits cd <workdir> || exit followed by the caller command on a separate shell line. This establishes the directory before parsing and executing the caller command list and exits before user commands when the directory is unavailable.

Validation

  • Focused regression suite: 43 passed.
  • ruff format, targeted ruff check, and git diff --check: passed.
  • make typecheck: passed.
  • Full verification: formatting and lint passed; 9,474 tests passed, 55 skipped, with one unrelated failure in tests/sandbox/test_runtime.py::test_remote_realpath_guard_fails_closed_on_symlink_cycle and one existing subprocess cleanup warning.
  • Independent review: no actionable findings.

Risk assessment

The change is limited to shell command construction for an already-supported workdir. Path normalization, shell selection, user selection, default unscoped commands, and successful command exit behavior remain unchanged.

seratch and others added 30 commits August 8, 2026 08:28
Co-authored-by: LeSingh1 <sshaurya914@gmail.com>
Co-authored-by: LeSingh1 <sshaurya914@gmail.com>
)

fix(sandbox): reject unsafe mount credentials
Co-authored-by: abhay-codes07 <abhaysingh0293@gmail.com>
Co-authored-by: LeSingh1 <sshaurya914@gmail.com>
Co-authored-by: Henry Su <henrysu4707@gmail.com>
seratch and others added 28 commits September 5, 2026 18:11
)

Co-authored-by: Om Singhal <wengsinghal@gmail.com>
Co-authored-by: Warren <warren@ciridae.com>
Co-authored-by: Henry Su <henrysu4707@gmail.com>
Co-authored-by: ayaangazali <ayaangazali.work@gmail.com>
@hsusul

hsusul commented Sep 8, 2026

Copy link
Copy Markdown
Owner Author

Superseded by upstream PR openai#4915.

@hsusul hsusul closed this Sep 8, 2026
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.