Skip to content

fix(policy): reject Windows filesystem roots as read-write paths - #5303

Open
nv-rahool wants to merge 6 commits into
NVIDIA:windowsfrom
nv-rahool:fix/5302-windows-root-paths/nv-rahool
Open

nv-rahool wants to merge 6 commits into
NVIDIA:windowsfrom
nv-rahool:fix/5302-windows-root-paths/nv-rahool

Conversation

@nv-rahool

@nv-rahool nv-rahool commented Nov 5, 2026 •

Copy link
Copy Markdown

Summary

Reject filesystem roots as read-write grants across POSIX and Windows path spellings. Namespace validation uses constant stack space and skips paths already rejected for exceeding the byte-length limit.

Related Issue

Closes #5302

Changes

  • Recognize Windows drive, UNC share, device, volume, partition, and namespace-link roots independently of the gateway OS, including separator and trailing-dot/space aliases.
  • Preserve narrower drive/share paths and the well-known GLOBALROOT/SystemRoot Windows-directory alias. Unknown object-namespace aliases remain conservatively rejected because they may name an entire volume.
  • Parse repeated namespace links iteratively and skip oversized paths before root classification.
  • Add root-alias, narrower-path, oversized-input, deep-namespace, SystemRoot-compatibility, and gateway-validation regressions.
  • Reuse the VM runtime hashes and K3s installer pin already merged into windows via fix(ci): repair Windows VM runtime and K3s installer pins #5736. The files exactly match that repair, and the VM hashes match published release-asset digests.
  • Update the policy-validation documentation with Windows root rules, the 4096-byte limit, and migration guidance for unsupported namespace aliases.

The existing host-dependent absolute-path check is outside this change.

Compatibility review remains open for conservative rejection of unknown object aliases. The maintainer explicitly chose to retain this protection; documentation and acknowledgement do not remove the current train's compatibility restriction.

Testing

Latest revision: e3739ef7372c5c0c630bd1c972b3d351835c1d6b. The final commit changes CI pins only; the policy code tested locally is unchanged from e84cefb.

  • Native Windows ARM64, Rust 1.95.0: cargo test --locked -p openshell-policy — 308 passed in the unoptimized test profile.
  • Scoped Clippy with warnings denied, Rust formatting, Markdown lint, license headers, and git diff --check.
  • The SystemRoot regression failed before its fix and passed afterward. Native resolution confirmed the \\?\, \\.\, and \??\ GLOBALROOT/SystemRoot spellings resolve to the Windows directory, narrower than the drive root, on the test host.
  • Deep-namespace regressions exercise 20,000 repeated links, oversized validation, and narrower-path controls without recursive stack growth.
  • Windows x64/ARM64, Branch Checks, and E2E CI for the latest commit: requested; results pending.

The full local mise run --skip-tools --jobs 1 pre-commit task was attempted but did not complete: the TypeScript Biome formatter crashes on this Windows ARM64 host with exit 0xC0000005. Earlier Python tooling setup also required an x64 interpreter. This is not reported as a passing full pre-commit run.

The author previously verified Windows x64 gateway/MXC sandbox creation and live policy updates on earlier revisions, including root rejection and narrower-path acceptance. Those manual MXC scenarios have not been rerun locally on the latest revision.

Checklist

  • Conventional Commit messages.
  • Every commit signed off for DCO.
  • Regression tests added.
  • Relevant policy documentation updated; no architecture boundary changed.
  • All requested CI complete and passing.

validate_filesystem_paths only treated POSIX "/" (and repeated "/") as the
filesystem root, so read_write entries such as "C:/", "C:\", "\",
"\\?\C:\" or "\\server\share" passed validation on a Windows gateway and
reached the MXC driver as a whole-drive grant.

Detect roots lexically and independently of the gateway host OS: POSIX
roots, drive roots, the current-drive root, verbatim/device drive roots and
UNC share roots, ignoring repeated separators and "." components. The
shared validator covers sandbox create, live policy updates and the
supervisor's OPA data check.

Signed-off-by: Rahool Paliwal <rpaliwal@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

All contributors have signed the DCO ✍️ ✅
Posted by the DCO Assistant Lite bot.

@nv-rahool

Copy link
Copy Markdown
Author

I have read the DCO document and I hereby sign the DCO.

@nv-rahool

Copy link
Copy Markdown
Author

recheck

@shailendra-nv shailendra-nv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The shared-validator change fixes the reported C:/ case, but two equivalent-root cases still pass the new validation; details are inline. Focused native ARM64 tests using the verbatim PR validator/helper pass the three new policy tests and fail two additional regression tests for these cases. This was extracted-code validation and native path-resolution testing; the full PR build and gateway E2E were not rerun, and no successful workload root write is claimed.

Comment thread crates/openshell-policy/src/lib.rs Resolved
Comment thread crates/openshell-policy/src/lib.rs Resolved

@shailendra-nv shailendra-nv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Requesting changes for the two remaining root-path validation gaps described in the existing inline comments:

  • Windows namespace/separator aliases still pass validation: #5303 (comment)
  • Win32 trailing-dot/space root aliases still pass validation: #5303 (comment)

Please close these gaps and add regression coverage before merging. The PR remains at the reviewed commit, 37ea092. Native ARM64 extracted-code tests confirmed both findings; full PR builds and gateway E2E were not rerun.

is_filesystem_root only recognised the namespace prefix when the original
path started with two backslashes, so "//?/C:/", "/\?\C:\" and the NT
spelling "\??\C:\" passed validation. It also treated only empty and "."
components as naming the root, so "C:/...", "C:/ " and "C:/. " passed even
though Win32 drops trailing dots and spaces from a component. The MXC driver
converts "/" to "\" and resolves each of these paths to the drive root.

Match the "\\?\", "\\.\" and "\??\" prefixes after separator normalization,
and treat two leading separators as a UNC prefix when either is a backslash,
so a POSIX "//tmp/x" keeps its meaning. When deciding whether a path names a
root, ignore trailing dots and spaces in its components, as Win32 does; this
includes paths with a leading "/", which the MXC driver reads as the root of
the current drive. Verbatim and NT paths keep their components as written,
so "\\?\C:\..." remains a narrower path.

Signed-off-by: Rahool Paliwal <rpaliwal@nvidia.com>
@nv-rahool

Copy link
Copy Markdown
Author

Pushed 926cc6a for both review threads.

  • Linux (Rust 1.95.0): cargo test -p openshell-policy --lib passes 304/304; cargo fmt --all --check and cargo clippy -p openshell-policy --all-targets --no-deps -- -D warnings are clean. With the previous is_filesystem_root, the new alias test fails.
  • Windows x64 (Windows Insider 28020.3382): cargo test -p openshell-policy passes 304/304, cargo test -p openshell-server --lib validate_policy_safety passes 8/8, and mise run windows:lint:x64 and mise run windows:build:x64 succeed. For each spelling I compared the validator's result with std::fs::canonicalize of the slash-converted path: every spelling that resolves to \\?\C:\ is rejected, and the accepted controls (\\?\C:\..., \??\C:\ , /tmp/..., C:/work/b35/rw) do not resolve to it.
  • Through a gateway with the MXC driver on the same host:
    • Before this commit, sandbox create rejected none of //?/C:/, /\?\C:\, \??\C:\, //./C:/, C:/..., C:/ , C:/. , \... and \\.\C:\.... //?/C:/ and /\?\C:\ reached Ready; the others failed later in CreateProcessSecurityEnvironment (0x80070057). A live policy set adding //?/C:/, \??\C:\, C:/... or C:/ loaded.
    • With this commit, all of these, plus /... and / , are rejected with InvalidArgument at sandbox create and at policy set. /tmp, C:/work/b35/rw and a live update adding C:/work/b35/rw2 still work. The C:\ ACL was unchanged.

Not changed: //server/share written only with forward slashes is still not treated as a share root, so that POSIX //tmp/x keeps its meaning. On Windows the MXC driver would pass it on as \\server\share.

@shailendra-nv shailendra-nv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Requesting changes: the current revision still accepts a GLOBALROOT device path that names a whole drive. The actionable finding and reproduction evidence are inline.

Reviewed commit: 926cc6a7f49de649f3be30b3378b1a57950d3996 against windows. The separator/namespace and trailing-dot/space cases raised previously are covered by this revision. All four added policy tests passed in an isolated native Windows ARM64 harness using the exact validator/helper; the additional GLOBALROOT rejection regression failed with Ok(()). Full crate/server tests and MXC end-to-end enforcement were not rerun.

Separately, linked issue #5302 lacks state:accepted, and the PR author's verified repository permission is read, so the target branch's issue-acceptance requirement remains unmet.

Comment thread crates/openshell-policy/src/lib.rs Resolved
is_filesystem_root took the first name after "\\?\", "\\.\" or "\??\" as
the volume, so "\\?\GLOBALROOT\Device\HarddiskVolume4\" was read as the
directory "Device\HarddiskVolume4" on a volume called GLOBALROOT and passed
validation. GLOBALROOT links to the root of the NT object namespace, so the
path names the whole volume, and the MXC driver accepts grants in that
namespace.

Read the name after the prefix as an entry of the "\??" directory: "UNC"
and drive letters as before, "Global" as a link back to the same directory,
and "GLOBALROOT" as the object namespace root. Below that root, "\??",
"\GLOBAL??" and "\DosDevices" hold the same names, and a "\Device" path
names a volume after the device name, after "HarddiskN\PartitionM" for a
disk, or after the server and share for a network redirector. Any other
object path is treated as a root, because a link elsewhere in the namespace
can name a whole volume.

Signed-off-by: Rahool Paliwal <rpaliwal@nvidia.com>
@nv-rahool

Copy link
Copy Markdown
Author

Pushed d644341 for the GLOBALROOT review.

  • Linux (Rust 1.95.0): cargo test -p openshell-policy --lib passes 305/305; cargo fmt --all --check and cargo clippy -p openshell-policy --all-targets --no-deps -- -D warnings are clean. Against the previous is_filesystem_root, the new test fails on \\?\GLOBALROOT\Device\HarddiskVolume4\.
  • Windows x64 (Windows Insider 28020.3382, C: = \Device\HarddiskVolume4 = \Device\Harddisk0\Partition4): cargo test -p openshell-policy passes 305/305, cargo test -p openshell-server --lib validate_policy_safety passes 8/8, and mise run windows:lint:x64 and mise run windows:build:x64 succeed. For each spelling I compared the validator's result with std::fs::canonicalize:
    • Rejected, and each resolves to \\?\C:\: \\?\, \\.\ and \??\GLOBALROOT\Device\HarddiskVolume4\, \\.\GLOBALROOT\Device\HarddiskVolume4\. , \\?\GLOBALROOT\Device\Harddisk0\Partition4\, \\?\GLOBALROOT\??\C:\, \\?\GLOBALROOT\GLOBAL??\C:\, \\?\GLOBALROOT\DosDevices\C:\, \\?\Global\C:\, \\.\Global\C:\, \\?\GLOBALROOT\??\Global\C:\ and the volume GUID path.
    • Also rejected: \\?\GLOBALROOT\Device\Mup\localhost\C$\ (resolves to \\?\UNC\localhost\C$), and \\?\GLOBALROOT\SystemRoot (C:\Windows) under the unknown-object-path rule.
    • Accepted, and each resolves to C:\work\b35 or the matching share path: \work\b35 under each of the device, partition, GLOBALROOT\??, Global, Mup and volume GUID spellings.
  • Through a gateway with the MXC driver on the same host (Session 0):
    • sandbox create rejects \\?\, \\.\ and \??\GLOBALROOT\Device\HarddiskVolume4\, //?/GLOBALROOT/Device/HarddiskVolume4/, \\?\GLOBALROOT\??\C:\, \\?\Global\C:\ and \\?\GLOBALROOT\SystemRoot with InvalidArgument ("policy contains…"). \\?\GLOBALROOT\Device\HarddiskVolume4\work\b35\rw and C:/work/b35/rw reach Ready.
    • A live policy set adding \\?\GLOBALROOT\Device\HarddiskVolume4\ or \\?\Global\C:\ is rejected with InvalidArgument; one adding \\?\GLOBALROOT\Device\HarddiskVolume4\work\b35\rw2 loads (version 2). The C:\ ACL was unchanged.
    • I did not run a workload write test with the unfixed build, so I have not checked whether MXC would have granted the whole volume.

