Skip to content

Refuse a missing deny_read inside a 2.1 jail's mounts, and document the mask gap - #169

Merged
M3gA-Mind merged 9 commits into
tinyhumansai:mainfrom
M3gA-Mind:fix/104-late-deny-read
Nov 12, 2026
Merged

M3gA-Mind merged 9 commits into
tinyhumansai:mainfrom
M3gA-Mind:fix/104-late-deny-read

Conversation

@M3gA-Mind

Copy link
Copy Markdown
Collaborator

Summary

Item 6 of #104 asks about deny_read paths created after the jail starts.

The 2.1 native resource jail. Since #107, the bubblewrap jail refuses a missing deny_read inside a mount, because a path created later would not be covered. The 2.1 native resource jail had no such check. It masked a missing path with --ro-bind /dev/null <path>, and bubblewrap then creates that path on the host: an empty, read-only file in the caller's tree. This was shown on bubblewrap 0.9.0. The 2.1 path now does what the bwrap jail does:

  • a missing denial inside a mount is refused (NotFound, the same message);
  • one outside every mount is skipped, since the sandbox never shows it.

A documented gap. A mask lasts only as long as the path it covers. A denial is a mount over that path's directory entry. When a host process replaces the path while the jail runs (an atomic rename, as credential helpers and editors write, or delete and recreate), the kernel drops that mount from the jail's namespace, and the jail sees the new file. This was shown on bubblewrap 0.9.0 and Linux 7.0 for both a file and a directory mask. bubblewrap can't prevent it.

The bwrap backend's known-gaps docs now say so, with what a host should do instead: deny a credential store outside every grant, so it's never mounted at all, or deny its parent directory.

The deny_read docs are also corrected. They said missing paths are "ignored" (bus) or "retained so backend rules can cover later creation" (jail), and bubblewrap does neither.

Related issue

Part of #104 (item 6). Items 1-5 are #160 and #167; item 6's seccomp filter is #161. The last part, resource limits on legacy bwrap jails, follows once #159 lands.

API or behavior changes

  • StartJailedExecWithResources with a missing deny_read path inside the root or a grant is now refused before launch. Before, it was accepted and an empty file was created on the host.
  • No API or contract change.

Validation

On our Linux CI runner (bubblewrap 0.9.0), at 780e281695. The head differs only by applying cargo fmt's patch:

  • cargo clippy --all-targets --all-features -- -D warnings: 0 errors, same as main. cargo build and cargo doc: ok.
  • cargo test -p tinybox-linux sandbox: 41 passed.
  • cargo test -p tinybox-module native_jail: 21 passed, all live tests run (none skipped).
  • cargo test --workspace --no-fail-fast: no failures unique to this branch.
  • Red control: without the new check, a_missing_denial_inside_a_mount_is_refused_and_one_outside_is_skipped fails (no refusal).
  • Separately, a bubblewrap probe on the same runner showed:
    • a --ro-bind /dev/null mask and a --tmpfs mask both stop covering their path once the host replaces it;
    • masking a missing path creates it on the host.

Tests

  • a_missing_denial_inside_a_mount_is_refused_and_one_outside_is_skipped: inside the root, refused with NotFound, and nothing is created on the host; outside every mount, the build succeeds and the path isn't in the argv.

Documentation

The known gaps in tinybox-jail/src/bwrap/mod.rs (the mask lifetime), NativeJailConfig::deny_read in tinybox-bus, and Jail::deny_read in tinybox-jail.

Checklist

  • The change is focused on one logical change
  • No new #[allow(...)], #[ignore], or relaxed lints
  • No secrets, tokens, or .env contents in the diff or the description

…he mask gap

The 2.1 native resource jail masked a missing deny_read path with
--ro-bind /dev/null, which makes bwrap create an empty file at that path in
the caller's tree; and a path created later was not covered anyway. As the
bwrap jail does since tinyhumansai#107, a missing denial inside a mount is now refused
and one outside every mount is skipped.

