Skip to content

Native sandbox: /tmp is read-only, breaking tools that hardcode /tmp #256

Description

@danny-avila

The native SRT sandbox mounts / read-only and allows writes only to the workspace root and a per-sandbox scratch directory (allowWrite in packages/code/src/native-sandbox.ts, scratch from mkdtemp(<tmpdir>/librechat-code-srt-XXXXXX)). TMPDIR points at the scratch directory and reaches child processes, so tools that honor it work. Tools that hardcode /tmp fail:

  • mongod, and therefore mongodb-memory-server test suites, creates its unix socket at /tmp/mongodb-<port>.sock regardless of TMPDIR. It dies with Failed to unlink socket file ... Read-only file system, then fassert() 40486, which callers only see as an opaque "Mongod internal error". Its --dbpath already lands under TMPDIR.
  • Shell scripts and CLIs that write /tmp/<name> directly (PR bodies, logs, scratch files).

On one trusted-VM deployment over 9 days: 38 test runs failed on the mongod socket and 32 commands on read-only /tmp. Agents keep relearning --nounixsocket / --unixSocketPrefix "$TMPDIR" workarounds.

Proposal

Give each sandbox a private writable /tmp, for example a bwrap --tmpfs /tmp (size-limited), or a bind of a per-sandbox scratch subdirectory onto /tmp. Keep it:

  • private to the sandbox (never the host /tmp, which the current design deliberately excludes to prevent a shared scratch area across workers),
  • wiped when the sandbox is evicted, like the scratch directory,
  • subject to the existing /tmp/claude deny rules.

This needs a security review of the SRT policy change, and the same behavior on macOS (/private/tmp) if feasible.

Acceptance

  • mongod (via mongodb-memory-server defaults) starts inside a native sandbox without extra args.
  • A file written to /tmp by one sandbox is not visible to another sandbox or to the host.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions