mxc icon indicating copy to clipboard operation
mxc copied to clipboard

PSEC: volume root of a granted path can't be opened for attributes

Open reflectronic opened this issue 1 month ago • 6 comments

Relevant area(s)

Windows

Brief description of your issue

BFS allows opening ancestors of granted paths for SYNCHRONIZE | FILE_READ_ATTRIBUTES, but not the volume root directory. So CreateFileW("D:\", FILE_READ_ATTRIBUTES, …), GetFileInformationByName("D:\", …) and GetVolumeInformationW("D:\") fail, even though the same opens and queries succeed on D:\dir.

Steps to reproduce

  1. Create a PSEC security environment that grants fs_read_only = ["D:\dir\dir2"].
  2. Launch a process in the security environment that calls the three functions above on D:\ and D:\dir.

Expected behavior

The volume root behaves like any other ancestor of a grant (can be opened for SYNCHRONIZE | FILE_READ_ATTRIBUTES).

Actual behavior

All three calls fail on D:\ with ERROR_ACCESS_DENIED and succeed on D:\dir.

This breaks common programs. For example, cmd /d /c dir prints Access is denied., even in a granted writable directory, since cmd calls GetVolumeInformationW on the volume root.

Windows 10.0.26300.9550, PSEC 1.1.

reflectronic avatar Oct 10 '26 00:10 reflectronic

@daniedud-MSFT is this expected behavior?

bbonaby avatar Oct 26 '26 06:10 bbonaby

I'm fairly confident this is a bug and that we have a fix in production for this, but we'll need to do a repro on our side and confirm.

daniedud-MSFT avatar Oct 26 '26 17:10 daniedud-MSFT

We expect a partial fix for this to come out in a later Windows Update, fixing the access to root. However, we still have a bug with GetFileInformationByName, which we'll keep working on fixing.

daniedud-MSFT avatar Nov 02 '26 22:11 daniedud-MSFT

Supplement to microsoft/mxc#1461 — restricted Windows/JDK volume-metadata denial

The changed-host diagnostic still reproduces the volume-root metadata denial.

Current Windows: 26H2 / build26300.9818. Current OpenAI-signed Codex executable SHA256: 3097c909fb6d5cd63510d44aceb1d42df9f6e85722a3e447e477def1ecf60e16 It was used only for a fresh separately pinned diagnostic. The old October runtime is absent; its original pin and records are preserved.

Invocation48803721b62e4a99a204142ea6484b65, 2026-11-03T08:00:42Z:

  • Explicit windows.sandbox=mxc, managed configuration included, no fallback.
  • Same original submitted path policy: root deny, minimal read, exact project/cache writable, selected tools and .git/.codex read-only, fresh denied canary; external networking submitted disabled.
  • Unchanged observer PASS under ordinary non-elevated identity, with allowed read, denied canary, and owned write observed. Source/tool guards286/17PASS.
  • JDK21.0.12.1+1-LTS diagnostic compilation exit0; direct NIO and NIO temp PASS.
  • File.createTempFile fails at WinNTFileSystem.getNameMax0, Java exit17.
  • GetVolumeInformationW(D:) returns false/error5. No directory enumeration.
  • No Gradle or capture was invoked. Probe temporary files remaining0.

A separate outer controller limitation left its root exit code UNKNOWN, although root exit was observed. The explicit Java/native receipts above are retained; no outer success or build acceptance is claimed, and no replay ran. The historical October capture DesiredAccess and original stack remain UNKNOWN. This does not prove every Gradle startup failure has the same cause as #1461.

Your November2 reply mentions a later Windows Update partial root fix. Please identify the fixed KB/build/revision and supported applicability to this host, or the exact required Codex/MXC policy translation correction. We need volume metadata without recursive drive reads, directory enumeration, elevation, unrestricted fallback, or changes to externally managed requirements. The emitted MXC/PSEC schema/revision remains UNKNOWN and needs vendor identification from the pinned Codex artifact.

OS-level external-network isolation and Gradle raw localhost IPC remain unqualified. No raw traces, user identity, private hostname, secret, session history or configuration dump is attached.

https://github.com/microsoft/mxc/issues/1461#issuecomment-6589633729

SimCardia avatar Nov 03 '26 08:11 SimCardia

Additional data points from a Windows process container, in case they help narrow this down. Windows 11 build 26200.9711, MXC SDK 1.0.0 (wxc-exec), containment: "processcontainer", allowDaclMutation: false, NTFS, secondary fixed drive.

1. A volume root in readwritePaths denies everything under it, reads included.

filesystem find D:\data\inner
readwritePaths: ["D:\\"] Access is denied. (os error 5)
readonlyPaths: ["D:\\"] works
readwritePaths: ["D:\\data"] works
readonlyPaths: ["D:\\"], readwritePaths: each top-level entry of D:\ works, including with System Volume Information and $RECYCLE.BIN in the list

readwritePaths: ["C:\\"] alone gives the same denial. There's no error at launch, so a caller granting a whole drive sees programs fail one by one. We now work around it with the last row, which gives up creating files directly at the top of the drive. Is a read-write volume root expected to work?

2. Adding the volume root to enumeratePaths fixes the root metadata failures for a grant on a secondary drive. With readwritePaths: ["D:\\data\\inner"], and C:\ read-only:

Inside the granted folder Parents in enumeratePaths, no root Root in enumeratePaths too
cmd /d /c dir Access is denied. works
Python os.stat("D:\\") fails works
uutils df . no file systems processed works
uutils mv a.txt b.txt Permission denied works
cat on a file outside the grant denied denied

That workaround only needs the root listed. The trade-off is that the root's names become visible.

3. Possibly relevant to #1676. Under the same no-root policy, Python os.rename, os.replace, git init and uutils rm all worked, and only uutils mv failed. So in our case the rename itself was allowed, and the failure looks like the root query. We haven't tried that issue's exact repro, and it's on the system drive, so it may be a different cause.

We haven't tested on SDK 1.0.1 or with the JDK.

mutewinter avatar Nov 05 '26 19:11 mutewinter

Another data point for this issue: Node.js can't start in a BaseContainer unless the volume root has an enumerate grant. This is on 26200.9725, after the October update that fixed #1464.

  • Windows 11 Home 25H2, build 26200.9725
  • @microsoft/mxc-sdk 1.0.1 (wxc-exec), tier base-container
  • Node.js v22.23.4

Policy.

  • readwritePaths: the working folder.
  • readonlyPaths: the Node install folder.
  • enumeratePaths: tried two ways, empty and with only the non-root ancestors (C:\P6Run, C:\Tools).

Result. With both, node script.js fails before any user code runs:

Error: EPERM: operation not permitted, lstat 'C:\'
    at Object.realpathSync (node:fs:2759:25)
    at toRealPath (node:internal/modules/helpers:61:13)
    at Function._findPath (node:internal/modules/cjs/loader:760:22)
    at resolveMainPath (node:internal/modules/run_main:39:23)

npm fails the same way. Python and .NET console builds work under the same policy.

Adding C:\ to enumeratePaths makes Node work, but the grant reaches past the root itself. A contained process can then list names across the whole drive, including folders it has no read or write grant for. File contents stay denied. When one machine keeps several projects apart, each container can see the other projects' file names.

Two questions:

  1. Will the partial fix you mentioned (access to the root) cover Node's lstat('C:\'), that is, opening the root for attributes with no enumerate grant?
  2. Until then, is there a way to grant attribute access on the volume root without enumerate access to everything under it?

DrappierTechnologies avatar Nov 11 '26 17:11 DrappierTechnologies