Skip to content

feat: sandbox lake challenge with bwrap instead of landrun - #15005

Draft
Kha wants to merge 1 commit into
masterfrom
push-uyzopvvpsnmt
Draft

feat: sandbox lake challenge with bwrap instead of landrun#15005
Kha wants to merge 1 commit into
masterfrom
push-uyzopvvpsnmt

Conversation

@Kha

@Kha Kha commented Sep 3, 2026

Copy link
Copy Markdown
Member

This PR builds and exports the code lake challenge judges inside a further restrictedbubblewrap sandbox rather than landrun, which stops that code from being able to access the invoking user's files and gives the steps that must not reach the network no network at all.

/ is bound read-only and the home directories are then covered, so the project still builds against the system it expects while ~/.ssh, credentials and caches are simply absent; only .lake is writable; and only dependency resolution, which has to fetch git dependencies, gets a network namespace. COMPARATOR_LANDRUN becomes COMPARATOR_BWRAP.

Landlock could not express either property. Its rules only ever grant, so nothing can be carved out of the --ro / the toolchain needs, and its network rules cover TCP alone, so a build could open a UDP socket and send what it had read; a namespace has neither gap. The cost is that bwrap cannot narrow a network to particular ports, so resolution gets all of one rather than TCP 443 and 22. A dependency reachable only with the user's own credentials is now out of reach, which is the point.

bwrap runs either through unprivileged user namespaces or installed setuid root, and distributions that disable the former usually ship the latter. --unshare-all expands to --unshare-user-try, which skips the user namespace rather than failing when it cannot be created, and none of --userns, --disable-userns or the overlay options, the ones bubblewrap does not support setuid, are used.

readablePaths becomes more critical, since a path the run needs has to be bound back over those covers: the toolchain, which an elan install puts under the home directory, along with the project, the exporter and any external kernel binary. External kernels are resolved through PATH before the sandbox starts for that reason. tests/lake/tests/fake-bwrap.sh replaces fake-landrun.sh and now honors --clearenv and --setenv, which landrun's --env got for free from the parent environment.

This PR builds and exports the code `lake challenge` judges inside a `bubblewrap` sandbox rather than a `landrun` one, which stops that code from reading the invoking user's files and gives the steps that must not reach the network no network at all. `/` is bound read-only and the home directories are then covered, so the project still builds against the system it expects while `~/.ssh`, credentials and caches are simply absent; only `.lake` is writable; and only dependency resolution, which has to fetch git dependencies, gets a network namespace. `COMPARATOR_LANDRUN` becomes `COMPARATOR_BWRAP`.

Landlock could not express either property. Its rules only ever grant, so nothing can be carved out of the `--ro /` the toolchain needs, and its network rules cover TCP alone, so a build could open a UDP socket and send what it had read; a namespace has neither gap. The cost is that `bwrap` cannot narrow a network to particular ports, so resolution gets all of one rather than TCP 443 and 22. A dependency reachable only with the user's own credentials is now out of reach, which is the point.

`bwrap` runs either through unprivileged user namespaces or installed setuid root, and distributions that disable the former ship the latter. `--unshare-all` expands to `--unshare-user-try`, which skips the user namespace rather than failing when it cannot be created, and none of `--userns`, `--disable-userns` or the overlay options, the ones bubblewrap does not support setuid, are used.

`readablePaths` becomes load-bearing, since a path the run needs has to be bound back over those covers: the toolchain, which an `elan` install puts under the home directory, along with the project, the exporter and any external kernel binary. External kernels are resolved through `PATH` before the sandbox starts for that reason. `tests/lake/tests/fake-bwrap.sh` replaces `fake-landrun.sh` and now honours `--clearenv` and `--setenv`, which `landrun`'s `--env` got for free from the parent environment.

Co-Authored-By: Claude <noreply@anthropic.com>
@Kha
Kha requested a review from hargoniX September 3, 2026 12:38
@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Sep 3, 2026
@mathlib-lean-pr-testing

Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Mathlib CI can not be attempted yet, as the nightly-testing-2026-09-03 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Mathlib CI should run now. You can force Mathlib CI using the force-mathlib-ci label. (2026-09-03 13:00:48)

@leanprover-bot leanprover-bot added the breaks-manual This is not necessarily a blocker for merging, but there needs to be a plan. label Sep 3, 2026
@leanprover-bot

leanprover-bot commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

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

Labels

breaks-manual This is not necessarily a blocker for merging, but there needs to be a plan. toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants