Cursor · tool · fg-0519

id -u returns 0 inside Cursor's Linux sandbox, so docker --user and chown use root

If you see Files created by a sandboxed Docker run are owned by root on the host, the cause and the fix for Cursor are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
Files created by a sandboxed Docker run are owned by root on the host$(id -u) and $UID print 0 in Agent terminal commands
Cause
On Linux the sandbox runs commands in a user namespace remapped to UID 0, so scripts that read the current user ID get root inside the sandbox.
Fix
Read the host IDs from CURSOR_ORIG_UID and CURSOR_ORIG_GID, falling back to id when they are unset.
Apply
docker run --rm --user "${CURSOR_ORIG_UID:-$(id -u)}:${CURSOR_ORIG_GID:-$(id -g)}" -v "$PWD":/work image
Affected
Cursor Agent sandbox on Linux (Landlock, kernel 6.2 or later), as of 2026-10
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun