[GH-ISSUE #4003] [Feature]: Windows server-extension sandbox (AppContainer) to match Seatbelt/Bubblewrap #2162

Closed
opened 2026-10-21 05:45:52 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @SpicyMarinara on GitHub (Jul 23, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4003

Summary

Personal Extensions ship a server runtime that executes user/third-party JavaScript inside a real OS sandbox. Today only two backends exist — macOS Seatbelt and Linux Bubblewrap — so on Windows the server runtime fails closed: server extensions cannot be approved (HTTP 503) and cannot run. This issue scopes a genuine Windows sandbox backend so Windows users get the same capability at the same safety bar.

This is a follow-up to the extension-hardening work in #4000. Android is intentionally out of scope (unrooted Android cannot host a real process sandbox — Bubblewrap needs unprivileged user namespaces the kernel/SELinux block, and proot provides no isolation; Android users are served by the browser runtime, whose sandbox is the WebView).

Why

  • Windows is a first-class install target, and server-side Personal Extensions are simply unavailable there.
  • The current behavior is safe (fail-closed), but it reads like a bug to a Windows user handed a disabled server extension. Closing the gap removes the platform asymmetry.

The safety bar (non-negotiable)

A Windows backend must match what Seatbelt/Bubblewrap already guarantee. It ships only when it can demonstrably enforce all of:

  • No network — outbound connections denied.
  • Filesystem confinement — read/write limited to the per-extension sandbox dir + the JSONL protocol files; no access to the user profile, Marinara data dir, or system config.
  • Privilege drop — the extension process runs with a low-privilege token, not the Marinara process's token.
  • Resource bounds — memory/CPU/handle caps and kill-on-parent-exit.
  • Fail closed — if any of the above cannot be established at spawn time, refuse to run (never fall back to unsandboxed).

If we cannot meet this bar, we keep Windows disabled. A weaker "sandbox" is worse than an honest "unavailable."

Proposed approach: AppContainer + restricted token + Job Object

This is the same primitive stack Chromium uses for its Windows renderer sandbox:

  1. AppContainer — create a per-extension AppContainer profile (CreateAppContainerProfile) with an empty/minimal capability SID set, giving an isolated object namespace and default-deny access. No network capability SID ⇒ no outbound network.
  2. Restricted / lowbox token — launch the Node child with the AppContainer (lowbox) token so it cannot reach securable objects the Marinara process can.
  3. Filesystem ACLs — grant the AppContainer SID explicit access only to the sandbox dir + protocol files; everything else stays default-deny.
  4. Job Object — assign the child to a job with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, memory/active-process limits, and UI restrictions.
  5. Node --permission as the inner layer — reuse the existing --permission --allow-fs-read/write flags (already used by the Mac/Linux paths) as defense-in-depth under the OS boundary, not as the boundary itself.

The existing file-based JSONL protocol (runner.mjs, input/output/heartbeat/error files) is transport-only and can stay unchanged; only the spawn + confinement layer is new.

Implementation options (needs a decision)

There is no CLI equivalent to sandbox-exec/bwrap on Windows, so we need one of:

  • (A) Shipped native helper .exe — a small C++/Rust launcher that sets up the AppContainer profile, token, ACLs, and Job Object, then CreateProcessAsUser-es Node. Marinara spawns the helper. Pro: keeps Win32 complexity out of Node, easy to unit-test in isolation, no addon build in the main install. Con: a shipped binary to build/sign/maintain per arch.
  • (B) N-API native addon — same Win32 calls via a Node addon. Pro: no separate process. Con: node-gyp build on Windows installs, ABI churn, harder to sandbox-test in isolation.
  • (C) PowerShell/CreateProcess shim — likely insufficient; PowerShell can't cleanly build an AppContainer lowbox token + job in one shot without native calls. Probably a dead end; noted for completeness.

Recommendation: (A) shipped helper exe. It isolates the security-critical code, is independently testable, and avoids per-install native builds. Decide before implementation.

Integration points

  • packages/server/src/services/extensions/personal-extension-sandbox.ts
    • Extend PersonalExtensionSandboxBackend with "windows-appcontainer".
    • Add a win32 branch to getPersonalExtensionSandboxStatus() that probes for the helper/addon and required OS support (AppContainer available, correct Windows edition/version), returning a clear reason when unmet.
    • Add the Windows spawn path in spawnSandboxedPersonalExtension().
  • packages/shared/src/types/personal-extension.ts — add "windows-appcontainer" to PersonalExtensionSandboxBackend and serverSandboxBackend.
  • No change needed to personal-server-extension-runtime.ts gating, runner.mjs, or the routes — they already key off serverSandboxAvailable/serverSandboxBackend generically.

Proof harness (required, mirrors the existing ones)

Extend scripts/regressions/extension-security.regression.ts with a Windows-only proof that, when run on Windows, asserts a sandboxed extension cannot: open a TCP connection, read a file outside the sandbox dir (e.g. the user profile), spawn a child process, or load a native addon — and can do its permitted protocol I/O. Gate it on process.platform === "win32" so other platforms skip. Wire it into Windows CI; the macOS/Linux proofs stay as-is.

Out of scope

  • Android server extensions (browser runtime only there).
  • Windows Sandbox (the disposable-VM feature) — requires Pro/Enterprise + Hyper-V; too heavyweight for a per-extension boundary.
  • Shipping a Node---permission-only Windows path and calling it equivalently safe — it has no network deny and no OS privilege drop, so it does not meet the bar above.

Acceptance criteria

  • A windows-appcontainer backend that enforces the full safety bar, with fail-closed behavior when unmet.
  • getPersonalExtensionSandboxStatus() reports it on supported Windows and a clear reason otherwise.
  • Windows proof harness passes in CI and demonstrates network/fs/child-process/addon denial.
  • Approve/run flow works end-to-end for a server extension on Windows; docs/FAQ/Troubleshooting updated to reflect Windows support and any minimum-edition requirement.
  • No relaxation of the existing fail-closed guards on any platform.
Originally created by @SpicyMarinara on GitHub (Jul 23, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4003 ## Summary Personal Extensions ship a server runtime that executes user/third-party JavaScript inside a real OS sandbox. Today only two backends exist — macOS Seatbelt and Linux Bubblewrap — so on **Windows** the server runtime fails closed: server extensions cannot be approved (HTTP 503) and cannot run. This issue scopes a genuine Windows sandbox backend so Windows users get the same capability at the same safety bar. This is a follow-up to the extension-hardening work in #4000. Android is intentionally **out of scope** (unrooted Android cannot host a real process sandbox — Bubblewrap needs unprivileged user namespaces the kernel/SELinux block, and `proot` provides no isolation; Android users are served by the browser runtime, whose sandbox is the WebView). ## Why - Windows is a first-class install target, and server-side Personal Extensions are simply unavailable there. - The current behavior is *safe* (fail-closed), but it reads like a bug to a Windows user handed a disabled server extension. Closing the gap removes the platform asymmetry. ## The safety bar (non-negotiable) A Windows backend must match what Seatbelt/Bubblewrap already guarantee. It ships **only** when it can demonstrably enforce all of: - **No network** — outbound connections denied. - **Filesystem confinement** — read/write limited to the per-extension sandbox dir + the JSONL protocol files; no access to the user profile, Marinara data dir, or system config. - **Privilege drop** — the extension process runs with a low-privilege token, not the Marinara process's token. - **Resource bounds** — memory/CPU/handle caps and kill-on-parent-exit. - **Fail closed** — if any of the above cannot be established at spawn time, refuse to run (never fall back to unsandboxed). If we cannot meet this bar, we keep Windows disabled. A weaker "sandbox" is worse than an honest "unavailable." ## Proposed approach: AppContainer + restricted token + Job Object This is the same primitive stack Chromium uses for its Windows renderer sandbox: 1. **AppContainer** — create a per-extension AppContainer profile (`CreateAppContainerProfile`) with an empty/minimal capability SID set, giving an isolated object namespace and default-deny access. No network capability SID ⇒ no outbound network. 2. **Restricted / lowbox token** — launch the Node child with the AppContainer (lowbox) token so it cannot reach securable objects the Marinara process can. 3. **Filesystem ACLs** — grant the AppContainer SID explicit access only to the sandbox dir + protocol files; everything else stays default-deny. 4. **Job Object** — assign the child to a job with `JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE`, memory/active-process limits, and UI restrictions. 5. **Node `--permission` as the inner layer** — reuse the existing `--permission --allow-fs-read/write` flags (already used by the Mac/Linux paths) as defense-in-depth under the OS boundary, not as the boundary itself. The existing file-based JSONL protocol (`runner.mjs`, input/output/heartbeat/error files) is transport-only and can stay unchanged; only the *spawn + confinement* layer is new. ## Implementation options (needs a decision) There is no CLI equivalent to `sandbox-exec`/`bwrap` on Windows, so we need one of: - **(A) Shipped native helper `.exe`** — a small C++/Rust launcher that sets up the AppContainer profile, token, ACLs, and Job Object, then `CreateProcessAsUser`-es Node. Marinara spawns the helper. *Pro:* keeps Win32 complexity out of Node, easy to unit-test in isolation, no addon build in the main install. *Con:* a shipped binary to build/sign/maintain per arch. - **(B) N-API native addon** — same Win32 calls via a Node addon. *Pro:* no separate process. *Con:* node-gyp build on Windows installs, ABI churn, harder to sandbox-test in isolation. - **(C) PowerShell/`CreateProcess` shim** — likely insufficient; PowerShell can't cleanly build an AppContainer lowbox token + job in one shot without native calls. Probably a dead end; noted for completeness. **Recommendation: (A) shipped helper exe.** It isolates the security-critical code, is independently testable, and avoids per-install native builds. Decide before implementation. ## Integration points - `packages/server/src/services/extensions/personal-extension-sandbox.ts` - Extend `PersonalExtensionSandboxBackend` with `"windows-appcontainer"`. - Add a `win32` branch to `getPersonalExtensionSandboxStatus()` that probes for the helper/addon and required OS support (AppContainer available, correct Windows edition/version), returning a clear `reason` when unmet. - Add the Windows spawn path in `spawnSandboxedPersonalExtension()`. - `packages/shared/src/types/personal-extension.ts` — add `"windows-appcontainer"` to `PersonalExtensionSandboxBackend` and `serverSandboxBackend`. - No change needed to `personal-server-extension-runtime.ts` gating, `runner.mjs`, or the routes — they already key off `serverSandboxAvailable`/`serverSandboxBackend` generically. ## Proof harness (required, mirrors the existing ones) Extend `scripts/regressions/extension-security.regression.ts` with a Windows-only proof that, when run on Windows, asserts a sandboxed extension **cannot**: open a TCP connection, read a file outside the sandbox dir (e.g. the user profile), spawn a child process, or load a native addon — and **can** do its permitted protocol I/O. Gate it on `process.platform === "win32"` so other platforms skip. Wire it into Windows CI; the macOS/Linux proofs stay as-is. ## Out of scope - **Android** server extensions (browser runtime only there). - **Windows Sandbox** (the disposable-VM feature) — requires Pro/Enterprise + Hyper-V; too heavyweight for a per-extension boundary. - Shipping a **Node-`--permission`-only** Windows path and calling it equivalently safe — it has no network deny and no OS privilege drop, so it does not meet the bar above. ## Acceptance criteria - [ ] A `windows-appcontainer` backend that enforces the full safety bar, with fail-closed behavior when unmet. - [ ] `getPersonalExtensionSandboxStatus()` reports it on supported Windows and a clear reason otherwise. - [ ] Windows proof harness passes in CI and demonstrates network/fs/child-process/addon denial. - [ ] Approve/run flow works end-to-end for a server extension on Windows; docs/FAQ/Troubleshooting updated to reflect Windows support and any minimum-edition requirement. - [ ] No relaxation of the existing fail-closed guards on any platform.
Author
Owner

@SpicyMarinara commented on GitHub (Jul 23, 2026):

Closing as not planned for now — recording the decision so it stays discoverable and re-openable if real demand appears.

Rationale:

  • Dropping this only affects server extensions on Windows. Browser extensions already work on Windows (their sandbox is the browser engine, not the OS), so Windows users keep the runtime most extensions use.
  • The server sandbox is intentionally very narrow (no network, no filesystem beyond the protocol files, no Marinara internals), so a server extension's unique value over a browser one is small — mostly "runs headless without a tab open." That's a niche capability on an already-niche, double-gated, hash-approved opt-in feature.
  • The build is disproportionate to that value: security-critical native Win32 work (AppContainer, restricted tokens, ACLs, Job Objects), a shipped signed helper binary, a Windows CI proof harness, and ongoing maintenance where a mistake means a sandbox that looks real but doesn't contain. There is no cheap-but-safe middle option (a Node --permission-only path is below the safety bar), so it's all-or-nothing.

Instead, the fail-closed behavior stays as the correct safe state, and the docs now state plainly that server extensions require macOS or Linux (with Bubblewrap) and that Windows/Android users should use browser extensions. Re-open if server extensions grow into a capability where the Windows gap becomes a real product cost.

<!-- gh-comment-id:5062437139 --> @SpicyMarinara commented on GitHub (Jul 23, 2026): Closing as **not planned** for now — recording the decision so it stays discoverable and re-openable if real demand appears. Rationale: - Dropping this only affects **server** extensions on Windows. **Browser** extensions already work on Windows (their sandbox is the browser engine, not the OS), so Windows users keep the runtime most extensions use. - The server sandbox is intentionally very narrow (no network, no filesystem beyond the protocol files, no Marinara internals), so a server extension's unique value over a browser one is small — mostly "runs headless without a tab open." That's a niche capability on an already-niche, double-gated, hash-approved opt-in feature. - The build is disproportionate to that value: security-critical native Win32 work (AppContainer, restricted tokens, ACLs, Job Objects), a shipped signed helper binary, a Windows CI proof harness, and ongoing maintenance where a mistake means a sandbox that looks real but doesn't contain. There is no cheap-but-safe middle option (a Node `--permission`-only path is below the safety bar), so it's all-or-nothing. Instead, the fail-closed behavior stays as the correct safe state, and the docs now state plainly that server extensions require macOS or Linux (with Bubblewrap) and that Windows/Android users should use browser extensions. Re-open if server extensions grow into a capability where the Windows gap becomes a real product cost.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#2162
No description provided.