@shailendra-nv shailendra-nv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-reviewed d6443414ac2b35644c9307bfa0bc5c984f263fc1. The previously reported GLOBALROOT root alias is now rejected, including all three native namespace spellings. All five added policy tests plus the native-resolution regression passed in the isolated Windows ARM64 harness.

Requesting changes for one new regression: unbounded namespace recursion still runs on paths already marked too long, causing a reproducible stack-overflow abort in unoptimized development/test builds. The inline comment contains the before/after evidence and the optimized-build limitation.

The condition for proceeding to /windows-ci, approval, and merge has not been met because this actionable finding remains. No full crate/server tests or MXC end-to-end tests were run in this re-review.

Comment thread crates/openshell-policy/src/lib.rs Resolved
Signed-off-by: Shailendra Singh <shailendras@nvidia.com>
@shailendra-nv shailendra-nv added test:e2e Requires end-to-end coverage test:windows Run native Windows x64 and ARM64 lint/tests on PR mirrors labels Nov 19, 2026 — with ChatGPT Codex Connector

Copy link
Copy Markdown
Collaborator

/windows-ci

Copy link
Copy Markdown
Collaborator

/ok to test 41f9399

@github-actions

Copy link
Copy Markdown

Label test:e2e applied, but pull-request/5303 does not exist yet. A maintainer needs to comment /ok to test 41f93990d9cd556577abe35c1356fba5f882430e to mirror this PR. Once the mirror exists, re-apply the label or re-run Branch E2E Checks from the Actions tab.

@github-actions

Copy link
Copy Markdown

Compatibility review (advisory)

Unaddressed breaking changes

The candidate rejects valid narrower Windows namespace paths, not only filesystem roots. This breaks existing policy files on a non-breaking train.

1. policy — ACKED

A Windows read_write path such as //?/GLOBALROOT/SystemRoot was accepted as an absolute subdirectory but is now rejected as an overly broad filesystem root.

  • Impact: Existing policies using narrower object-namespace aliases fail openshell sandbox create and openshell policy set with INVALID_ARGUMENT.
  • Action: Restrict namespace-root detection to paths known to denote whole volumes so narrower aliases remain valid on this non-breaking train.
  • PR: fix(policy): reject Windows filesystem roots as read-write paths #5303
Review details
  • Execution: complete
  • Candidate: PR #5303 (e47a04c6e83fbb97d6f0cb273f868e02b0453591)
  • Baseline: 5b9e5b91afb10afbce8d9be09e2513a7efc22a21 (5b9e5b91afb10afbce8d9be09e2513a7efc22a21)
  • Reviewed: rust-sdk, python-sdk, go-sdk, typescript-sdk, api-behavior, cli, configuration, policy, helm, state

Advisory review; publication gates are unchanged.

Branch check run

shailendra-nv commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Bot-comment follow-up for e84cefb:

  • SystemRoot compatibility finding: fixed in e84cefb. The well-known link names the Windows directory, so it and its subdirectories are preserved. A regression failed before the fix and now passes across namespace prefixes and case variants. Native Windows ARM64 resolution confirmed all three native spellings name C:\Windows on the test host. All 308 policy tests, scoped Clippy, and formatting checks pass.
  • Remaining compatibility finding: OPEN. The fresh reviewer correctly notes that conservatively rejecting other unknown object aliases can reject previously accepted narrower aliases. The maintainer explicitly chose to retain that protection and leave this finding open, rather than allow aliases that might name whole-volume roots. Migration guidance is published, but acknowledgement and documentation do not make this compatible with the current non-breaking train. A compatible release decision or a separately verified solution that preserves root protection is still needed before approval/merge.
  • Runner admission / E2E hint: satisfied. The latest commit is mirrored to pull-request/5303, and Windows, Branch Checks, and E2E runs are active for that exact head. The original missing-mirror hint is stale; no running suite is being counted as passed.
  • DCO: both new commits are signed off and the current DCO check passes.
  • Issue acceptance: bug(policy): Windows drive and share roots are accepted as read_write paths #5302 is explicitly attached and marked state:accepted at the maintainer's direction; the current acceptance check passes.

The separate maintainer-approval requirement also remains pending. All existing inline review threads are resolved, but the remaining compatibility advisory above has deliberately not been marked resolved.