The docs said missing denials are ignored, or retained to cover later
creation, which bubblewrap does neither. They also did not say that a mask
lasts only as long as the path it covers: a host that replaces a denied path
inside a grant (an atomic rename) exposes the new file to a running jail,
shown on bubblewrap 0.9.0 and Linux 7.0. That is now a documented known gap
with what a host should do instead.

Part of tinyhumansai#104
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

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: Advanced
  • Run ID: 1512a684-c75b-47db-9369-d307a48e2638
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@tinysweeper

tinysweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Tiny Sweeper review

Reviewed head: cc4cfd26f9bfec142ea0018b835caed4600fe972

Findings

No active actionable findings.

Resolved this pass

  • Add the missing disable_userns field to the test request
  • Add the missing disable_userns field to the test request
  • Add the missing disable_userns field to the test request
  • Add the missing disable_userns field to the test request
  • Add the missing disable_userns field to the test request
  • Add the missing disable_userns field to the test request
  • Add the missing disable_userns field to the test request

Verdict: Ready for maintainer review · Priority: none
Coverage: Reviewed 5 of 5 files.

Diagnostics and supporting details

Full summary

Pull request purpose (title): Refuse a missing deny_read inside a 2.1 jail's mounts, and document the mask gap. For the 2.1 native resource jail, a missing `deny_read` path inside the root or a grant is now refused with `NotFound` before launch instead of being masked with `--ro-bind /dev/null` (which made bubblewrap create an empty file on the host), and a missing denial outside every mount is skipped when the argv is built. The bubblewrap backend's known-gaps docs now record that a mask lasts only as long as the path it covers, and the `deny_read` docs in `tinybox-bus` and `tinybox-jail` are corrected to describe per-backend handling. The latest-push-delta section is unavailable, so the whole-pull-request diff is described here, not a push delta.

Review snapshot

Change surface Files Review signal Count
Production 4 Active findings 0
Tests 1 Noted findings 0
Documentation 0 Resolved findings 7
Configuration 0 Pending checks/questions 0

Completeness: Complete
Test assessment: No supported feature-to-test mapping was available; this does not mean tests are absent or passed.

What changed

A new Linux-only test covers both branches (refusal inside the root with nothing created, and skipping outside every mount), and documentation in `NativeJailConfig::deny_read`, `Jail::deny_read`, and the bwrap known-gaps list now describes the refusal, the mask lifetime, and host guidance.

