Skip to content

Feature [process containment]: Enumerate FS config (Issue 1162) - #1163

Merged
Jeff Whiteside (jsidewhite) merged 7 commits into
mainfrom
jsidewhite/issue_1162
Sep 16, 2026
Merged

Jeff Whiteside (jsidewhite) merged 7 commits into
mainfrom
jsidewhite/issue_1162

Conversation

@jsidewhite

@jsidewhite Jeff Whiteside (jsidewhite) commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

Adds support for fs_enumerate for applications that call FindFirstFile/FindNextFile.

Closes #1162

Microsoft Reviewers: Open in CodeFlow

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Tier detection can misreport unsupported hosts, and new diagnostics log unescaped user-controlled paths.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Adds schema 0.9 filesystem enumeration-only access for PSEC 1.1 BaseContainer hosts.

Changes:

  • Plumbs enumeratePaths through contracts, models, SDKs, and PSEC serialization.
  • Adds capability probing and fail-closed backend validation.
  • Adds unit, serialization, and regression coverage.
File Description
tests/​regression_tests/​TestCases.psd1 Registers regression case 1162.
tests/​regression_tests/​test_cases/​Invoke-Issue1162-ProcessContainerFsEnumerate.ps1 Tests enumeration without content reads.
src/​core/​wxc_common/​src/​wire.rs Adds the rolling wire field.
src/​core/​wxc_common/​src/​validator.rs Restricts the feature to ProcessContainer.
src/​core/​wxc_common/​src/​policy_identity.rs Verifies policy-hash sensitivity.
src/​core/​wxc_common/​src/​models.rs Adds the runtime policy field.
src/​core/​wxc_common/​src/​config_parser.rs Maps, validates, and normalizes paths.
src/​core/​wxc_common/​src/​config_contract_adapters/​v0_8.rs Preserves the older contract shape.
src/​core/​wxc_common/​src/​config_contract_adapters/​v0_7.rs Preserves the older contract shape.
src/​core/​wxc_common/​src/​config_contract_adapters/​v0_6.rs Preserves the older contract shape.
src/​core/​wxc_common/​src/​config_contract_adapters/​dev/​common.rs Adapts the development field.
src/​core/​mxc-sdk/​tests/​streaming.rs Updates SDK test construction.
src/​core/​mxc-sdk/​tests/​streaming_processcontainer.rs Updates ProcessContainer tests.
src/​core/​mxc-sdk/​tests/​streaming_bubblewrap.rs Updates Bubblewrap tests.
src/​core/​mxc-sdk/​tests/​sdk_helpers.rs Updates SDK helper tests.
src/​core/​mxc-sdk/​tests/​sandbox.rs Updates sandbox request tests.
src/​core/​mxc-sdk/​tests/​isolation_session.rs Updates IsolationSession tests.
src/​core/​mxc-sdk/​README.md Documents capability discovery.
src/​core/​mxc_engine/​src/​probe.rs Reports enumeration capability.
src/​core/​mxc_engine/​src/​policy/​exact/​v0_9.rs Emits the v0.9 field.
src/​core/​mxc_engine/​src/​policy/​exact/​v0_8.rs Rejects use before v0.9.
src/​core/​mxc_engine/​src/​policy/​exact/​v0_7.rs Rejects use before v0.9.
src/​core/​mxc_engine/​src/​policy/​exact/​v0_6.rs Rejects use before v0.9.
src/​core/​mxc_engine/​src/​policy.rs Extends the Rust policy API.
src/​core/​mxc_engine/​src/​dispatch.rs Updates test policy construction.
src/​core/​mxc_config_contract/​src/​dev/​stable.rs Adds the exact contract field.
src/​core/​generated/​process_security_environment_specification/​src/​process_security_environment_layout/​process_security_environment_generated.rs Regenerates PSEC bindings.
src/​backends/​wslc/​common/​src/​policy.rs Rejects unsupported enumeration policy.
src/​backends/​windows_sandbox/​lifecycle/​src/​policy.rs Rejects unsupported enumeration policy.
src/​backends/​learning_mode/​windows/​src/​secenv.rs Queries the PSEC support bit.
src/​backends/​isolation_session/​common/​src/​policy.rs Rejects unsupported enumeration policy.
src/​backends/​appcontainer/​common/​src/​probe.rs Exposes BaseContainer support facts.
src/​backends/​appcontainer/​common/​src/​fallback_detector.rs Prevents unsupported fallback.
src/​backends/​appcontainer/​common/​src/​dispatcher.rs Adds the fallback diagnostic.
src/​backends/​appcontainer/​common/​src/​base_container_runner.rs Selects and validates PSEC 1.1.
src/​backends/​appcontainer/​common/​src/​base_container_helpers.rs Serializes fs_enumerate.
src/​backends/​appcontainer/​common/​src/​appcontainer_runner.rs Rejects AppContainer enforcement.
sdk/​node/​tests/​unit/​sandbox.test.ts Tests TypeScript mapping.
sdk/​node/​src/​types.ts Adds TypeScript policy fields.
sdk/​node/​src/​sandbox.ts Maps enumeration paths.
sdk/​node/​src/​generated/​wire.ts Updates generated rolling types.
sdk/​node/​src/​generated/​v0_9_0_alpha/​wire.ts Updates generated exact types.
sdk/​node/​README.md Documents TypeScript usage.
sdk/​dotnet/​README.md Documents managed usage.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​SandboxPolicy.cs Adds EnumeratePaths.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​PlatformDiscovery.cs Adds the capability enum.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​MxcSandbox.cs Parses the native capability.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​MxcSandboxTests.cs Tests managed serialization and discovery.
schemas/​dev/​mxc-config.schema.0.9.0-dev.json Updates the rolling schema.
schemas/​dev/​mxc-config.schema.0.9.0-alpha.json Updates the exact schema.
external/​windows-sdk/​ProcessSecurityEnvironment.provenance.toml Records updated schema provenance.
external/​windows-sdk/​ProcessSecurityEnvironment.fbs Adds the native contract field.
docs/​schema.md Documents the schema field.
docs/​process-container/​os-version-support.md Documents host support requirements.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +37 to 40
if unrestricted_host_loopback_allowed(&request.policy)
|| !request.policy.enumerate_paths.is_empty()
{
Self::V1_1
Comment thread src/core/mxc-sdk/README.md Outdated
Comment on lines +194 to +195
`FilesystemEnumeratePaths` covers PSEC 1.1
`filesystem.enumeratePaths` without granting file-content reads.

@bbonaby Branden Bonaby (bbonaby) Sep 15, 2026 •

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.

thought (non-blocking): Should we remove PSEC 1.1 here? #Resolved

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed. I removed the PSEC version from the public Rust SDK capability description. It now describes the observable behavior: native support for filesystem.enumeratePaths without granting file-content reads.

format!("Could not resolve Windows system directory: {reason}")
}
FallbackError::EnumeratePathsUnsupported => {
"filesystem.enumeratePaths requires BaseContainer PSEC 1.1 with fs_enumerate support"

@bbonaby Branden Bonaby (bbonaby) Sep 15, 2026 •

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.

question (non-blocking): Should the error state that the users version of Windows doesn't support enumerate paths rather than calling out PSEC 1.1 directly?

I guess the question is the same for the error message in src/backends/appcontainer/common/src/dispatcher.rs as well.

Just wondering if folks see PSEC 1.1 if they'll know what we mean is all. That said, we can probably get away with just making sure the docs say what we mean. #Resolved

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah that's probably better.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed. I changed the probe, dispatcher, fallback, and direct AppContainer messages to lead with “not supported by this version of Windows” and explain that enumeration-only access requires native ProcessContainer support and cannot fall back to AppContainer. PSEC details remain in internal capability diagnostics and backend documentation.

Comment on lines +826 to +834
if !request.policy.enumerate_paths.is_empty()
&& !api
.supports_enumerate_paths()
.map_err(|error| ScriptResponse {
failure_phase: FailurePhase::BackendUnavailable,
..ScriptResponse::error(&format!(
"failed to query Process Security Environment filesystem enumeration support: {error}"
))
})?

@bbonaby Branden Bonaby (bbonaby) Sep 15, 2026 •

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.

note (non-blocking): For this if statement and the one below, it'd probably be preferrable to have the part after the && go in a separate variable above it just so it's all readable/maintainable. #Resolved

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed. I extracted named requirement/support booleans for enumeration and unrestricted host loopback, while keeping each capability query conditional so an unused capability query cannot reject an unrelated request. I also corrected the nearby PSEC 1.1 comment.

@@ -382,6 +390,19 @@ impl CapturePlatformSupport for RealCapturePlatformSupport {
format!("could not query process security-environment support: {error}")
})
}

