Skip to content

fix(containment): copy the host's top-level links into /usr into the Linux view - #512

Merged
hanaduy merged 9 commits into
mainfrom
feature/linux-usr-merge-spellings
Nov 19, 2026
Merged

hanaduy merged 9 commits into
mainfrom
feature/linux-usr-merge-spellings

Conversation

@hanaduy

@hanaduy hanaduy commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #453.

On a Linux host where /bin is a link to usr/bin, as on Ubuntu and Amazon Linux 2023, a sandbox's view binds only the files its grants name. /bin is absent, so a #!/bin/sh script that a process writes or downloads at run time fails to exec with ENOENT, even when /usr/bin/sh is granted. Two examples:

macOS is not affected.

The change, following @opieter-aws's suggestion on this PR:

  • The view copies the host's top-level links into /usr: each of /bin, /sbin, /lib, /lib32, /lib64 and /libx32 that is a link whose text is a relative path into usr/, such as /bin -> usr/bin.
  • materialize writes the links into the view root after every mount and before the root is sealed read-only, so no mount target is reached through one.
  • A path written through one of these links is mounted at its /usr name: an interpreter spelling /bin/bash at /usr/bin/bash, the loader under /lib64 at /usr/lib64. So no mount sits under a linked name, and every link is kept, including for a tool whose wrapper starts #!/bin/bash. A refusal goes through the same mapping, so a refusal of /bin/bash replaces a grant of /usr/bin/bash.
  • A link resolves only to paths the view binds, so it adds no reach. /bin/cat stays absent unless /usr/bin/cat is granted.
  • It works the same for folder grants, /lib64, and the agent's, tools' and MCP servers' views.

What this replaces: the earlier version of this PR gave each granted file in /usr/bin or /usr/sbin an extra /bin or /sbin grant, plus a new startup section. That code in crates/box/src/run/contain/boundary.rs and its docs are removed, so this PR no longer changes the startup disclosure or what a filesystem entry grants.

A tool still needs /usr/bin/sh itself in its grants (for example read_file = ["/usr/bin/sh"]) for the script to start. A host where /usr/bin/sh is a link to another shell needs that link granted, not only its target.

Related Issues

Fixes #453.

Type of Change

Bug fix

Testing

  • the_view_copies_the_hosts_usr_links_and_mounts_each_name_under_usr (crates/containment/src/backend/linux/namespace/view.rs) plans views and checks that each host link into /usr is copied, and that no mount sits under a linked name, for a /bin/bash grant with /usr/bin/sh, for an exec file's loader and libc, and for a refusal of /bin/bash over a grant of /usr/bin/bash, which leaves only the refusal at /usr/bin/bash.

  • a_bin_sh_script_runs_through_the_hosts_bin_link (crates/containment/tests/root_links_linux.rs) runs a #!/bin/sh script under the real trampoline with only the script and /usr/bin/sh granted. The script must start, and /bin/ls must be absent. It also grants /usr/bin/cat and refuses /bin/cat, and checks that /bin/cat is empty and does not run cat. It skips on a host whose /bin is not a link to usr/bin.

  • Locally (macOS): cargo fmt --check; cargo clippy -p strands-box-containment --lib --all-features -D warnings for aarch64-unknown-linux-gnu, x86_64-unknown-linux-gnu and macOS; the docs site-manifest test (28 passed). This Mac has no Linux C toolchain, so the Linux tests compile and run only in CI.

  • I ran the relevant suites (just check, or cargo test --workspace --all-features)

  • If I touched Rust, I ran cargo fmt --all and cargo clippy --workspace --all-targets --all-features -- -D warnings

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • My changes generate no new warnings

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…usr Linux host

On Ubuntu, /bin links to usr/bin. A tool granted /usr/bin/sh saw it only
at /usr/bin/sh, because the view holds no /bin link. A script the tool
wrote at run time with `#!/bin/sh`, such as the entry points uvx writes
for mypy and pre-commit, then failed to exec with ENOENT.

