Repository navigation
feat(filesystem): let a read entry name a link to a file - #456
Conversation
|
Assessment: Request Changes The link-to-a-file path works for the common non-store case. However, the Review Categories
Checked and held:
The motivation and the staging-boxy evidence are clearly laid out. |
f02e271 to
9236979
Compare
|
Assessment: Approve Re-reviewed at 9236979. Both earlier findings are fixed and covered by new test rows, and I found no new correctness problem in the changed branches. Checked and held:
Still open, non-blocking: the unit test checks |
|
Assessment: Approve Re-reviewed at 77a38ca. The only change since 9236979 is in the Seatbelt Checked and held:
Still open, non-blocking: the |
|
After looking into this a bit more, this is not a platform issue, this is a standlone feature that effects both platforms |
| } else { | ||
| &grant.resolved | ||
| }; | ||
| allow_operator(containment, path, grant.operation, grant.scope)? |
There was a problem hiding this comment.
Keep the permission tied to the approved file
This can prepare a read grant for a different file from the one Box approved at startup. The gap occurs when a process can replace an intermediate link in a directory it has permission to write to.
For example, suppose the configured link is helper, which points through scratch/selector to approved.txt. Box checks that helper still reaches the approved file. Later, when preparing the read permission, it follows helper again. If a running process replaces scratch/selector between those steps, the second lookup can select other.txt. The configured link itself has not changed, but the file selected for the grant has.
Could we compare the prepared target with the approved target saved in grant.resolved, then finish creating the grant from that same prepared result? The existing guard checks could stay in place. Reusing the prepared result matters because following the link again after the comparison would reopen the same gap.
I reproduced this in a controlled test by running the existing identity check, replacing the intermediate link, and then preparing the grant. The resulting configuration granted other.txt instead of approved.txt. As a control, replacing the link before the identity check was rejected. This demonstrates the gap in the grant preparation sequence; I have not reproduced the timing in a concurrent full-Box run.
| && lexical | ||
| .parent() | ||
| .is_some_and(|folder| folder.canonicalize().is_ok_and(|real| real == folder)) | ||
| && lexical.canonicalize().is_ok_and(|target| target.is_file()); |
There was a problem hiding this comment.
Include the directory links needed to read the file on macOS
Some file links accepted by this change still cannot be read through their configured name on macOS. The final file is readable, but opening the link fails with a permission error. That leaves an accepted configuration unable to provide the read access it promises.
For example, suppose helper points to current/file, and current is a directory link pointing to data. Here, helper itself sits in a real directory, so it meets the new acceptance rules. The problem occurs farther along the path. The code finds data/file but leaves current out of the permissions it generates. macOS still needs to follow that directory link when the process opens helper, so the missing permission blocks the read.
Could we retain the directory links encountered along the target path and include the permissions needed to follow them? A regression test could check that both names are readable while neighboring files remain blocked. The code already had this gap, but this PR makes the affected configuration valid.
In a native macOS 27.2.1 test using this PR’s containment library, the configuration applied successfully and data/file was readable. Opening helper returned “operation not permitted.” Adding a metadata grant for current, which permits inspecting that link, made helper readable while data/sibling remained blocked.
Description
On Linux, a program often runs a helper by the name
PATHfinds, such as/usr/bin/cc, and that name is a symbolic link. Box refuses a filesystem entry that names a link, so a caller can only grant the real file (/usr/bin/gcc). The name the program opens is then missing in the box, and cargo stops withlinker `cc` not found.This change lets a
readorread_fileentry name a link to a file.read_file = ["/usr/bin/cc"]works. The box shows gcc's file at/usr/bin/ccand at/usr/bin/gcc, both read-only. The disclosure printsread_file /usr/bin/cc -> /usr/bin/gcc.~/.sshis refused like the file itself. The links in between, such as/etc/alternatives/cc, and the folders that hold the links are not granted./usr/bin/ccand/usr/bin/gccon Ubuntu, are two entries, and both names reach the file. A link beside areadfolder that holds its file is kept too, such as/usr/bin/javanext to the JDK folder, because its name is outside that folder.~/.ssh/config), a link listed next to its own file or inside the folder it points into, and a link inwrite,write_file,exec,listormetadata.granted Read twice). It now refuses only one name granted twice, and renders each link name's own rules.check_read_grantnow accepts a read link to a file, and theGrantRefusal::Linkdoc lists which links are still refused.docs/user/config.md(entry rule and refusal table),docs/design/platform-differences.md,docs/design/containment.md.Related Issues
None.
Type of Change
New feature
Testing
a_read_entry_naming_a_link_to_a_file_reads_by_both_names(a real box reads the file by two link names and by its own name, not a sibling, and the disclosure shows the arrow)every_refusal_class_fires_and_names_the_entry(accepted inreadandread_file, as two links to one file, and beside a folder holding its file; refused inwrite_file,metadata,exec, through a linked folder, inside and into a credential store, inside the folder it points into, and twice with its file)a_read_grant_naming_a_link_to_a_file_is_accepted(check_read_grant)50bf296plus its helper change, built against this change at6061c66eplus #455's permitlinker `cc` not found6061c66e, before the review fixes. The review fixes (92369795: credential-store links, two names for one file) were tested with fmt, clippy and the workspace tests onc061263c, then rebased ontoa8009909without a rerun.cargo fmt --check,cargo clippy --workspace --all-targets --all-features -D warningsandcargo test --workspace --all-featurespass. On the busy test host,mcp_alias_fallback(Text file busy),shell_dependency_guard(package-cache lock) and runs that hit a full disk failed in the parallel run. Each passed when run again on its own, and none touches filesystem entries.the_enter_only_grant_renders_before_the_direct_grantsreadsboundary.rssource, so its search string follows the changed line.grouping_folds_one_path_into_one_rule_set; CI runs it. On macOS Seatbelt already allows each link node on a grant's path.Still blocked
PATHname and gives a GCC helper the files it links, needs this change in its pinned Box Core.cargo install cargo-nextest) stops at the output budget and bash'ssetpgidEPERM, a separate wall.Checklist