Skip to content

app: pin nested repositories and refuse unprotected worktrees in the Linux sandbox - #1699

Closed
eXsoR65 wants to merge 3 commits into
ashhart:mainfrom
eXsoR65:sandbox-git-gaps
Closed

eXsoR65 wants to merge 3 commits into
ashhart:mainfrom
eXsoR65:sandbox-git-gaps

Conversation

@eXsoR65

@eXsoR65 eXsoR65 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Closes the two git gaps that kept the Linux command sandbox out of #1122. Refreshed onto
upstream/main 1fae9d9c4. The bubblewrap backend is
back on top of current main, with nested repositories pinned and worktrees that reach outside the
workspace refused. It stays opt-in (TENSORFOLD_LINUX_SANDBOX=1); Linux commands keep failing
closed without it.

Fixes #1693.

What was broken

  • Nested repositories. Only the workspace root's .git was pinned. A repository nested under the
    workspace, or a submodule, let a sandboxed command rewrite its config and plant hooks.
  • Worktrees. When .git is a file (gitdir: …), the real metadata can live outside the
    workspace. The profile never mounted it, and the command ran anyway — unprotected, not refused.

What it does now

  • Every .git under the workspace is pinned like the root: writable bind, read-only config,
    config.worktree, hooks, info. The walk is bounded (2048 entries, depth 8) and refuses instead
    of pinning a subset.
  • A worktree whose resolved gitdir or shared commondir lies outside the workspace is refused; so is
    a workspace with no repository, because bwrap cannot deny creating .git by name. Refusal returns
    code 126 with the reason, and nothing runs.
  • New tests fail without each fix: removing the nested walk fails "nested .git pinned"; restoring the
    pre-change worktree handling fails "Missing expected exception".

Receipt

  • Tests on head 21dd5495: npm test 857/857 passed, 0 failed; typecheck clean;
    linux-port-docs guard clean; git diff --check clean.
  • Conformance (real namespace, opt-in): filesystem containment, git controls, nested repository
    config/hooks read-only
    , worktree refusal, network denial/allowing, cancellation.
  • Not run: a host without bwrap; the conformance test prints a skip there instead of claiming a
    pass. No distro other than Debian 13.
  • CI on this head: all 11 checks pass — desktop (macOS 15), desktop-linux, appimage-linux,
    mobile, zig, fmt, zig-windows, zig-macos-dev-tools, release-paths, and both
    benchmark-clients jobs.
  • Coordination: atc check 1693 reports yours with this pull request linked;
    atc overlap reports no conflicting pull requests for the seven changed files, though it marks its
    own coverage incomplete (invalidPulls, pullFilesLimit, pullFilesUnavailable, timeLimit).
    atc who finds no open pull request or worktree touching any of the seven files.

Limits

  • Opt-in until a maintainer decides it defaults on; commands stay refused otherwise.
  • The remaining deviation is the workspace-without-repository case: it is refused, not protected by a
    mount rule.
  • Still no clean-machine install test here; this branch changes no packaging.

…Linux sandbox

A writable workspace pinned only its own .git, so a nested repository or
submodule could have its config and hooks changed from inside the sandbox,
and a worktree pointer could name a gitdir the profile never mounted. Pin
every .git under the workspace with the same read-only control entries,
and refuse a worktree whose gitdir or shared directory is outside the
workspace. A workspace with no repository keeps commands refused, because
bwrap cannot deny creating .git by name.
@eXsoR65

eXsoR65 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Refreshed onto current main (1fae9d9c4, head 21dd5495) and re-ran everything: 11/11 checks green, including desktop on macos-15, desktop-linux, appimage-linux and mobile. Locally 857/857 plus the bubblewrap conformance run.

The one design choice worth your call: a worktree whose gitdir is outside the workspace is refused rather than pinned read-only. Refusing keeps the promise that sandboxed commands cannot reach metadata the profile did not mount; pinning would keep worktree users working but mounts a path outside the workspace and needs commondir handling. The issue (#1693) lists both with costs. Happy to switch if you prefer the other tradeoff.

@ashhart

ashhart commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Thank you for this, @eXsoR65. The TensorFold app's work is now handled separately from the engine work in this repo, and this PR has had no activity since 2026-11-06, so I'm closing it to keep the open list honest. If you'd like to take it up again, reopen it or open a new one against today's main and we'll look.

  • Synthena (Ash's Agent)

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.

Issue: Linux command sandbox — close the git and worktree gaps

2 participants