Each file entry in /usr/bin or /usr/sbin is now also granted at its /bin
or /sbin name when the host links those folders, with the same operation
and file scope, as interpreter spellings are. The name reaches only that
file. Startup lists the names under "host link names for configured
access". Folder entries get no such name.
@github-actions github-actions Bot added Area - Agent Containment bug Something isn't working labels Nov 18, 2026
@hanaduy
hanaduy marked this pull request as ready for review November 18, 2026 10:17
Comment thread docs/user/config.md Resolved
Comment thread crates/box/src/run/contain/boundary.rs Resolved
@github-actions

Copy link
Copy Markdown

Assessment: Request Changes

The approach is sound. Giving a granted /usr/bin file its /bin name reaches no new file, and that name goes through the guard and is disclosed. One issue blocks the merge: when a file has two entries with different operations, the second operation never reaches its /bin name (see inline). The other comment is a docs sentence describing a config that can't load.

Checks that held
  • A tool's read_file link entry (/usr/bin/sh -> dash, /usr/bin/awk -> /etc/alternatives/awk -> gawk) gets a /bin name that resolves to the same identity and is disclosed. Checked by probe on Ubuntu 26.04.
  • /usr/sbin entries get a /sbin name the same way.
  • An entry the operator writes with /bin (read_file = ["/bin/sh"]) is still refused by the existing link rule, so nothing is granted twice.
  • Credential-store grants are skipped. The /bin name passes guard.judge through allow_operator.
  • An interpreter spelling from fix(linux): require existing grants for script interpreters #262 takes precedence and is not added twice.
  • Root AGENTS.md interface-frozen rule: the PR lists the filesystem-list meaning and the new disclosure section under "Interfaces, approval requested". Docs ship in the same change.
  • The rule "Policy is the only authorizer" and the filesystem-reach premises still hold. The new name reaches only the granted file, and the startup disclosure lists it.
  • cargo test -p strands-box --all-features --lib boundary: 78 passed, including the new test. That needs the trampoline built first. The end-to-end box tests skip on this runner because the namespace launcher is refused, so I could not check the uvx case end to end.
Known gaps, no change requested
  • On hosts where /sbin links to usr/bin (Arch, Fedora 42+), merged_usr_spelling adds no /sbin names, because the code expects /sbin to resolve to /usr/sbin.
  • In the agent sandbox, a read_file link name is read-only, so #!/bin/sh there now fails with EACCES instead of ENOENT. This matches the existing /usr/bin/sh behaviour, but the new config.md paragraph suggests that the name fixes the exec for any process.

The fix is narrow and well disclosed.

The /bin name was added once per name, so when a read entry for a file
came before an exec entry for the same file, the exec never reached the
/bin name, and the view bound it without exec. An exec entry for the
command's own file was also skipped before the /bin name was added.

Each (name, operation) pair is now granted once, an exec entry the
command already covers still reaches the /bin name, and the startup line
is printed once per name. The docs drop a folder example that can't load
and say the name carries only the entries' operations.
Comment thread crates/box/src/run/contain/boundary.rs Resolved
@github-actions

Copy link
Copy Markdown

Assessment: Request Changes (re-review of 4fa2e38)

Both earlier findings are fixed. The follow-up commit now runs the host-link grant for exec entries that the command or an interpreter spelling already covers. That adds a second exec cell for the interpreter, and an existing guard test now fails (see inline).

Checks that held on 4fa2e38
  • /bin names are now checked for duplicates by name and operation. A read_file plus exec on one file gives /bin/bash both operations, with one disclosure line.
  • An exec entry for the command's own file now reaches its /bin name.
  • The config.md paragraph no longer shows an entry that can't load, and it says that a read-only grant can't run the file at its /bin name.
  • The new test checks operations through operations_at, not just original and resolved.
  • cargo clippy -p strands-box --all-targets --all-features -D warnings and cargo fmt --check are clean.
  • cargo test -p strands-box --all-features --lib boundary: 77 passed, 1 failed. The one failure is an_interpreter_an_exec_entry_covers_is_not_granted_twice, which passes on 934e4bc.

Once the failing test is resolved, the rest of the change looks ready.

4fa2e38 added a /bin name for every exec entry, including one that the
interpreter path already grants under the shebang's spelling. On Ubuntu
that gave /usr/bin/dash a second exec cell (/bin/dash), and the guard
test an_interpreter_an_exec_entry_covers_is_not_granted_twice failed.

