mxc icon indicating copy to clipboard operation
mxc copied to clipboard

Seatbelt: a readwritePaths grant allows connect() to every Unix socket under it, so getTemporaryFilesPolicy exposes local programs' sockets

Open mrestrepo95 opened this issue 1 week ago • 0 comments

Relevant area(s)

macOS / Seatbelt, Node SDK policy helpers

Brief description of your issue

On macOS a readwritePaths entry lets the workload connect() to any Unix-domain socket below it. Combined with policy.filesystem.getTemporaryFilesPolicy(), which returns the user's whole temp folder ($TMPDIR, i.e. /var/folders/.../T/) read-write, a sandbox built from the recommended helpers can talk to every local program that keeps its socket there (IDE servers, language servers, agents' control sockets, ssh-agent forwards, etc.), with the user's rights on the other end.

This is the same shape as #1455 (a recommended helper widening the sandbox more than its name suggests), fixed by #1463.

What an embedder has to do today: not use getTemporaryFilesPolicy, create a private temp folder per sandbox, grant only that, and set TMPDIR to it.

Steps to reproduce

  1. On the host, listen on a Unix socket under $TMPDIR (e.g. node -e "require('net').createServer(s=>s.end('hi\n')).listen(process.env.TMPDIR+'/probe.sock')").
  2. Spawn a workload with filesystem from getTemporaryFilesPolicy() (or readwritePaths: [$TMPDIR]) and no network.
  3. From inside, node -e "require('net').connect(process.env.TMPDIR+'/probe.sock').pipe(process.stdout)" prints hi.

Measured on 1.1.0, with a control:

temp policy: rw=["/var/folders/…/T/"]
rw = getTemporaryFilesPolicy():  hi-from-host
rw = a private folder only:      connect error EPERM

Expected behavior

Any of:

  • document that a read-write grant includes Unix-socket connect on macOS;
  • have getTemporaryFilesPolicy return a fresh per-sandbox temp folder instead of the user's whole one;
  • a way to grant read-write without socket connect. #1277's proposed seatbelt.deniedUnixSocketPaths would let callers deny it, but the default stays open.

Environment

@microsoft/mxc-sdk 1.1.0, macOS 26.7 arm64.

mrestrepo95 avatar Nov 19 '26 13:11 mrestrepo95