Skip to content

2.39.0: commands run sandboxed on Windows under every workspace posture - #54

Merged
lpalbou merged 12 commits into
mainfrom
windows-sandbox-all-postures
Nov 25, 2026
Merged

lpalbou merged 12 commits into
mainfrom
windows-sandbox-all-postures

Conversation

@lpalbou

@lpalbou lpalbou commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Extends the Windows command sandbox to the two workspace shapes 2.38.0 refused (root backlog 1341): allowed_only ("Deny everything, allow listed workspaces") and any_except_denied with a read-only default; fixes found on the way in the released shape (git in rows inside a refused folder, role changes, permission changes on content, a lock a command could take). Reports drives that store no permissions (exFAT, FAT, network shares).

Verification: the implementer's module (334 tests), an independent contract module written without seeing the implementation (255 tests, three shapes), the platform-independent rule tests, and a real-host smoke that runs the three shapes on the CI runner's real profile and drives; three adversarial rounds (final verdict: releasable; its two last items, the token-size ceiling and one README sentence, are fixed in 4251d06). Limits are listed in abstractcore/tools/README.md (Command sandbox, Windows).

Both shapes now run sandboxed on Windows instead of refusing every command
(host_sandbox_kind is windows-restricted-token for both postures).

Writes are limited to the read & write rows, the private workspace and its
.tmp: the restricted token (mirror of the user plus one SID per rule) runs
at integrity level 6144, between Low and Medium, so every unlabelled object
and registry key refuses its writes; the rows are labelled 6144 (children
first, the folder's own label last as the completion mark). Such a label is
inert for every other program, so it stays. Each labelled folder refuses
writes to its own guard SID, listed in a state folder every such policy
refuses; every token holds the guard SID of each labelled folder its policy
can reach but not write, so a folder one run writes stays read-only to the
others while and after it runs.

"Deny everything" refuses the user's data computed from the machine: the
profile, each fixed drive (when it holds no system root and is the user's to
change) or each changeable folder at its root that is not a system root, and
the user's recycle bin folder. The folders on the way to a row list their
names (carve-list / pass-list): git needs GetLongPathNameW on its working
folder. Folders Windows labels Low (LocalLow, Favorites) are guarded under the
read-only default.

WINDOWS_ALLOW_LIST_UNEXPRESSIBLE and WINDOWS_READ_ONLY_UNEXPRESSIBLE are
removed. Tests run the refusal, nesting, read-only and built-in matrices for
the three shapes, plus writes outside the rows (registry included), runs
sharing folders (sequential, overlapping, nested, a killed launcher, the
remaining first-labelling window) and the tools.
…, real-host smoke

Carved folders and the folders on the way to a row list the names directly
inside them in every shape (never their content): git needs GetLongPathNameW
on its working folder and failed in a run's own folder inside the gateway's
data folder under the read & write default ("Unable to read current working
directory"). The carve-list / pass-list variants are gone; carve entries
written by 2.38.0 for the same rule SIDs are replaced in place at the next
launch.

Only name-surrogate reparse points (junctions, symbolic links) are skipped
inside a carved folder: a cloud file placeholder or an app alias is the object
itself and was left readable. The security calls take \?\ paths, so a name
longer than 260 characters is refused whether or not long paths are enabled.
A child counts as reachable when the user may read, list, run or pass through
it; one that is reachable and whose permissions the user cannot change stops
the command (exit 126 naming it), one that is not needs no refusal.

Tests: git in the gateway layout under the three shapes, the 2.38.0 upgrade,
the kinds a real profile holds (junctions onto a folder on the way, cloud and
alias reparse points, hidden and long-named files, unchangeable children
readable or not, children that come and go during the check), and
test_sandbox_windows_real_host.py, which runs only with
ABSTRACTCORE_SANDBOX_REAL_HOST=1 (set in the windows-sandbox CI job).
… can take, unprotected drives

A folder made inside a refused folder after a first command can later be a
read & write or read-only row, or lie on the way to a deeper row, and is
refused again when no longer listed: every row and folder on the way directly
inside a carved folder is looked at again at each launch, its refusal is
always one a row on that path overrides (entries written for a former role,
and unmarked copies Windows leaves in folders whose list is not marked as
inheriting, as a real profile's are, are moved to where they are inherited),
and carved folders are put in force before the rows inside them. A row there
with permissions of its own fails closed with the remedy.

Content of a read & write row is the command's, its permissions included (the
row folder's own permissions and label are not). This also ends the hang of
tempfile.mkdtemp, venv, ensurepip and pip install in rows inside a refused
folder: mkdtemp retried its private folder 2**31 times.

The launchers' lock is a file in the state folder instead of a session-wide
named mutex any command could hold or poison; the state folder is refused in
every shape, and its list of labelled folders carries its own hash: missing or
damaged, confined commands do not run.

Drives without access lists (exFAT, FAT) and network shares are never part of
the allow-list floor, are reported in the result (sandbox.unprotected), and a
refused or read-only row there stops the command; nothing is written there.
…of buckets

A folder on the way to a row may hold a list of its own: its pass entries come
before any grant, so they are its refusal. The real-host smoke on GitHub's
administrator runner showed it: C:\Users can be refused there, and the
profile, whose list is always its own, lies on the way to every run's folder;
every allow-list command stopped.

Every labelled folder also refuses writes to one of 256 bucket SIDs (a hash of
its path), and every token whose writes are limited holds every bucket but
those of its own rows and of the labelled folders inside them. Another run's
folder is refused with no list at all, including one labelled for the first
time after the token was made, except where its bucket is one of the run's own
rows (1 pair in 256), which the list still covers. A lost or damaged list is
started again silently. 256: a token with 512 extra SIDs or more reads files
measurably slower; 4096 is more than a restricted token takes.
…imits measured

The contract tests' first-labelling limit now expects what the bucket guard
leaves: a command already running when a folder is first labelled writes it
only when its own row shares the folder's bucket. The windows-sandbox job runs
them next to the module.

A test shows that permissions a command gives content of its own row open
nothing another run refuses to read. The README states, as measured per shape,
what git does (https and the ordinary commands work; local clones, hooks and
aliases that need git's shell do not under the confined shapes), what Windows'
ssh-keygen leaves behind, the bucket guard and its one-in-256 exceptions, and
the per-launch cost of re-checking folders on the way.
…without Git Bash change (limits d and e)

Measured on GitHub's runner: MSYS programs start under the confined shapes when no normal one runs in the session, and an administrator's C:\Users is the refused root with the profile inside it. The README says when Git Bash stops.
@lpalbou
lpalbou marked this pull request as ready for review November 25, 2026 00:34
@lpalbou lpalbou changed the title Windows command sandbox: "Deny everything, allow listed workspaces" and a read-only default 2.39.0: commands run sandboxed on Windows under every workspace posture Nov 25, 2026
@lpalbou
lpalbou merged commit 3160eb5 into main Nov 25, 2026
13 checks passed
@lpalbou
lpalbou deleted the windows-sandbox-all-postures branch November 25, 2026 17:12
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