Linux sandbox fails on Unraid rootfs: `bwrap: pivot_root: Invalid argument`
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- linux, rust
- Domain
- operating-systems, security
Research direction
Start with the Linux sandbox path and the failure reported at linux-sandbox/src/linux_run_main.rs:252:9; reproduce on an Unraid host whose root is the initial rootfs using the bundled bubblewrap helper. Trace the pivot_root failure and existing legacy Landlock fallback, then make the behavior compatible with this topology or report a clear compatibility diagnostic; verify that sandboxed commands no longer fail opaquely.
Written by the indexing model from the issue text.
Description
What version of Codex is running?
codex-cli 0.144.1
What platform is affected?
- Unraid Linux
- Kernel:
6.12.54-Unraid - Architecture:
x86_64 - Sandbox policy:
workspace-write - Workspace filesystem: ZFS
- Root filesystem: the initial
rootfs
$ findmnt -no TARGET,FSTYPE,PROPAGATION,OPTIONS /
/ rootfs private rw,size=31643352k,nr_inodes=7910838,inode64
$ findmnt -T /mnt/cache/projects/<repo> -o TARGET,SOURCE,FSTYPE,OPTIONS
TARGET SOURCE FSTYPE OPTIONS
/mnt/cache/projects cache/projects zfs rw,relatime,xattr,posixacl,casesensitive
There is no system bwrap on this host, so Codex uses its bundled bubblewrap helper.
What issue are you seeing?
Every sandboxed command fails before the requested command executes:
bwrap: pivot_root: Invalid argument
This affects harmless read-only commands such as pwd, git status --short, and rg --files.
Because the sandbox bootstrap fails, the only available retry path is execution outside the sandbox. With an approval-based policy, this makes ordinary repository inspection appear to require approval for every command.
The same commands succeed normally when executed outside the Codex sandbox, confirming that repository ownership and workspace permissions are not the problem.
Steps to reproduce
-
Run Codex 0.144.1 on an Unraid host where
/remains mounted as the kernel's initialrootfs. -
Start a session using the default bubblewrap filesystem sandbox and
workspace-write. -
Ask Codex to run any command, for example:
pwd -
Observe:
bwrap: pivot_root: Invalid argument -
Retry the same command outside the sandbox and observe that it succeeds.
Additional diagnostics
Unprivileged user and mount namespaces are available. Both of these complete successfully:
unshare --user --map-root-user true
unshare --user --map-root-user --mount true
The namespace limit is also nonzero:
$ cat /proc/sys/user/max_user_namespaces
246490
This rules out the common case where unprivileged user namespaces are disabled.
The legacy Landlock fallback is present but does not work on this host:
codex --enable use_legacy_landlock sandbox linux /bin/true
Result:
thread 'main' panicked at linux-sandbox/src/linux_run_main.rs:252:9:
error applying legacy Linux sandbox restrictions: Sandbox(LandlockRestrict)
Likely cause
Linux documents EINVAL from pivot_root(2) when “the current root is on the rootfs (initial ramfs) mount”:
https://man7.org/linux/man-pages/man2/pivot_root.2.html
That exactly matches both the error and this host's mount topology.
Expected behavior
Codex should either:
- support sandboxing when the host root is the initial
rootfswithout relying on an unsupportedpivot_root()operation; - detect this mount topology at startup and use a compatible sandbox backend; or
- surface a clear compatibility diagnostic rather than failing every command and causing repeated approval escalations.
This appears distinct from AppArmor/user-namespace failures because namespace creation succeeds and the syscall fails specifically at pivot_root.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.5k
- Avg merge
- 1m
- Merged PRs (30d)
- 1k
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openai/codex
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug CLI windows-os
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
macOS sandbox blocks hw.optional.arm64 sysctl, causing Flutter to misdetect Apple Silicon as x64 Openbug CLI sandbox
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug CLI TUI
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
CLI config enhancement skills
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
A-linter
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
oxc-project/oxc#26863 ·