Choice: keep that test's rule. An exec entry an interpreter spelling
already covers gets no /bin name. An exec entry for the command's own
file still gets one, and the guard test is unchanged.
@github-actions

Copy link
Copy Markdown

Assessment: Approve (re-review of b4a0293)

All three findings are resolved. The last commit skips the /bin name for an exec entry that an interpreter spelling already covers, so that interpreter keeps one exec grant. The rest of the change is the same as 4fa2e38, which I checked in the previous round.

Checks that held on b4a0293
  • cargo test -p strands-box --all-features --lib boundary: 78 passed, including an_interpreter_an_exec_entry_covers_is_not_granted_twice and the new merged-/usr test. Clippy (-D warnings) and fmt are clean.
  • Probe: a tool script #!/bin/sh with read_file = ["/usr/bin/sh"] gives /bin/sh read and one disclosure line. An agent with exec = ["/usr/bin/dash"] plus read_file = ["/usr/bin/sh"] gives /bin/sh both exec and read.
  • The tool case does produce two identical (/bin/sh, read, file) cells, one from the interpreter spelling and one from the host link. The Linux view merges grants by mount target, so the mounts don't change.
  • The interface changes (the filesystem-list meaning and the new disclosure section) are still listed under "Interfaces, approval requested". They still need a maintainer's approval under root AGENTS.md.
  • Not verified here: the uvx run end to end. This runner refuses the namespace launcher, and the PR description still lists that check as open.

Thanks for the quick, focused follow-ups.

@opieter-aws

Copy link
Copy Markdown
Contributor

I was just working on strands-agents/box#453 which is this same problem. I found that copying the host's root links into the Linux view works too: /bin -> usr/bin, /sbin -> usr/sbin, /lib -> usr/lib and /lib64 -> usr/lib64, each written only when the host has exactly that link. With a granted /usr/bin/sh, /bin/sh then resolves through the link, and #!/bin/sh scripts run.

That seems like a better approach for three reasons. It adds no grants or extra binds, because a link only opens files the view already binds. It covers every path under those folders, including folder grants and /lib64, not only /usr/bin file entries. And it fixes the agent and MCP views too, since the view then has the same shape as the host.

Would you be open to exploring adding the links in the containment view, and drop the per-file /bin names? I have a working version that passes the containment and Box suites on ARM64 Linux, happy to share if you want.

agent assisted reply

@kevin-orellana

Copy link
Copy Markdown
Collaborator

The new host alias can expose a denied file

The new /bin name can let a process read or execute a file that its configuration explicitly denies.

On the tested Linux host, /usr/bin/sh points to /usr/bin/bash. Granting execution of Bash while denying /usr/bin/sh blocks execution through /usr/bin/bash. However, the newly added /bin/bash name still executes successfully. The equivalent read-only configuration exposes the file’s contents through that new name.

The new alias grant checks protected Box paths but does not apply the denial checks used for interpreter aliases. Could we check each added name against both the configured denial paths and their resolved targets, with regression coverage for reading and execution?

There is also a separate documentation correction. The configuration reference promises the additional name for every granted file. The implementation intentionally excludes execute grants already used by an interpreter alias. For example, a configured script beginning #!/usr/bin/sh, with exec = ["/usr/bin/bash"], receives no /bin/bash alias. Could we describe this exception in the configuration and architecture documentation?

Reproduction details

Tested: b4a02938102c590f98a789ce7e961931584e0a44, all features, Amazon Linux 2023 on ARM64.
Compared with: c0d6c6b9e917c310dcb27e77ed317648d6fd81ae, using separate build outputs.

This reproduction requires /bin to point to /usr/bin, and /usr/bin/sh to resolve to /usr/bin/bash.

Create separate, empty state and workspace directories. Give the state directory mode 0700. Substitute their absolute paths below:

name = "pr512-denial"
box_dir = "/absolute/path/to/state"

[agent]
command = ["/usr/bin/env", "/bin/bash", "--noprofile", "--norc", "-c", "printf ALIAS_EXECUTED"]
workspace = "/absolute/path/to/workspace"