fn supports_enumerate_paths(&self) -> Result<bool, String> {

@bbonaby Branden Bonaby (bbonaby) Sep 15, 2026 •

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.

note (non-blocking): perhaps this will be removed eventually with the refactor once secenv.rs is moved out of learning mode. The RealCapturePlatformSupport just seems to add duplication. #WontFix

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah I plan to do that right after this! :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For this PR, i wanted it to follow the same pattern as deny paths, for clarity.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed. CapturePlatformSupport is currently retained as the injectable test seam for native-capture eligibility. Consolidating it with SecurityEnvironmentApi fits the planned refactor that moves secenv.rs out of Learning Mode, so I would prefer to keep that broader cleanup out of this feature PR.

/// mode; both are honoured here. Everything else in the module table is
/// rejected.
pub(crate) fn validate_provision_policy(request: &ExecutionRequest) -> Result<(), MxcError> {
if !request.policy.enumerate_paths.is_empty() {

@bbonaby Branden Bonaby (bbonaby) Sep 15, 2026 •

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.

question: do we need the same for bubblewrap and LXC? #WontFix

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Bubblewrap and LXC do not need backend-local duplicates. Their one-shot ScriptRunner/SandboxBackend paths run wxc_common::validator::validate_common, which rejects non-empty enumeratePaths for every backend except ProcessContainer before backend execution. The WSLC check here is for the separate state-aware provision path, which does not use the one-shot runner validation path. I expanded the central validator test to explicitly cover Bubblewrap and LXC.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Great callout, and maybe we should make it clearer which paths are validated centrally... or fix code so it's super clear.

Copilot says it's not a concern because all paths are covered...

Bubblewrap and LXC do not need duplicate backend-local checks. Their one-shot execution paths
always call wxc_common::validator::validate_common, which already rejects enumeratePaths for every backend except
Windows ProcessContainer. The WSLC check is specifically needed for its state-aware provision path, which uses separate
phase validation.

..but I agree with you the code should speak for itself.

Copilot AI review requested due to automatic review settings September 15, 2026 17:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

Three new normalization branches log user-controlled paths without diagnostic escaping, allowing forged log lines.

Review tier: Balanced
Findings: 2 Medium severity · 1 Low severity

Open (3)
Previously missed (2)

In code that hasn't changed since last review

Medium severity Initialize EnumeratePaths like sibling collections

sdk/​dotnet/​Microsoft.Mxc.Sdk/​SandboxPolicy.cs:149

Unlike ReadwritePaths, ReadonlyPaths, and DeniedPaths, this collection defaults to null. That makes the established collection-initializer pattern (EnumeratePaths = { path }) throw and forces callers to special-case the new field; initialize it to an empty list for a consistent public API.

Low severity Document enumerate precedence in normalization

src/​core/​wxc_common/​src/​config_parser.rs:980

Adding enumeratePaths to this normalization changes the documented ordering, but the function comment still says deny > readonly > readwrite. That omits the new level and contradicts the implementation, which treats enumeration as stricter than read-only access.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

PSEC 1.1 enumeration can currently serialize an ingress table on hosts that do not advertise ingress support, and the Node.js builder lacks required schema/backend gating.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 2 Medium severity · 2 Low severity

Open (4)
Resolved since last review (2)

Comment thread sdk/node/src/sandbox.ts Resolved
fn normalize_filesystem_paths(policy: &mut ContainerPolicy, logger: &mut Logger) {
if policy.readwrite_paths.is_empty()
&& policy.readonly_paths.is_empty()
&& policy.enumerate_paths.is_empty()
Co-authored-by: Copilot <[email protected]>

Copilot-Session: 3f79f2c6-12b0-4859-8537-6fa9f5209cd6
Copilot AI review requested due to automatic review settings September 15, 2026 23:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

The TypeScript policy builder can emit enumeratePaths for schema versions whose exact contracts reject it, and one parser comment now documents stale precedence.

Review tier: Balanced
Findings: 2 Medium severity · 2 Low severity

Open (4)

@MGudgin Gudge (MGudgin) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Summary

Attribution was re-verified against
ae1e60a54779f0f32d9eeec7edae9d65a4083b54...ed7c3db9b4df8b7f6e886f5318951ee35c78417e.
The merge base exactly equals the PR base, and the local/GitHub diff content is
equivalent after ignoring blob-hash abbreviation and hunk-label differences.

Two High findings survive: PSEC 1.1 enumeration can serialize an unadvertised
ingress table, and the new C# enum member changes an existing public numeric
value. The review event is COMMENT; the High findings should still be fixed
before merge.

Verified clean, with receipts

  • Unsupported non-ProcessContainer backends received fail-closed rejection
    guards; no silent policy broadening was found.
  • The PR adds independent support-bit coverage showing
    PSE_SUPPORT_FS_ENUMERATE and PSE_SUPPORT_NETWORK_INGRESS can differ.
  • Generated wire/schema artifacts were treated as generated output rather than
    reviewed for hand-written implementation defects.
  • The central resolver still has only its definition and production call in
    both base and head; the two added Rust tests cover serialization/predicates,
    not the resolver matrix.

Findings outside the diff

Low (documentation drift) - Capability design document is now stale.
docs/backend-support-probe-api-plan.md:83 —
newly_exposed_by_change: the file is byte-identical base versus head, but its
exhaustive capability list omits the new filesystemEnumeratePaths value added
by this PR. Add the new capability to the list.

Low (documentation drift) - C# discovery documentation omits the new public
capability.
sdk/dotnet/README.md:115-144 —
newly_exposed_by_change: the README is modified by the PR, but the capability
discovery example and prose are unchanged while BackendCapability gains
FilesystemEnumeratePaths. Add it to the example and explain the mapped policy
field.

Verified pre-existing - not attributed to this PR

No unrelated pre-existing finding is being charged to this PR. The unchanged
regression harness and design document are cited only where the PR's new
behavior newly depends on or invalidates them.

Withdrawn

  • src/backends/process_container/common/src/appcontainer_runner.rs:1734-1740
    — invalid: the added check is redundant in normal dispatch, but redundancy
    alone does not establish a defect and can be intentional defense in depth.

Comment thread sdk/node/src/sandbox.ts Resolved
Comment thread docs/schema.md Resolved
Comment thread sdk/node/src/sandbox.ts Resolved
Separate PSEC contract version negotiation from individual capability support, preserve SDK compatibility, and strengthen policy validation and regression coverage.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 3f79f2c6-12b0-4859-8537-6fa9f5209cd6
Explicitly run the positive ProcessContainer enumeration serialization case as Windows so the cross-platform validation remains deterministic on Linux and macOS runners.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 3f79f2c6-12b0-4859-8537-6fa9f5209cd6

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The Node.js path mishandles explicit ProcessContainer targeting and its new mapping test fails on non-Windows lanes, while the probe can misreport deny support.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity · 2 Medium severity · 4 Low severity

Open (7)
Resolved since last review (2)

Comment thread sdk/node/src/sandbox.ts
Comment on lines +442 to +444
const targetsWindowsProcessContainer =
platform === 'win32' && (containment === 'process' || containment === 'processcontainer');
if (!targetsWindowsProcessContainer) {
Comment thread sdk/node/tests/unit/sandbox.test.ts Resolved
.is_some(),
bfs_compiled_in: cfg!(feature = "tier2_bfs"),
base_container_supports_deny_paths: BaseContainerRunner::supports_native_denied_paths(),
base_container_supports_deny_paths: capabilities.supports_deny_paths,
Comment thread docs/schema.md
Comment on lines +364 to +365
`processContainer.filesystem` carries `enumeratePaths`. Both sub-blocks are
valid only when `containment` is `processcontainer`.
Comment on lines +244 to +249
/// Enumeration-only access cannot be represented by AppContainer fallback tiers.
#[error(
"processContainer.filesystem.enumeratePaths is not supported by this version of Windows; \
enumeration-only access requires native ProcessContainer support"
)]
EnumeratePathsUnsupported,
Copilot AI review requested due to automatic review settings September 16, 2026 18:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

Probe output can misreport deny-path support, and explicit Node ProcessContainer selection remains unusable.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity · 4 Low severity

Open (6)
Resolved since last review (1)

Resolve the ProcessContainer security-environment refactor by retaining shared capability-flag caching for deny, enumeration, and ingress support.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 3f79f2c6-12b0-4859-8537-6fa9f5209cd6
Copilot AI review requested due to automatic review settings September 16, 2026 19:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Explicit Node.js ProcessContainer requests fail dispatch, and probing can incorrectly advertise denied-path support.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity · 2 Medium severity · 4 Low severity

Open (7)

Comment on lines 1075 to 1078
if policy.readwrite_paths.is_empty()
&& policy.readonly_paths.is_empty()
&& policy.enumerate_paths.is_empty()
&& policy.denied_paths.is_empty()
@MGudgin

Copy link
Copy Markdown
Member

Re-verified the review against updated head d2db390e and the new PR base
b773325c.

Disposition: all 14 inline findings are addressed. The two original High
findings are fixed: PSEC ingress capability is resolved independently from the
1.1 contract version, and the C# capability enum preserves its released
numeric values.

Verification completed:

  • 29 focused Rust tests passed, including the resolver matrix, enumeration
    without ingress, path precedence, backend rejection, and capability-cache
    tests.
  • Node SDK unit tests: 432 passed, 20 skipped, 0 failed.
  • Focused .NET capability tests: 6 passed, 0 failed.

The capable-host #1162 executor E2E was not run locally. CI's Windows x64/ARM64
build jobs and Rust CodeQL were still running when checked; the other reported
build, SDK, lint, versioning, and integration checks were passing.

Two Low, non-blocking documentation items from the review body remain:

  • docs/backend-support-probe-api-plan.md:83 still omits
    filesystemEnumeratePaths from its capability list.
  • sdk/dotnet/README.md:115-144 still omits
    BackendCapability.FilesystemEnumeratePaths from the discovery example and
    prose.

No blocking review finding remains open.

@jsidewhite
Jeff Whiteside (jsidewhite) merged commit 6c1f7b6 into main Sep 16, 2026
28 checks passed
@jsidewhite
Jeff Whiteside (jsidewhite) deleted the jsidewhite/issue_1162 branch September 16, 2026 20:56
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.

Add BaseContainer support for PSEC fs_enumerate

4 participants