@sam-india-007

sam-india-007 commented Nov 19, 2026 •

Copy link
Copy Markdown

Windows ARM64 CI: ⌛ running

Commit e3739ef, requested by @shailendra-nv

Signed-off-by: Shailendra Singh <shailendras@nvidia.com>

Copy link
Copy Markdown
Collaborator

/windows-ci

Copy link
Copy Markdown
Collaborator

/ok to test e84cefb

@github-actions

Copy link
Copy Markdown

Compatibility review (advisory)

Unaddressed breaking changes

Existing policies using unrecognized Windows object-namespace aliases in filesystem_policy.read_write can now fail with INVALID_ARGUMENT. The PR acknowledges the impact and documents migration, but this train allows no Stable breaks.

1. policy — ACKED

Absolute read_write paths using unrecognized GLOBALROOT aliases were accepted previously but are now rejected conservatively with INVALID_ARGUMENT.

  • Impact: Sandbox creation and policy updates from the CLI or any SDK fail until affected policies replace those aliases with absolute drive or share paths.
  • Action: Defer conservative rejection of unrecognized object-namespace aliases to a breaking train, or preserve previously accepted aliases while continuing to reject known filesystem roots.
  • PR: fix(policy): reject Windows filesystem roots as read-write paths #5303
Review details
  • Execution: complete
  • Candidate: PR #5303 (453f2c94507131f057414b60de14007d0239fa88)
  • Baseline: 5b9e5b91afb10afbce8d9be09e2513a7efc22a21 (5b9e5b91afb10afbce8d9be09e2513a7efc22a21)
  • Reviewed: rust-sdk, python-sdk, go-sdk, typescript-sdk, api-behavior, cli, configuration, policy, helm, state

Advisory review; publication gates are unchanged.

Branch check run

Apply the VM runtime hashes and K3s installer pin already merged into windows in NVIDIA#5736. The runtime hashes match the published release asset digests.

Signed-off-by: Shailendra Singh <shailendras@nvidia.com>

Copy link
Copy Markdown
Collaborator

/windows-ci

Copy link
Copy Markdown
Collaborator

/ok to test e3739ef

Copy link
Copy Markdown
Collaborator

E2E diagnosed and repaired in new commit e3739ef: the previous head's macOS VM build failed because its pinned runtime archive hash was stale. The VM runtime and K3s installer files now exactly match the already-merged Windows repair in #5736 (f0db2ee); the three runtime hashes also match GitHub's release-asset digests. No checksum validation was disabled. Fresh CI has been requested for this head.

The policy code remains identical to e84cefb (308 native ARM64 tests and scoped Clippy passed). The remaining compatibility advisory for unknown object aliases stays open, with the root protection retained as requested.

@github-actions

Copy link
Copy Markdown

Compatibility review (advisory)

Unaddressed breaking changes

Stable policy validation now rejects previously accepted Windows object-namespace read-write paths, including aliases that may target narrower directories. Migration is documented and the risk is acknowledged, but this train does not allow breaks.

1. policy — ACKED

Unknown Windows GLOBALROOT object aliases previously passed filesystem validation but now return INVALID_ARGUMENT, except for the recognized SystemRoot alias.

  • Impact: Existing policies using a narrower unknown object alias fail during sandbox creation or policy application even when the alias does not grant a filesystem root.
  • Action: Preserve narrower unknown aliases in this non-breaking train, or defer their rejection to a break-allowing train while retaining the documented drive-or-share-path migration.
  • PR: fix(policy): reject Windows filesystem roots as read-write paths #5303
Review details
  • Execution: complete
  • Candidate: PR #5303 (e805ad0cbe5bb64498e7644fb667956547c03efd)
  • Baseline: 5b9e5b91afb10afbce8d9be09e2513a7efc22a21 (5b9e5b91afb10afbce8d9be09e2513a7efc22a21)
  • Reviewed: rust-sdk, python-sdk, go-sdk, typescript-sdk, api-behavior, cli, configuration, policy, helm, state

Advisory review; publication gates are unchanged.

Branch check run

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:e2e Requires end-to-end coverage test:windows Run native Windows x64 and ARM64 lint/tests on PR mirrors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(policy): Windows drive and share roots are accepted as read_write paths

3 participants