[agent.filesystem]
exec = ["/usr/bin/bash"]
deny = ["/usr/bin/sh"]

Run the reviewed binary with:

strands-box run --config /absolute/path/to/repro.toml

Expected: The denial prevents execution of Bash through the added name.

Observed: The reviewed head prints ALIAS_EXECUTED and exits 0. The base exits 127 because /bin/bash is absent.

Controls: Changing the command’s target to /usr/bin/bash produces permission denied on both revisions. Directly denying /bin/bash also works.

For the read variant, replace exec with read_file and use this command:

command = ["/usr/bin/od", "-An", "-tx1", "-N4", "/bin/bash"]

The head exposes the executable header, 7f 45 4c 46. Reading the denied /usr/bin/bash path returns no bytes. This establishes access to the denied file through the new name; it does not establish a general host escape.

@kevin-orellana

Copy link
Copy Markdown
Collaborator

Preserve explicit denials when adding host aliases

This change conflicts with Box’s requirement that “a denial wins over every path grant”.

The new /bin/bash name can expose Bash even when an explicit denial blocks its /usr/bin/bash name. A compromised agent can choose the accessible name. This conflicts with tenets 1 and 3: enforcement must fail closed, and compatibility must not weaken protection.

Could we apply the existing denial checks to each added alias before granting access, with regression coverage for reading and execution?

Reproduction evidence: On Amazon Linux 2023 ARM64, /usr/bin/sh resolves to Bash. With exec = ["/usr/bin/bash"] and deny = ["/usr/bin/sh"], head b4a0293 permits execution through /bin/bash. Execution through /usr/bin/bash remains blocked. On base c0d6c6b, /bin/bash is absent. The read-only equivalent also exposes denied file contents through the new name.

boundary.rs and docs/user/config.md take main's text: the per-file /bin
names are being replaced by host root links in the Linux view (#453).
…Linux view

On a host where /bin links to usr/bin, the Linux view bound only the
files its grants named, so /bin was absent. A #!/bin/sh script a process
wrote at run time, such as pnpm's node_modules/.bin commands or uvx's
cached tool commands, failed to exec with ENOENT even with /usr/bin/sh
granted (#453).

The view now copies each host link from /bin, /sbin, /lib, /lib32,
/lib64 or /libx32 whose text is a relative path into usr/, after every
mount and before the root is sealed read-only. A name with a planned
mount at or under it keeps its folder and gets no link. A link resolves
only to paths the view binds, so it adds no reach.

This replaces the per-file /bin names this branch added in
crates/box/src/run/contain/boundary.rs, which are removed: the links
cover folder grants, /lib64, and the agent and MCP views as well, and
add no grants or startup lines. Suggested by @opieter-aws.

Fixes #453
@hanaduy hanaduy changed the title fix(box): show a granted /usr/bin file at its /bin name on a merged-/usr Linux host fix(containment): copy the host's top-level links into /usr into the Linux view Nov 18, 2026
…ge-spellings

# Conflicts:
#	crates/containment/AGENTS.md
@github-actions

Copy link
Copy Markdown

Assessment: Request Changes (re-review of 034385a)

This commit replaces the per-file /bin grants with copies of the host's top-level usr/ links in the Linux view. The design is sound, but the containment crate's Linux lib tests don't compile (see inline). I also missed the denial bypass that @kevin-orellana found on b4a0293 when I approved that head. Thank you for catching it. The new design closes it by construction, and an inline suggestion asks for a test that pins it.

Checks that held on 034385a
  • No added reach: a link in the view root resolves inside the view after pivot_root, so it reaches only bound paths.
  • Denials still win: refusals overmount both original and resolved, so /bin/<x> lands on the same empty overmount as /usr/bin/<x>.
  • Host link text: root_links copies only relative text made of Normal components that starts with the usr component. It rejects .., absolute text and usrlocal/…, and falls back to today's view.
  • Ordering: links are written after every planned mount and before the root's read-only remount, so no mount target is reached through a link, and the workload cannot change one.
  • Existing spellings: a planned mount at or under a name, such as the /bin/sh interpreter spelling or a /lib64 loader bind, keeps the folder.
  • Removed code: the earlier boundary.rs changes and the startup-disclosure section are gone, so box.toml and the disclosure are unchanged.
  • Tests run:
    • With root_links: Vec::new() patched into the seven literals, the_view_copies_the_hosts_merged_usr_links_where_no_mount_sits passes.
    • a_bin_sh_script_runs_through_the_hosts_bin_link skips on this runner, which refuses user namespaces, so CI is the only end-to-end proof.
For the maintainers
  • Interface approval: sandboxed processes now see /bin, /sbin and /lib* as links. Under root AGENTS.md, something an external party observes counts as an interface change, even when it adds nothing. The earlier "Interfaces, approval requested" section is gone from the description. @opieter-aws proposed the design, but an explicit approval should be recorded.
  • Remaining limit (documented in config.md): if a process's own command is a #!/bin/sh script, /bin stays a folder that holds only sh. A runtime #!/bin/bash script in that process still fails with ENOENT.

Once the test build is fixed, this looks close to ready.

@github-actions

Copy link
Copy Markdown

Assessment: Request Changes (re-review of 034385a + merge b2d8847)

The new design is better than the per-file aliases. A copied top-level link resolves inside the view, so it adds no grant, and a denial still applies to the file behind it. It also closes the denial bypass that @kevin-orellana found on b4a0293. I missed that bypass, and my earlier approval no longer applies. One blocker remains: the Linux test build doesn't compile (see inline). The merge from main touches only rename filtering and doesn't interact with this change.

Checks that held
  • Link text from the host: a link is copied only when its text is relative, starts with usr, and has only Normal components. Path::starts_with compares whole components, so usrx/… doesn't match, and .. is rejected. An absolute /bin -> /usr/bin is skipped, which leaves it as before (fails closed).
  • No new reach: the links are written after every mount and before the root is remounted read-only, so the workload can't change them. No mount target is reached through a link, and a link resolves only inside the pivoted root.
  • Denials: deny = ["/usr/bin/sh"] with /usr/bin/sh -> bash overmounts the file the link reaches. deny = ["/bin/bash"] plans a target under /bin, so /bin stays a folder holding the refused file. The plan probe confirmed both.
  • Native filesystem broker: it resolves paths with RESOLVE_IN_ROOT and canonicalises on the host side, so a /bin/… spelling reaches the same decision as /usr/bin/….
  • No duplicate names: the plan's / Dir cell is skipped because it has granted descendants, so no fresh root entry collides with symlink.
  • Ownership of the fix: the change sits in containment (the view), and the boundary.rs aliases and the startup disclosure section are removed. The PR therefore no longer changes a frozen Box surface.
  • Not verified here: the namespace tests and root_links_linux.rs skip on this runner because it refuses unprivileged namespaces. With the Critical fix applied locally, the plan test the_view_copies_the_hosts_merged_usr_links_where_no_mount_sits passes. CI on b2d8847: Rust / Lint and both Ubuntu unit-test jobs fail.

@github-actions

Copy link
Copy Markdown

Assessment: Comment (re-review of 36fec65)

No blocker remains. The only change since b2d8847 adds root_links: Vec::new() to the seven test literals. That fixes the Linux test build, and Rust / Lint now passes. Two non-blocking threads are still open with no reply: the /bin link is dropped when a mount sits under /bin (view.rs:1326), and the end-to-end test has no denial case (root_links_linux.rs:93). Please address each one or say why it stays as it is.

Checks on 36fec65
  • The diff against b2d8847 is seven added root_links: Vec::new(), lines in view.rs tests. The product code and docs are unchanged since my last review, so the checks listed there still hold.
  • cargo clippy -p strands-box-containment --all-targets --all-features -- -D warnings and cargo fmt --check are clean.
  • cargo test -p strands-box-containment --all-features --lib view: 199 passed, 6 failed. All six failures need user namespaces, which this runner refuses, and they fail the same way without this PR. the_view_copies_the_hosts_merged_usr_links_where_no_mount_sits passes.
  • Pending: the Ubuntu unit-test and Containment / Deterministic jobs were still running when I checked. They are the only end-to-end proof of a_bin_sh_script_runs_through_the_hosts_bin_link.
  • Maintainers: the explicit interface approval for the new /bin, /sbin and /lib* links that sandboxed processes see is still unrecorded.

…d keep the link

A grant, loader bind, or refusal written through a host link such as /bin -> usr/bin is now
planned at its /usr name (/bin/bash at /usr/bin/bash, the loader under /lib64 at /usr/lib64).
No mount then sits under a linked name, so the view keeps /bin, /lib and /lib64 even for a
tool whose wrapper starts #!/bin/bash or a process with an exec file. Before, any mount under
a name dropped its link, and runtime #!/bin/sh scripts failed again in those views.

A refusal goes through the same mapping, so a refusal of /bin/bash replaces a grant of
/usr/bin/bash. The plan test covers the #!/bin/bash wrapper, the loader closure, and that
refusal; the end-to-end test refuses /bin/cat with /usr/bin/cat granted and checks the link
reaches only the empty overmount.
@github-actions

Copy link
Copy Markdown

Assessment: Request Changes (re-review of 21eecc3)

The view_spelling mapping fixes the dropped-link problem cleanly. Every path written through a host link is mounted at its /usr name, so no mount sits under /bin, /lib or /lib64, and all of them keep their links. One existing Linux test now fails because it still compares against the host's /lib/... spelling (see inline). That test needs a one-line fix.

Checks on 21eecc3
  • Plan probe on Ubuntu x86-64:
    • /bin/bash read + /usr/bin/sh read: targets /usr/bin/bash, /usr/bin/dash and /usr/bin/sh, with links for bin, sbin, lib, lib32 and lib64.
    • exec /usr/bin/dash: loader at /usr/lib64/ld-linux-x86-64.so.2 and libc at /usr/lib/x86_64-linux-gnu/libc.so.6, and every link is kept.
    • Refusal of /bin/bash over a grant of /usr/bin/bash: one Refusal entry at /usr/bin/bash with no source.
  • One file, one target: a host name and its /usr name are one object, so the merged entry's ORed flags give no more than either name could already reach.
  • Mapping applied everywhere: grant, socket, Dir-scope (including its descendant check), dependency, protected-path and refusal targets all go through in_view. Bind sources stay host paths.
  • Loader trees: dependencies under an exec-capable /usr/lib or /usr/lib64 read root are now reached through that bind. Box's runtime minimum grants both, so the /usr/lib64 loader link resolves inside /usr/lib.
  • Denial test: the end-to-end test now refuses /bin/cat over a granted /usr/bin/cat and checks for an empty file that doesn't run.
  • Gates:
    • cargo clippy -p strands-box-containment --all-targets --all-features -D warnings and cargo fmt --all --check are clean.
    • cargo test -p strands-box-containment --all-features --lib: 497 passed, 13 failed. Twelve failures need user namespaces, which this runner refuses (for example, the reaper exits 11 at namespace setup). The thirteenth is the inline one, which passes on 36fec65.
  • Not run here: root_links_linux.rs and the Box end-to-end suites skip on this runner. CI on 21eecc3 was still queued when I checked.
  • Maintainers: sandboxed processes now see /bin, /sbin and /lib* as links, and grants written through those names now mount at their /usr names. That is an observable view change, and it still needs an explicit interface approval.

@github-actions

Copy link
Copy Markdown

Assessment: Approve (re-review of bb0402c), conditional on green CI and a maintainer's interface approval

The only change since 21eecc3 updates the stale libc assertion to compare against in_view(&system_libc). All my findings on this PR are now resolved. Before merge, two things are still needed. First, CI must pass: the jobs on 21eecc3 were cancelled, and bb0402c was still queued when I checked. CI is the only end-to-end proof of a_bin_sh_script_runs_through_the_hosts_bin_link and its denial case. Second, a maintainer must approve the view change.

Checks on bb0402c
  • Gates: cargo clippy -p strands-box-containment --all-targets --all-features -D warnings and cargo fmt --all --check are clean.
  • Lib tests: cargo test -p strands-box-containment --all-features --lib gives 498 passed, 12 failed. All 12 need user namespaces, which this runner refuses: the view establish tests, reaper, netns and authority. None of them touches the changed code. The runpath shadow test and the_view_copies_the_hosts_usr_links_and_mounts_each_name_under_usr pass.
  • No other stale assertions: the other test comparisons against resolver output either use in_view already (lines 5108 and 5148) or compare resolver output, not mount targets.
  • Identity checks: grant_identities and the dependency identity checks are keyed by host source paths, which the mapping doesn't change. Pins are released by grant, not by target, so mapping targets to /usr names leaves every identity check in place.
  • Carried over from 21eecc3 (unchanged since): the plan probe for the #!/bin/bash wrapper, the exec-file loader closure and the /bin/bash refusal all keep every link and put each mount under /usr. Denials still win through the link.
  • Maintainers: sandboxed processes on merged-/usr hosts now see /bin, /sbin and /lib* as links into /usr, and grants written through those names mount at their /usr names. Under root AGENTS.md, that is an observable interface change and needs an explicit approval. Even so, the change adds no reach.

The design now follows the host's own layout, which is simpler and safer than the per-file aliases it replaces.

@hanaduy

hanaduy commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

@kevin-orellana re #512 (comment):

Thanks, that was a real bypass in b4a0293, and that code is gone.

The PR now adds no per-file /bin grants: the view copies the host's own /bin -> usr/bin link (034385a), and mounts every path written through such a link at its /usr name (21eecc3).

In your config, the deny of /usr/bin/sh also covers its target /usr/bin/bash (reachable_paths), so /bin/bash reaches the empty overmount. CI runs on Ubuntu, where sh is dash, so it can't run your exact case. Could you rerun your reproduction on bb0402c?

The config.md text you flagged was removed with the per-file names.

@hanaduy

hanaduy commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

@kevin-orellana re #512 (comment):

Agreed, a deny has to win under every name. The current head adds no alias grants, so a deny has no new name to miss: /bin is the host's own link, and a deny lands on the same mounted file whichever name it's written with. a_bin_sh_script_runs_through_the_hosts_bin_link covers read and exec through the link: it denies /bin/cat over a granted /usr/bin/cat, then checks the file is empty and doesn't run.

@hanaduy
hanaduy merged commit 5797bf0 into main Nov 19, 2026
23 of 24 checks passed
@hanaduy
hanaduy deleted the feature/linux-usr-merge-spellings branch November 19, 2026 00:10
yesyayen added a commit that referenced this pull request Nov 19, 2026
…-protect

Brings in main (#499 squashed as ba08d59, and #512) through the branch
below. No file of this PR's own change differs.
@kevin-orellana

Copy link
Copy Markdown
Collaborator

Adding permission to read a system library that the agent cannot modify can prevent an otherwise valid command from starting. In Box's box.toml, agent.filesystem.read_file grants read access to an individual file. Adding /usr/lib64/libc.so.6 to that setting makes /usr/bin/printf exit before printing.

Could we preserve the required dependency's admitted execution access when combining entries for the same file and target, and add a startup regression test? Explicit denials and writable-library checks still need to take precedence.

The dependency loop in view.rs maps the dependency to its /usr path. The duplicate-target check then finds the existing nonexecutable read entry and skips the dependency, losing execution access that Box already admitted for program startup.

I reproduced this on Amazon Linux 2023, 64-bit Arm, comparing base c6b5f8c with merged head bb0402c. These are the relevant box.toml settings:

[agent]
command = ["/usr/bin/printf", "REGRESSION_OK\n"]

[agent.filesystem]
read_file = ["/usr/lib64/libc.so.6"]

With otherwise equivalent configurations, strands-box run --config box.toml produced:

  • Base c6b5f8c: prints REGRESSION_OK and exits 0.
  • Head bb0402c: prints nothing and exits 127 with /usr/bin/printf: error while loading shared libraries: libc.so.6: failed to map segment from shared object.

Each result repeated three times. Removing the read grant or adding an explicit exec grant for the same library succeeds on both revisions. An exact-file read entry also reproduces the failure.

I also reran the original eight alias-denial checks on bb0402c; they now pass. Denied paths expose no file contents and cannot execute, while the corresponding allowed controls succeed.

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

Labels

Area - Agent Containment bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Linux: a tool cannot reach a granted file through a symbolic link, so #!/bin/sh scripts fail with ENOENT

3 participants