Features

  • Added — Preflight refusal of missing deny_read paths inside mounts: A `StartJailedExecWithResources` request with a missing `deny_read` path inside the root or a grant is now refused with `NotFound` before launch, instead of being accepted and causing bubblewrap to create an empty read-only file in the caller's tree. (crates/tinybox-linux/src/sandbox/args.rs fn validate_native_jail_command(request: &NativeJailCommand) -> std::io::Result<, crates/tinybox-linux/src/sandbox/args.rs fn native_bwrap_argv()
  • Modified — Skip missing denials outside every mount when building argv: A missing `deny_read` path outside the root and all grants is no longer emitted as a mask argument, and no longer causes bubblewrap to create the path on the host. (crates/tinybox-linux/src/sandbox/args.rs fn native_bwrap_argv()
  • Modified — Corrected deny_read and mask-lifetime documentation: `NativeJailConfig::deny_read` and `Jail::deny_read` now describe per-backend handling of missing paths, and the bwrap known-gaps section records that a mask is dropped when the host unlinks or renames over the denied path, with guidance to deny outside every grant or deny the parent directory. (crates/tinybox-bus/src/jail.rs pub struct NativeJailConfig {, crates/tinybox-jail/src/jail.rs pub struct Jail {, crates/tinybox-jail/src/bwrap/mod.rs)

Tests

No supported feature-to-test mapping was produced. Test execution is not inferred.

Before merge

None.

Agent review details

critique

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: Reviewed 3 files; 2 findings.

security

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The security lane reports no security defect introduced: existing validation still runs first, the new error is only raised for missing paths under existing mounts, and present denials are still masked.
  • Lane summary: Reviewed 3 files; 0 findings.

tests

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The tests lane reports the documented mask-lifetime gap is stated honestly and pinned by the earlier bwrap preflight tests, and found no defect in this revision.
  • Lane summary: The new validation refuses a missing deny_read path inside a mount and skips one outside every mount, with a test that exercises both branches, and the bubblewrap docs now state the mask-lifetime gap honestly. I found no defect in this revision; the prior disable_userns concern is addressed by the new test's request builder, and the documented known gap in the mask lifetime is documented and pinned by the earlier bwrap preflight tests.

commits

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The commits lane reports no sensitive content in committed files.
  • Lane summary: No sensitive content in committed files. (1 earlier finding(s) still open)

description

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: The new commits add the missing-denial check for the 2.1 native jail, skip missing denials outside every mount when building argv, and document the mask-lifetime gap; the test's `NativeJailCommand` literal includes `disable_userns`, so the earlier finding no longer stands. The change looks sound to merge.
Evidence and run details
  • Models: ladder/vectors-oai3, deepseek-v4.1-flash
  • Spend: $0.007824
  • Tokens: 507645 input · 15706 output · 93568 cached · 379 embedding
  • Updated: 2026-11-12T16:16:43Z
  • Continuity: summary cache chain restarted at the storage ceiling.
Head State Pass summary
4acfba48cd65 ready for maintainer review 0 active finding(s), 0 resolved finding(s) (at 2026-11-11T18:30:14Z)
99dd8f447388 ready for maintainer review 0 active finding(s), 0 resolved finding(s) (at 2026-11-12T07:31:41Z)
a9eb478d7a90 changes requested 1 active finding(s), 0 resolved finding(s) (at 2026-11-12T08:35:24Z)
93c77d6f4093 changes requested 1 active finding(s), 2 resolved finding(s) (at 2026-11-12T10:12:56Z)
cc4cfd26f9bf ready for maintainer review 0 active finding(s), 7 resolved finding(s) (at 2026-11-12T16:16:43Z)

tinysweeper 0.1.2

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

tinysweeper found nothing blocking. Approving.

Diagnostics

Total spend: $0.0335

@tinysweeper tinysweeper Bot added the priority: p3 Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect. label Nov 11, 2026

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

tinysweeper found nothing blocking. Approving.

Diagnostics

Total spend: $0.0022

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Requesting changes: 1 lane(s) blocking, worst finding is high.

Fix or reply to the findings below and push. The next review clears this automatically once they are gone — you should not need to dismiss anything by hand.

Diagnostics

Total spend: $0.0188

@tinysweeper tinysweeper Bot added priority: p1 Next. Wrong behaviour a user will hit, or a security weakness behind a condition. and removed priority: p3 Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect. labels Nov 12, 2026

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Requesting changes: 3 lane(s) blocking, worst finding is high.

Fix or reply to the findings below and push. The next review clears this automatically once they are gone — you should not need to dismiss anything by hand.

Diagnostics

Total spend: $0.0148

The field arrived on main with the honest-claims change, after this test was
written, so the literal no longer compiled (E0063).
# Conflicts:
#	crates/tinybox-jail/src/bwrap/mod.rs

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The previously-blocking findings are resolved. Clearing the changes request.

Diagnostics

Total spend: $0.0078

@tinysweeper tinysweeper Bot added priority: p3 Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect. and removed priority: p1 Next. Wrong behaviour a user will hit, or a security weakness behind a condition. labels Nov 12, 2026
@M3gA-Mind
M3gA-Mind merged commit e271ae0 into tinyhumansai:main Nov 12, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p3 Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant