--sandbox_block_path: help doesn't say an absent path isn't blocked, or that replacing the path unblocks a running action
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- linux
- Domain
- build-system
Research direction
Search the Bazel source for the existing --sandbox_block_path help text and inspect the linux-sandbox option entry point. Update the help or documentation to state when the path is blocked and when replacement can unblock it, then run the relevant --help output to verify the wording.
Written by the indexing model from the issue text.
Description
The reporter of #4963 wanted --sandbox_block_path "to prevent likely cases of loss of hermeticity". Its help is one line: "For sandboxed actions, disallow access to this path." On Linux I found two cases where an action read a path passed to this flag. Neither is in the flag's help or in the docs.
The first is a path that does not exist when an action's sandbox is set up. linux-sandbox skips it. That is what #4963 asked for, and b6bb800 made it so, released in 7.3.0. The same issue asked for the flag's description to "document what this is", and the help still reads as quoted above. I'm not asking for a warning. I mention the silence because it leaves the build no way to show that the path wasn't blocked. On 9.2.0 the console output with the flag and an absent path was the same as without the flag, apart from timings and the output directory's name. It was still the same at --sandbox_debug -s once timestamps and PIDs are removed, and at that verbosity an applied block prints a bind mount line naming the path. 7.2.1 failed the build instead: "Mount target '...' does not exist."
Because the check runs for each action, a path that appears during the build was blocked for some actions and not others. I ran two genrules, B depending on A, with the blocked file absent at the start. A host process created it after A had started. Action A read it. B, set up afterwards, got Permission denied. With the file present from the start both were denied, and without the flag both read it.
The second case is a block that was applied. While an action ran, I replaced the blocked file from outside the sandbox, once by renaming a new file over it and once by deleting and recreating it. Both times the running action read the new file. Rewriting the file in place kept it blocked, and actions started afterwards were blocked again. With a blocked directory on 9.1.1, the action's /proc/self/mountinfo listed the bind mount before the replacement and not after. That matches mount_namespaces(7): a mount point replaced from another mount namespace is detached, as the kernel has done since Linux 3.18. Renaming a new file over the old one is the usual way to update a file atomically. So a blocked file that a host process updates that way while an action runs becomes an undeclared input of that action.
The mechanism isn't new. The kernel documents it, and another sandbox that hides paths with bind mounts ran into it and wrote it down when it changed its own cleanup (https://github.com/anthropics/sandbox-runtime/pull/184). What I couldn't find in Bazel's help or tracker is that an action already running can read a blocked path that appears, or is replaced, after its sandbox was set up. The nearest issue, #24514, is a different limit of the same flag, which a maintainer traced to symlink resolution.
All of this was on Linux, Debian 13 with kernel 6.12, under linux-sandbox. On 9.2.0 I ran every case twice, each from a fresh workspace and output root. The absent path and the path that appeared mid-build gave the same results on 8.8.0, and on 9.1.1 with a blocked directory. I didn't run macOS, where these paths are passed to sandbox-exec (#4963), and I didn't run the hermetic sandbox. processwrapper-sandbox ignores the flag altogether: under it the file was readable with the flag set.
For linux-sandbox, one sentence in the help would cover both: for each action, the path is blocked only if it exists when that action's sandbox is set up, and only until something replaces it while the action runs.
- Dominant language
- Java
- Stars
- 26.2k
- Forks
- 4.7k
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 125
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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 bazelbuild/bazel
-
team-Rules-Java type: bug untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
bazelbuild/bazel#33068 ·
Maintainers usually reply within 2 days
-
Remote repo contents cache rejects repos with a backslash in a file name on UnixPossibly taken A pull request linked to this issue is open or already merged. Openteam-Remote-Exec type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bazelbuild/bazel#32601 · 3 comments · 1 assignee ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bazelbuild/bazel#32132 ·
Maintainers usually reply within 2 days
-
Docs: run/build.mdx describes a sandboxing warning removed in 2017 and a flag deleted in 9.0.0Possibly taken @lavishdev claimed this 70 days ago. Openhelp wanted P2 team-Documentation team-OSS type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
bazelbuild/bazel#31316 ·
Maintainers usually reply within 2 days
-
Rename gen_mdx_reference_docs to gen_reference_docsPossibly taken @kapunahelewong claimed this 73 days ago. OpenP2 team-Documentation team-OSS type: documentation (cleanup)
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
bazelbuild/bazel#31211 · 2 comments ·
Maintainers usually reply within 2 days
All issues in bazelbuild/bazel
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Lincoln-cn/JAiRouter#1473 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
exercism/java-analyzer#379 ·
-
area: ui bug priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
tetsuji16/microProject#1893 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
liberation-data/fornax4j#325 ·
Maintainers usually reply within 1 day
-
[Bug]: FE and Kinesis extraction pipes render flow starting at the centre and scroll the source arm backwardsPossibly taken @chonkzillaofficial claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
BCCE-team/BuildCraft#85 ·