Public: anyone can read this; the crew can change it.

Checks with no cell: every forked bun aborts, it can't read its own /proc/self under the Landlock floor (#16938) #17305

shipped production is serving it opened this From outside

Landed in pull #17365

opened this

Since #16938 (1857b5e4) a check with no cell (\no cell here: ... the check step is held by landlock\) only lets the helper's own pid read \/proc/<pid>\ (landlock_helper.ts: \allow(ruleset, /proc/${process.pid}, READ)\). Every process the step forks gets a new pid, so it can't read its own \/proc/self/*\. Bun (1.3.14 and 1.4.4) reads \/proc/self/maps\ at startup (the main thread's stack bounds) and aborts:

$ bun test
panic(main thread): abort() called
oh no: Bun has crashed.
failed: check took longer than 60s

Seen on the grokbot-dev child forge: leagues/starter-scheduler pull 24, run 01m8t0p6nc4mnmy9b3t6t64690, twice, at two heads. Main there was green on 11-26 before the deploy. Every bun check on a cell-less host is red, and so is any step whose \bun\ isn't the exec'd process.

Local repro on main (kernel 6.12, ABI 6), using \checkFloor\ + \landlockPlan\ + \landlockArgv\, with argv \/bin/sh -c ...\:

  • \exec bun -e 'console.log(42)'\ prints 42 (bun is the helper's pid).
  • \bun -e 'console.log(42)'; true\ aborts (forked child).
  • \cat /proc/self/maps; true\ gives Permission denied. \exec cat /proc/self/maps\ works.
  • Adding \/proc\ to the plan fixes it, but that undoes the point of #16938.

A Landlock rule binds to an inode at ruleset time, so pids that don't exist yet can't be granted. Options I see:

  1. Leave \/proc\ readable under the floor and stop neighbours reading the forge's \/proc/<pid>\ another way, e.g. \prctl(PR_SET_DUMPABLE, 0)\ in each forge process. A same-uid process then can't read its environ, maps or fd.
  2. Keep #16938's narrowing only where steps don't fork, which isn't a check.
  3. Treat cell-less hosts as unable to run checks and say so, instead of a red that blames the pull.

Option 1 is security-sensitive, so I'm asking for a maintainer decision before I send a pull. I'm happy to write it.

commented

Data for the decision (box, kernel 6.12, Landlock ABI 6, the same checkFloor + landlockPlan + landlockArgv path). I made /proc readable in the plan (pid dirs included) and had the step read a same-uid process outside the sandbox that holds VICTIM_SECRET in its env:

/proc/<outside pid>/…floor today/proc readable
environdenieddenied
maps, mem, stackdenieddenied
fd/0 (readlink/open)denieddenied
fd/ listing (numbers only)deniedread
cmdline, statusdeniedread
forked bun -eabortsruns

Landlock already scopes ptrace: a sandboxed process can't pass PTRACE_MODE_READ on a process outside its domain, and that check guards environ, maps, mem and fd links. So reading /proc doesn't reopen the tokens #16938 was protecting. What a step can still see is other processes' argv, status and fd counts. That's option 1 without the PR_SET_DUMPABLE work, and the cost is fine as long as the forge never puts a secret in argv.

If you're OK with that cost, I'll send the small pull: drop the pid skip in readRootsAround, drop the helper's own-pid rule, and add a test that a forked child under the floor reads its own /proc/self/maps but can't read another process's environ. Still your decision.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs