Skip to content

Restore Linux sandbox runtime mappings - #297

Draft
leynos wants to merge 1 commit into
harden-sandbox-runner-compat-restacked-20260924from
harden-sandbox-runtime-paths
Draft

leynos wants to merge 1 commit into
harden-sandbox-runner-compat-restacked-20260924from
harden-sandbox-runtime-paths

Conversation

@leynos

@leynos leynos commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

An explicitly authorized Linux command could fail before startup because Birdcage mounted runtime libraries with no-execute permissions and Weaver discarded loader aliases such as /lib64. This branch preserves each existing runtime path spelling and mounts those paths read-only with executable mappings. The caller's exact initial-command allowlist remains separate.

This layer follows runner-policy PR #303, above PR #296 and unblocks the later five-scenario sandbox test-quality layer. It contains one production fix, one direct-command regression, and ADR 013.

Review walkthrough

Validation

  • All eight local Make gates passed sequentially on 31858ff923564c58740fd3e54284330fbf5edcb9: check-fmt, spelling, lint (Clippy and Whitaker), test, typecheck, markdownlint, nixie, and test-workflow-contracts.
  • make test: 1,562 nextest tests passed, four skipped; workspace doctests passed. Workflow contracts: 187 passed.
  • The direct /usr/bin/env trial passed under nextest on this head and, in an earlier targeted run, Cargo's fallback runner with Threads: 1, both Unicode environment markers in the sandboxed and restored worker, and neither marker in the parent. The unlisted canonical loader was rejected before activation.
  • Deliberate mutation controls failed as expected: changing runtime mounts to Read produced EPERM; canonicalizing aliases before Birdcage produced ENOENT. Both edits were restored and the passing trial rerun.

Notes

Local gates are green under this layer's current configuration. Parent PR #303 remains draft with hosted CI blocked before coverage by the Whitaker installer's incompatible cargo-dylint release; this layer cannot be review-ready until that gate runs successfully. The five Gherkin scenarios remain assigned to the subsequent test-quality layer; this PR proves one direct command and does not claim those scenarios pass. The harness registers zero trials outside Linux. Local macOS compilation was unavailable because a macOS target is not installed; hosted checks must establish that platform's result.

Summary by Sourcery

Restore reliable startup for explicitly authorized dynamically linked Linux commands without broadening the caller's executable authorization boundary.

New Features:

  • Add Linux sandbox defaults that mount existing runtime library roots with executable read-only mappings while preserving loader aliases.
  • Add a direct-command sandbox regression probe covering dynamic startup, environment handling, and single-threaded execution.

Bug Fixes:

  • Restore startup of explicitly authorized dynamically linked Linux commands whose runtime libraries require executable mappings or loader aliases.

Enhancements:

  • Keep private runtime mounts separate from caller-supplied read paths and the exact initial-command allowlist.
  • Preserve non-Linux runtime defaults and prevent runtime mounts from authorizing the loader as an initial command.

Documentation:

  • Document the Linux runtime mount decision, security boundary, and platform-specific defaults in ADR and user-facing design documentation.

Tests:

  • Add unit and integration coverage for preserving Linux runtime aliases, separating runtime mounts from executable authorization, and validating direct sandbox execution.

References

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Sep 23, 2026

Copy link
Copy Markdown

Reviewer's Guide

Restores Linux dynamically linked command startup by preserving runtime path aliases and mounting standard runtime roots with Birdcage's ExecuteAndRead permission, while keeping caller executable authorization exact and adding a focused direct-command regression probe plus architectural and user-facing documentation.

Sequence diagram for Linux sandbox command startup

sequenceDiagram
    participant Caller
    participant SandboxProfile
    participant Sandbox
    participant Birdcage
    participant Command

    Caller->>SandboxProfile: new()
    SandboxProfile-->>Sandbox: runtime_paths with original aliases
    Caller->>Sandbox: allow executable path
    Sandbox->>Sandbox: ensure_program_whitelisted()
    Sandbox->>Birdcage: ExecuteAndRead(runtime paths)
    Sandbox->>Birdcage: launch authorized command
    Birdcage->>Command: map runtime libraries and loader
    Command-->>Caller: starts inside sandbox
Loading

File-Level Changes

Change Details Files
Preserve Linux runtime library aliases and grant them executable read-only sandbox mappings without expanding caller authorization.
  • Keep existing runtime roots in original spelling, including symlink aliases such as /lib64.
  • Store runtime paths separately from caller read-only, writable, and executable paths.
  • Add runtime roots as ExecuteAndRead exceptions while retaining exact initial-command allowlist checks.
  • Document the security boundary, rationale, consequences, and platform-specific defaults.
crates/weaver-sandbox/src/runtime.rs
crates/weaver-sandbox/src/profile.rs
crates/weaver-sandbox/src/sandbox.rs
docs/adr-013-linux-runtime-library-mounts.md
docs/contents.md
docs/users-guide.md
docs/weaver-design.md
Add a Linux direct-command regression probe covering runtime startup, environment handling, and thread constraints.
  • Run a single-threaded child that launches explicitly allowed /usr/bin/env inside the sandbox.
  • Verify executable runtime mappings allow the command and restored worker to run while environment markers remain isolated from the parent.
  • Keep the custom probe executable Linux-only and use libtest-mimic with Cargo fallback compatibility.
  • Add unit coverage for alias preservation, separation from executable authorization, and non-Linux empty defaults.
crates/weaver-sandbox/tests/sandbox_child_probe.rs
crates/weaver-sandbox/src/runtime.rs
crates/weaver-sandbox/src/sandbox.rs
crates/weaver-sandbox/src/tests/unit.rs
crates/weaver-sandbox/Cargo.toml
Update sandbox test dependencies and lockfile for the new regression harness.
  • Add cap-std and libtest-mimic development dependencies.
  • Register the nonstandard child-probe test target.
  • Refresh resolved dependency metadata.
crates/weaver-sandbox/Cargo.toml
Cargo.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

codescene-access[bot]

This comment was marked as outdated.

Preserve original Linux runtime-root aliases and give dynamic loaders
read-only executable mappings. Keep these defaults separate from the
caller's exact executable allowlist.

Cover direct `/usr/bin/env` launch in a single-threaded child and record
the permission boundary in ADR 013.
@leynos
leynos force-pushed the harden-sandbox-runtime-paths branch from e39abdc to 31858ff Compare September 24, 2026 03:28
@leynos
leynos changed the base branch from test-quality-protocol-roundtrip-20260923-restacked to harden-sandbox-runner-compat-restacked-20260924 September 24, 2026 03:28

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant