Repository navigation
Extend MXC schema to support Services Enumeration permission - #1868
Vsevolod (beervoley) wants to merge 12 commits into
Conversation
… for BaseContainer Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 843b1137-3895-473e-b922-4b0b56eb9ad9
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 843b1137-3895-473e-b922-4b0b56eb9ad9
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 843b1137-3895-473e-b922-4b0b56eb9ad9
There was a problem hiding this comment.
🟡 Changes recommended
Automatic upgrades on PSEC 1.3 hosts grant service enumeration to callers with unset service policies, expanding sandbox permissions they cannot opt out of through their contracts.
1 open issue
What changed in this PR
Adds service-enumeration policy to MXC’s development contract and connects it to native Windows ProcessContainer through PSEC 1.3.
Changes:
- Adds
processContainer.services.enumerateVisible, generated contract artifacts, and parsing tests. - Implements PSEC 1.3 serialization, host-dependent defaults, and rejection on unsupported backends or fallback tiers.
- Updates the Windows schema provenance and documents the policy.
| File | Description |
|---|---|
src/mxc-sdk/tests/mxc_contract/v1_1_0_alpha/fixtures/one_shot/valid/services_enumeration.json |
Adds a valid enumeration request. |
src/mxc-sdk/tests/mxc_contract/v1_1_0_alpha/fixtures/one_shot/invalid/services_enumeration_null.json |
Covers rejection of null values. |
src/mxc-sdk/src/core/process_security_environment_spec/process_security_environment_layout/services_policy_generated.rs |
Adds generated services-policy bindings. |
src/mxc-sdk/src/core/process_security_environment_spec/process_security_environment_layout/process_security_environment_generated.rs |
Integrates services into generated PSEC bindings. |
src/mxc-sdk/src/core/process_security_environment_spec/mod.rs |
Exports services-policy bindings. |
src/mxc-sdk/src/core/mxc_contract/dev/stable.rs |
Defines the development-contract policy. |
src/mxc-sdk/src/core/mxc_common/wire.rs |
Carries policy through request adaptation. |
src/mxc-sdk/src/core/mxc_common/validator.rs |
Rejects policy on unsupported backends. |
src/mxc-sdk/src/core/mxc_common/policy_identity.rs |
Tests policy identity distinctions. |
src/mxc-sdk/src/core/mxc_common/models.rs |
Adds the optional internal policy field. |
src/mxc-sdk/src/core/mxc_common/config_parser.rs |
Normalizes policy and tests contract acceptance. |
src/mxc-sdk/src/core/mxc_common/config_contract_adapters/v1_0/one_shot.rs |
Leaves services unset for V1.0 requests. |
src/mxc-sdk/src/core/mxc_common/config_contract_adapters/v0_9/one_shot.rs |
Leaves services unset for V0.9 requests. |
src/mxc-sdk/src/core/mxc_common/config_contract_adapters/dev/one_shot.rs |
Adapts development services settings. |
src/mxc-sdk/src/core/mxc_common/config_contract_adapters/dev/one_shot_tests/stable_candidate.rs |
Tests optional values and invalid inputs. |
src/mxc-sdk/src/backends/process_container/common/secenv.rs |
Defines the PSEC 1.3 version constant. |
src/mxc-sdk/src/backends/process_container/common/probe.rs |
Formats unsupported-policy errors. |
src/mxc-sdk/src/backends/process_container/common/fallback_detector.rs |
Prevents fallback from ignoring services policy. |
src/mxc-sdk/src/backends/process_container/common/dispatcher.rs |
Surfaces services-policy fallback errors. |
src/mxc-sdk/src/backends/process_container/common/base_container_runner.rs |
Adds version checks, defaults, and backend tests. |
src/mxc-sdk/src/backends/process_container/common/base_container_helpers.rs |
Serializes services policy into PSEC. |
src/mxc-sdk/src/backends/process_container/common/appcontainer_runner.rs |
Rejects services policy in AppContainer. |
sdk/node/src/generated/v1_1_0_alpha/wire.ts |
Adds generated TypeScript policy types. |
schemas/dev/mxc-config.schema.1.1.0-alpha.json |
Adds the development JSON schema definition. |
external/windows-sdk/ProcessSecurityEnvironment.provenance.toml |
Records schema provenance and validation limits. |
external/windows-sdk/ProcessSecurityEnvironment.fbs |
Adds the PSEC services-policy table. |
docs/schema.md |
Documents policy usage, defaults, and limitations. |
Review effort: Balanced
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 843b1137-3895-473e-b922-4b0b56eb9ad9
233acdd to
b4d4bba
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Existing published-contract and V1 SDK requests gain service-enumeration permission without caller consent or a way to opt out, creating a critical backward-compatibility and permission regression.
2 open issues
Review effort: Balanced
Published-contract and V1 SDK callers cannot express processContainer.services, so they no longer get PSEC 1.3 and service enumeration implicitly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 843b1137-3895-473e-b922-4b0b56eb9ad9
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 843b1137-3895-473e-b922-4b0b56eb9ad9
There was a problem hiding this comment.
🔵 Needs a closer look
Scheduled Windows functional coverage is missing for service-enumeration permissions, leaving enabled, disabled, and default behavior, service-management denial, and unsupported-host rejection unverified.
3 open issues
Review effort: Balanced
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because service normalization can bypass host-version restrictions, while identical policy hashes can represent different effective service permissions.
No open issues 🎉
3 resolved since last review
Review effort: Balanced
Gudge (MGudgin)
left a comment
There was a problem hiding this comment.
Summary
Requesting changes for the implicit service-enumeration grant and the missing functional Windows validation. Adding the setting should not widen an unchanged request's sandbox permissions when the host supports PSEC 1.3.
Reviewed 7136ecf93ab86f2802b469371827bba9e7bd751c against merge-base 799d50d0793988abecb9837879487cd79ff7244f. The five inline comments and the policy-reference finding below cover six consolidated findings: two High and four Medium.
Findings outside the diff
Medium (documentation) - Document the implicit permission in the development policy reference [6]. docs/containment-policy/dev/policy.md:140
Attribution: newly_exposed_by_change - this file is byte-identical across the review range, but the new default introduces a permission that its ProcessContainer settings table does not describe. The guide says it describes requests independently of other documents. A reader cannot discover the services setting, the host-dependent omission default, or its opt-out there. Update the existing table/guidance with the setting, final default semantics, and PSEC 1.3 prerequisite. This is a documentation gap caused by the new feature, not a pre-existing runtime bug.
Claim clarification (part of finding 3)
Medium - Explicit empty services policy is not rejected on older hosts. Attribution: claim_mismatch.
The description says, "Explicit services on a host without PSEC 1.3 is rejected." However, services: {} intentionally normalizes to the omitted/default case (src/mxc-sdk/src/core/mxc_common/config_parser.rs:1645-1648) and does not trigger the native 1.3 gate. Only an explicit boolean does. Clarify that distinction, or preserve section presence if every present services object should require 1.3. This claim mismatch, like the inline empty-object documentation mismatch, is not independently a merge condition.
Verified clean by static inspection
- Published adapters
src/mxc-sdk/src/core/mxc_common/config_contract_adapters/v0_9/one_shot.rs:100andsrc/mxc-sdk/src/core/mxc_common/config_contract_adapters/v1_0/one_shot.rs:100setservices: None; the parser's new default flag is scoped to the Windows development-contract ProcessContainer case (src/mxc-sdk/src/core/mxc_common/config_parser.rs:1652-1656). No typed V1 SDK files are changed. - Explicit true and false require native PSEC 1.3 in
BaseContainerRunner::can_backend_service_request(src/mxc-sdk/src/backends/process_container/common/base_container_runner.rs:534-541); unsupported explicit policy is not silently delegated to a fallback. - Existing runner tests were retained: 64
#[test]markers at base, 68 at head. The existing policy-preparation fake-API test now checks minor 3 for the development contract and minor 1 for published contracts (src/mxc-sdk/src/backends/process_container/common/policy_preparation_backend_tests.rs:377-381). This is useful unit coverage, not functional OS-enforcement coverage.
Verified pre-existing - not attributed to this PR
No independent pre-existing defect is being charged to this PR. The unchanged policy-reference file is identified above only because the new default makes it incomplete. The earlier standalone PolicyHash concern was withdrawn: hashing request intent before backend dispatch is an existing design, not an established new enforcement failure. Preparation/launch divergence is reported as a maintainability issue, not a proven verification bypass.
Validation limits
cargo test -p mxc-sdk --lib services was attempted during review but blocked before compilation by a sandbox filesystem access denial. No local test result or independent PSEC 1.3 runtime verification is claimed. The PR's manual VM report was not independently reproduced.
| .enumerate_visible_services | ||
| .or((request.policy.default_enumerate_visible_services | ||
| && version >= SecurityEnvironmentVersion::V1_3) | ||
| .then_some(true)) |
There was a problem hiding this comment.
High (security, correctness) - Require an explicit service-enumeration grant [1].
Attribution: introduced_by_change - this new default supplies true when the caller supplied no services boolean.
An unchanged 1.1.0-alpha ProcessContainer request with services omitted, or with services: {}, now receives services { enumerate_visible: true } on a PSEC 1.3 host. The parser sets the default flag and spawn_base opportunistically upgrades the PSEC version, so upgrading MXC or the host can widen the sandbox's permissions without a request change. This grants enumeration of visible services, not service control, but it still reverses the secure-by-default expectation. Explicit false avoids the grant only on hosts that accept the new policy.
Fix: Leave omission and an empty object non-granting; require enumerateVisible: true to add the capability. Keep unsupported explicit policy fail-closed.
|
|
||
| // Dev-contract requests default service enumeration on when the host supports PSEC 1.3; | ||
| // an explicit `processContainer.services.enumerateVisible` (true or false) always wins. | ||
| let psec_version = if request.policy.enumerate_visible_services.is_none() |
There was a problem hiding this comment.
High (test coverage) - Add functional Windows CI coverage for the new permission and host gate [2].
Attribution: introduced_by_change - this PR adds a host-dependent sandbox permission/default without a functional OS-enforcement scenario.
The new fixtures and unit/fake-API tests check parsing and PSEC construction, but the scheduled ProcessContainer scripts have no services-enumeration assertions; the PR explicitly defers functional Windows coverage. The updated policy-preparation test covers the supported-host runner path, but not actual OS grant/denial. Also, the unavailable-BaseContainer unit test forces the API absent and returns before ServicesPolicyUnsupported, so it does not exercise the new 1.3 gate.
Fix: Extend scheduled native ProcessContainer validation with observable positive/negative controls for omitted, empty, true, and false policy; published-contract preservation; and explicit-policy rejection before execution on an unsupported host. Reuse the injected version callback for deterministic lower-version gate/fallback unit cases. Unit construction tests and the reported manual VM run should supplement, not replace, that functional gate.
| When `services` is omitted, BaseContainer defaults `enumerateVisible` to true on | ||
| hosts that support PSEC 1.3, and keeps the OS default otherwise; set | ||
| `enumerateVisible: false` to opt out. An empty services object or | ||
| `enumerateVisible: false` adds no service-enumeration permission; it does not |
There was a problem hiding this comment.
Medium (security, documentation) - An empty services object does add the default grant [3].
Attribution: claim_mismatch - the changed text says an empty services object "adds no service-enumeration permission," contrary to the new implementation.
services: {} normalizes to enumerate_visible_services = None, and on a PSEC 1.3 host the builder substitutes true. A caller following this sentence to avoid adding permission therefore receives enumeration access. An empty object and explicit false are not equivalent here.
Fix: Align this text with the final default decision. If default-on is retained, say explicitly that {} retains the enabled default and only an explicit false boolean avoids this additional grant. The related unsupported-host claim clarification is in the review body. These claim mismatches are non-blocking by themselves.
| && matches!(source_contract, ContractVersion::V1_1_0Alpha) | ||
| && containment == ContainmentBackend::ProcessContainer | ||
| { | ||
| policy.default_enumerate_visible_services = true; |
There was a problem hiding this comment.
Medium (maintainability) - Resolve this default once in the backend [4].
Attribution: introduced_by_change - this adds a Windows/backend default to shared normalization and a second PSEC version-selection path at launch.
ExecutionRequest already carries source_contract, but this rule is now spread across the parser, a skipped policy flag, manual hash projection, the builder, and spawn_base. In particular, preparation/verification use supported_security_environment_version, which upgrades only an explicit services boolean; the implicit 1.3 upgrade exists only in spawn_base. For the same omitted dev policy, preparation builds a lower-version spec without services while launch builds a 1.3 spec with the grant. I have not established a verification bypass, but these are two different implementations of the effective-policy decision. Project instructions place backend-specific defaults in the backend, not the shared parser.
Fix: Use the existing request provenance to resolve the effective services policy/PSEC version in one backend-owned path, reused by preparation, verification, and launch. Add a test comparing the prepared and launched effective services setting.
| pub network: OptionalField<ProcessContainerNetwork>, | ||
| /// Optional service enumeration policy for native Windows ProcessContainer. | ||
| #[serde(default)] | ||
| pub services: OptionalField<ProcessContainerServices>, |
There was a problem hiding this comment.
Medium (correctness) - Reject the positional-array representation of services [5].
Attribution: introduced_by_change - the newly added settings struct is deserialized without the existing object-only helper.
OptionalField<T> delegates a present value to T::deserialize, and Serde's derived struct deserializer accepts positional arrays. Consequently, an otherwise valid development request can supply "services": [true] and obtain enumerate_visible = true, although the generated schema requires an object. Production one-shot parsing uses Serde rather than schema validation, and its later cross-field validator does not reject this shape. deny_unknown_fields does not prevent the array form.
Fix: Apply the existing deserialize_optional_object helper here, as nearby custom settings do, and add a native-parser regression rejecting [true] while retaining the intended object/omission behavior. This is verified by tracing deserialization, not by an executed runtime test.
Refs #1900. Remove implicit grants and launch-only PSEC upgrades, preserve services-section presence, reject positional arrays, and keep prepared and launched policies aligned. Add scheduled Windows permission and unsupported-host cases, regenerate development artifacts, and correct policy documentation and provenance. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 2681ffd7-9999-40c1-b6bc-6d1b7f87bc3c
|
Addressed the review feedback in 8d755d7:
Validation: 17 focused library tests, all 392 development-contract tests, targeted Clippy/format checks, PSEC codegen drift verification, and seven real native pre-1.3 cases passed. This local host does not advertise PSEC 1.3, so enabled enumeration/management-denial and disabled-feature results still need a suitable Windows host before delivery. No new build-validation claim was added to the provenance. |
Refs #1900. Remove references to nonexistent AppContainer fallback tiers from services guidance and name the existing rejection tests for the native checks they exercise. No enforcement behavior changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 2681ffd7-9999-40c1-b6bc-6d1b7f87bc3c
|
Follow-up in bfc88c4 aligns the services documentation and existing rejection-test names with the native-only ProcessContainer design; no fallback detector or fallback path is claimed. Runtime enforcement is unchanged. The 10 focused services-policy tests, formatting check, and targeted Clippy pass. The latest review has no open code findings, but its remaining gates are still outstanding: maintainer scope acceptance for #1900, approval/merge of #1882, and PSEC 1.3-enabled plus disabled-feature host results. This PR remains draft; the earlier pre-1.3 results are not represented as evidence for those missing host scenarios. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 2681ffd7-9999-40c1-b6bc-6d1b7f87bc3c
|
Follow-up 479f3f9 addresses the probe/V1.Dev feedback on design #1882 (cc61587). Added direct request-aware engine probe coverage and scheduled CLI probe cases; strengthened public Rust V1.Dev policy preparation with nonempty observations and omitted/empty/false/true preservation, comparing prospective PSEC with native submission and backend execution. Consumer/CI docs and both PR descriptions now distinguish typed V1 inputs from V1.Dev JSON requests and generic availability from request compatibility. The 10 services-policy library tests, 11 preparation tests, targeted Clippy with warnings denied, formatting, and 10 native services cases passed locally on the pre-1.3 host. No production probe change was needed: the shared serviceability decision already enforces the services 1.3 gate. This stays draft: positive PSEC 1.3 enforcement, feature-disabled creation failure, maintainer acceptance of #1900, and approval/merge of #1882 remain required; none is claimed by this follow-up. |
|
LGTM |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 2681ffd7-9999-40c1-b6bc-6d1b7f87bc3c
|
Adapted to approved spec #1882 (b44347f) in 283b695. Added empty-observation services preparation preserving byte-for-byte JSON even with native serviceability forced unavailable; strengthened injected 1.3 creation refusal to verify one exact services PSEC submission, propagated HRESULT/operation context, no workload, and no policy-stripping retry. Added a public Node V1.Dev executor-backed PTY case covering all four services shapes, real version-query/host diagnostics, unsandboxed management-rights controls on 1.3, and post-startup terminal refusal/no workload on older hosts. Wired it into scheduled test requirements and bundle discovery; the SDK bundle now builds/stages/inventories the existing native access probe. Updated consumer and CI docs to distinguish native versus executor-backed PTY, empty versus nonempty preparation, services-specific probe compatibility, and real versus injected host evidence. Validation: services-policy tests (10), preparation tests (11), targeted Clippy with warnings denied, formatting, native SDK/probe builds, Node SDK/integration builds, the two targeted Node integration cases, and 10 native services cases passed. Changed PowerShell scripts parse successfully. Local Windows 10.0.26732.0 advertises PSEC minor 2: omitted Node PTY execution and explicit-services terminal refusal passed, but positive 1.3 permission enforcement could not run here. The full Windows SDK bundle was not built locally. The PR stays draft for remaining maintainer/merge gates and required real 1.3 enforcement; real feature-disabled provisioning remains explicitly unverified until the OS team supplies a supported mechanism. |


Description
Adds explicit opt-in
processContainer.services.enumerateVisibleto the development contract (1.1.0-alpha) and maps it to the native Windows PSEC 1.3 services policy.truegrants enumeration of visible services, never service creation, configuration, start, or stop access. Omitted, empty, and false policies add no permission.{}and explicit false, requires native Windows ProcessContainer and PSEC 1.3. Unsupported hosts/backends reject it before workload execution.0.9.0-alpha,1.0.0), typed V1 SDK requests, and development requests omitting services retain their existing PSEC version-selection rules and receive no implicit grant.Adapted to approved design #1882 (b44347f). This PR remains draft pending the remaining maintainer/merge gates and required real PSEC 1.3 enforcement evidence. Real feature-disabled coverage is explicitly unverified until the OS team supplies a build/image or supported provisioning procedure; the test flag does not configure the host.
References
Refs #1900
Design: #1882 (
docs/development/architecture/designs/1900-services-enumeration/README.md)OS schema change: https://microsoft.visualstudio.com/OS/_git/os.2020/pullrequest/17662109
Validation
cargo fmt --all -- --checkpassed; the executor and native access probe built.Checklist
feature-acceptedIssue Type
Feature