8000 fix(graph,mctx): load a box's package graph only from links it may follow by bryan-minimal · Pull Request #4000 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

fix(graph,mctx): load a box's package graph only from links it may follow - #4000

Open
bryan-minimal wants to merge 7 commits into
mainfrom
fix/1258-upstream-dir-confined
Open

bryan-minimal wants to merge 7 commits into
mainfrom
fix/1258-upstream-dir-confined

Conversation

@bryan-minimal
@bryan-minimal bryan-minimal commented Dec 3, 2026 •
Copy link
Copy Markdown
Member

What

The daemon loads a package graph on a box's behalf. Until now it took the workspace, and every [upstream] or sideload link the graph's layers named, by plain path. That meant a dir link could point anywhere on the daemon's machine, and a repo given as a local path or file:// URL was cloned by the daemon.

A context confined to a box's workspace now loads its graph within the box:

  • Dir links: a dir link is followed only to a directory inside the workspace. It may climb with .. and come back inside, as the .minimal/ layout's ../pkgs does: the path is resolved by name against the declaring file's directory and must stay beneath the workspace. A symlink on the way, or a path that leaves the workspace, is refused, naming the link (relative to the project, or to the layer that declares it, never by the daemon's own path) and why, before anything there is read.
  • Repos: a repo that git would take as local (a path, file://, a remote helper) is refused in the graph and in the project setup (init, update).
  • Layer files: every layer's minimal.toml is read beneath the workspace, or beneath the checkout for a repository. A layer directory that resolves outside it is refused.

A host-side load keeps today's behaviour. mctx::Config carries box_local_links (default Refuse) as the place a later allowance from the user's policy plugs in. The daemon's scaffold no longer looks the file up by plain path first.

Tests

  • Unit tests for the containment rules in graph::confine and the loader: in-workspace .., a .. that leaves, symlinked paths, local and file:// repos.
  • Daemon box-chain tests in box_manager.

Lab evidence

Release vs this branch:

check distros release this branch
a box links outside its project (four link forms) or to a repository on the machine; an in-project sideload still loads Ubuntu 24.04, Fedora 44 fail: bytes from outside the project reached the box pass: every outside link refused, the in-project sideload loads
the same through the in-VM daemon Ubuntu 24.04 fail pass
baseline Ubuntu 24.04, Fedora 44 pass pass

The lab prepush (fmt, clippy -D warnings, the workspace tests, the new tests repeated, doctests, the native daemon e2e) and Kani are green on this tree.

🤖 Generated with Claude Code

bryan-minimal and others added 4 commits December 2, 2026 09:54
…llow

A package graph the daemon loads on a box's behalf took the workspace and
every [upstream] or sideload link its layers named by plain path: a dir
link anywhere on the daemon's machine, and a repo that is a local path or
file:// URL, cloned in the daemon.

A context confined to a box's workspace now loads its graph within the box:
- a dir link is followed only to a directory inside the workspace, reached
  through no .. and no symlink; anything else is refused, naming the link
  as written and why, before anything there is read
- a repo that git would take as local (a path, file://, a remote helper)
  is refused, in the graph and in the project setup (init, update)
- every layer's minimal.toml is read beneath the workspace, or beneath the
  checkout for a repository, and a layer directory that resolves outside
  it is refused

A host-side load keeps today's behaviour. mctx::Config carries
box_local_links (default Refuse) as the place a later allowance from the
user's policy plugs in. The daemon's scaffold no longer looks the file up
by plain path first.


Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keeps the project setup's check off a large Result error type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A dir link that climbs with .. and comes back inside the workspace, as
the .minimal/ layout writes ../pkgs, is now followed: the path is
resolved by name against the declaring file's directory, must stay
beneath the workspace, and the symlink check and the load use the
resolved path. A .. that leaves the workspace is still refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bryan-minimal
bryan-minimal requested a review from a team as a code owner December 3, 2026 18:52
@coderabbitai
coderabbitai Bot commented Dec 3, 2026 •
Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 13 billable files and costs up to $3.25.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 58 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 57 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: bcf67e5b-66cb-49d4-8931-b162b8e0947f
Commits

Reviewing files that changed from the base of the PR and between e24ee1e and 749c480.

Files selected for processing: 13

  • crates/boxes/docs/COMPOSITION.md
  • crates/decode/src/lib.rs
  • crates/decode/src/load.rs
  • crates/graph/src/confine.rs
  • crates/graph/src/lib.rs
  • crates/graph/src/loader.rs
  • crates/mctx/src/config.rs
  • crates/mctx/src/lib.rs
  • crates/mctx/src/project_setup.rs
  • crates/mfile/src/lib.rs
  • crates/minimald/src/box_actor/setup.rs
  • crates/minimald/src/box_manager/tests.rs
  • crates/minimald/src/env.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@minimal-foundry
minimal-foundry Bot commented Dec 3, 2026 •
Copy link
Copy Markdown
Contributor

Approved: no findings at 749c4803d4d9.

Nothing to do.

Clobber: not checked in git history. If that was not intentional, restore the earlier change.

@minimal-foundry minimal-foundry Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — approved

Verdict APPROVE — No findings.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Dec 3, 2026
@norrietaylor norrietaylor left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the link-following paths: BoxScope::resolve_link in load_layer for the upstream, every sideload and the leaf; Layer::new_within with the confined minimal.toml read; bound_for for checkouts; the layer cache (it only caches Repo origins, so a dir layer never skips new_within); every daemon graph-load site (composables, build_context and cloned_reinit keep mfile_edit_root); ProjectSetup for init/update; and is_local_remote against git's own url_is_local_not_ssh / helper parsing for the CLI clone in checkouts::repo. The design holds and the tests are good negative-control pairs. Two medium findings block approval. First, a TOCTOU: the box can swap the layer directory for a symlink between refuse_outside and Confinement::new, which re-derives the confinement root from the swapped path, so neither confinement check catches it. Second, the scaffold now swallows a refused read, and no test covers that. There are also two low notes on refusal wording and scope.


Generated by Claude Code

Comment thread crates/decode/src/lib.rs Resolved
Comment thread crates/minimald/src/box_actor/setup.rs Resolved
Comment thread crates/graph/src/confine.rs Resolved
Comment thread crates/graph/src/confine.rs Resolved
bryan-minimal and others added 3 commits December 3, 2026 17:14
… lie beneath

The layer directory was checked against the workspace, then canonicalized again
when its confinement was made. A directory swapped for a link out of the workspace
between the two became the confinement root, so the checks on every file read
passed. The confinement is now refused unless its root is beneath the workspace
or checkout, so a later swap is caught by those checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hout a scaffold

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…repos are refused

A refused relative dir in a checkout's layer named the daemon's path to the checkout;
it is now shown relative to the layer that wrote it. The docs now say a repository
is refused when git reaches it without the network; a loopback host is a network
remote, pinned by a test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@minimal-foundry minimal-foundry Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — approved

Verdict APPROVE — No findings.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

This branch has not been deployed

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

Labels

review:approved minimal-review approved the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0