Skip to content

fix(sandbox): ensure read_write directories are writable by sandbox user#7

Merged
pdettori merged 2 commits intomvpfrom
fix/sandbox-tmp-permissions
May 2, 2026
Merged

fix(sandbox): ensure read_write directories are writable by sandbox user#7
pdettori merged 2 commits intomvpfrom
fix/sandbox-tmp-permissions

Conversation

@pdettori
Copy link
Copy Markdown

@pdettori pdettori commented May 2, 2026

Summary

  • Container images (e.g. ghcr.io/nvidia/openshell-community/sandboxes/base:latest) ship /tmp as root:root 0700
  • The supervisor's prepare_filesystem only chowned newly created directories, leaving existing ones inaccessible to the unprivileged sandbox user
  • Claude Code fails with EACCES: permission denied, mkdir '/tmp/claude-998/...' when trying to create its task directory

Fix

When a read_write directory exists but is not writable by the target user (neither world-writable nor owned by the user with write bit), set its mode to 1777 (sticky world-writable). This runs before the child process is forked, so there is no TOCTOU risk.

Test plan

  • New unit test prepare_read_write_path_fixes_inaccessible_tmp
  • Rebuild supervisor image and verify Claude Code can write to /tmp inside sandbox
  • Existing tests (prepare_read_write_path_creates_missing_directory, prepare_read_write_path_preserves_existing_directory, prepare_read_write_path_rejects_symlink) still pass

Context

Without this fix, Claude Code's Bash tool cannot execute inside sandboxes using the community base image, which blocks network access testing (the proxy allows network from Claude Code's process tree via ancestor binary matching).

pdettori added 2 commits May 1, 2026 22:49
Container images may ship /tmp as root:root 0700. The supervisor's
prepare_filesystem only chowned newly-created directories, leaving
existing ones inaccessible to the unprivileged sandbox user.

When a read_write directory exists but is not writable by the target
user (neither world-writable nor owned by the user with write bit),
set its mode to 1777 (sticky world-writable). This fixes Claude Code
failing with EACCES when creating its task directory under /tmp.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Paolo Dettori <dettori@us.ibm.com>
The st_uid() method is from std::os::linux::fs::MetadataExt while
uid() is from std::os::unix::fs::MetadataExt which is portable
across all Unix platforms.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Paolo Dettori <dettori@us.ibm.com>
@pdettori pdettori merged commit 280002f into mvp May 2, 2026
8 checks passed
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