Skip to content

fix: preserve denyRead precedence in linux mount planner#100

Merged
jy-tan merged 1 commit intomainfrom
mount-planner
Apr 3, 2026
Merged

fix: preserve denyRead precedence in linux mount planner#100
jy-tan merged 1 commit intomainfrom
mount-planner

Conversation

@jy-tan
Copy link
Copy Markdown
Contributor

@jy-tan jy-tan commented Apr 2, 2026

Summary

Prevent overlapping Linux filesystem deny rules from re-exposing masked paths by replacing the late exact-path dedupe with subtree-aware mount planning.

The new planner makes denyRead masks take precedence over later read-only self-binds from denyWrite, mandatory dangerous-path protection, and runtime exec deny, including descendant paths under a masked directory.

Resolves #87.

Changes

  • Add internal/sandbox/linux_mount_planner.go to plan the late policy overlays for denyRead, mandatory dangerous-path protection, denyWrite, and runtime exec deny
  • Encode explicit precedence rules for overlapping mounts:
    • a masked ancestor beats any later same-path or descendant self-bind
    • same-path denyRead + denyWrite stays masked instead of becoming visible read-only
    • child denyWrite entries under a masked directory are ignored
    • redundant read-only descendant mounts are pruned
  • Simplify internal/sandbox/linux.go by delegating only the overlay/security phases to the planner and leaving the base, special mounts, and cross-mount repairs imperative
  • Add unit tests for planner conflict resolution and command generation for same-path and child-path overlap cases
  • Add Linux integration regressions covering the original ~/.ssh overlap and the stronger child-under-masked-parent case

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 4 files

@jy-tan jy-tan requested a review from dwt April 2, 2026 02:50
@jy-tan jy-tan merged commit 90707e3 into main Apr 3, 2026
6 checks passed
@jy-tan jy-tan deleted the mount-planner branch April 3, 2026 06:44
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.

denyRead directories remain readable when also in denyWrite

1 participant