Repository navigation
[IsoSession] Network policy admission pass and lab-only loopback gate - #1796
Ion Vasilian (ionvasilian) wants to merge 1 commit into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟡 Changes recommended
The new validation can falsely pass rejection and runtime failures, is not invoked by CI, and directly changes machine-wide settings instead of using caller-managed setup.
5 open issues
Run the admission checks in scheduled CI validation · New Require the expected rejection reason for negative tests · New Treat successful non-loopback TCP connects as reachable · New Move OS-level runtime setup into the caller-provided setup script · New Fail runtime validation on a nonzero wxc-exec exit · New
What changed in this PR
Adds network-policy validation coverage for MXC’s IsolationSession backend and a compile-time lab gate for exact TCP loopback ports, while preserving shipping admission rules.
Changes:
- Adds 31 shipping/lab admission cases, a build-mode canary, and optional runtime reachability and cleanup checks.
- Adds lab-only backend and parser handling, with corresponding test adjustments.
- Packages the script in Windows test bundles, with optional staging for older Azure branches.
Validation was limited to code inspection; Windows runtime tests were not run.
| File | Description |
|---|---|
tests/scripts/run_isolation_session_network_test.ps1 |
Adds admission, reachability, and cleanup checks. |
src/mxc-sdk/src/policy/sdk_v1_conformance.rs |
Skips one parser-rejection fixture in lab builds. |
src/mxc-sdk/src/policy.rs |
Makes an explicit-network test shipping-only. |
src/mxc-sdk/src/core/mxc_contract/published/v1_0_0/request.rs |
Defers non-proxy network validation to the backend in lab builds. |
src/mxc-sdk/src/core/mxc_contract/published/v0_9_0_alpha/request.rs |
Applies the same lab-only parser deferral. |
src/mxc-sdk/src/core/mxc_contract/dev/request.rs |
Applies lab-only parser deferral to the development contract. |
src/mxc-sdk/src/core/mxc_common/config_parser.rs |
Disables two parser-rejection tests under the lab cfg. |
src/mxc-sdk/src/backends/isolation_session/common/policy.rs |
Adds the narrow loopback admission gate and tests. |
src/mxc-sdk/src/backends/isolation_session/common/one_shot.rs |
Enables validated egress rules in lab builds and adds tests. |
src/mxc-sdk/Cargo.toml |
Registers the lab cfg for compiler checking. |
scripts/ci/build-windows-sdk-test-bundle.ps1 |
Stages and requires the new script in SDK test bundles. |
.azure-pipelines/templates/IsolationSession.TestBundle.Build.Job.yml |
Stages the script when present on the selected branch. |
Review effort: Balanced
b7bd3f4 to
1a3f09b
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Lab enforcement relies on external OS-private configuration, and revised runtime probes were not rerun, requiring maintainer verification of enforcement, restoration, and cleanup on a compatible prerelease Windows host.
No open issues 🎉
5 resolved since last review
Review effort: Balanced
|
Superseded: these results are for 1a3f09b. 83d1575 removed the runtime rows from this PR; see the review discussion. Re-ran the runtime rows at 1a3f09b on a pre-release Windows build, to address the review note that the revised probes had not been re-run. Command: Result: 40/40 passed (exit 0).
Restoration and cleanup, checked independently after the run:
Scope note: the host enforcement comes from an external, OS-side setup script that this PR does not ship. The lab cfg is not part of shipping builds, and the shipping admission rows (CI dry-run) do not depend on it. |
adpa-ms
left a comment
There was a problem hiding this comment.
[AgentAssisted] A few questions about the PR's purpose before the details. The answers decide its shape.
1. What has to work that doesn't today? MXC passes no network policy to the OS. The IsolationSession bindings have no network members, and the create-and-run path passes none to add_user, start_session or create_process. As your comment says, the enforcement comes from the host setup script. On a host it has prepared, would a shipping wxc-exec with the all-allow request get the same results as the -Lab -Runtime rows? If so, what does the lab build add?
2. Why land the runtime rows in MXC now? ProcessContainer's network tests fit here: MXC builds the requested rules into the spec it passes to CreateProcessSecurityEnvironment, so the tests cover MXC's translation too. Here MXC passes nothing yet. These rows' network results depend only on the OS and the setup script, and neither MXC CI nor the planned OS row runs them. Should they land with the public network surface MXC will pass the policy through, and run on the OS side until then?
3. Why change the published 0.9.0-alpha and 1.0.0 parsers? A release wxc-exec accepts 1.1.0-alpha IsolationSession requests without --experimental, and the script chooses its own version. Three of the four test exemptions exist only because the published parsers changed. Under the lab cfg, the invalid-fixture and missing-network tests in mxc_contract_v0_9_0_alpha and mxc_contract_v1_0_0 would also fail; the --lib run doesn't build them. Does any caller need a published contract?
4. What do the shipping dry-run rows catch that existing tests miss? PR CI already enforces the rule: contract tests and fixtures for all three versions, plus config parser, SDK and backend unit tests. The nightly one-shot suite checks it against the real binary. In a shipping build, 27 of the 31 rows expect the same parser message. A dry run stops before any OS call, so these rows test nothing specific to an IsolationSession host.
A smaller shape, depending on your answers:
- To measure the compartment before the public surface exists, an OS-side test can launch the shipping
wxc-execwith the all-allow request. That needs no MXC change. - If MXC must accept the restricted request now, gate only the dev contract and the backend. The dev parser accepts exactly all-allow or the loopback shape, and the script sends 1.1.0-alpha. No test needs an exemption: none of the dev contract's invalid fixtures has the loopback shape.
- Drop the shipping rows. To pin that shipping builds reject the loopback shape, add one invalid fixture.
Add run_isolation_session_network_test.ps1: 31 dry-run admission rows (network on/off, L3/L4 egress rules, loopback, proxy) sent as the development contract 1.1.0-alpha. Rows assert capability outcomes (accept or typed reject), never ProcessContainer field shapes. The pass is lab-only: row L01 runs first as a canary, and a shipping binary that rejects it at parse time makes the pass report a skip (exit 77) and run no rows. Requests reach wxc-exec through a config file, never its command line. Add a lab-only admission gate behind the rustc cfg isolation_session_network_lab: TCP egress to declared 127.0.0.1/32 exact ports with ingress and host loopback denied. Only the development contract (1.1.0-alpha) and the isolation_session backend change; the published 0.9.0-alpha and 1.0.0 parsers are untouched. Shipping builds are unchanged; the cfg is registered in check-cfg and set by no build or pipeline. Tests that differ under the lab cfg state the lab-cfg expected result rather than being exempted. A new invalid 1.1.0-alpha fixture pins that a shipping build rejects the declared-loopback shape. Stage the script into the IsolationSession TestBundle (optional in the pipeline step, so older branches still build). Runtime reachability rows are not part of this change: they land with the change that passes the public network options to the session. Validated locally on main 8e368f0, shipping and lab cfg: fmt clean; clippy -D warnings clean; contract targets v0_9_0_alpha 278, v1_0_0 281, v1_1_0_alpha 390, version_boundaries 21, all passing on both; mxc-sdk lib tests 2822 pass shipping and 2834 pass lab, each with 1 host-environment failure (host_to_container_loopback_connects, 10060) that also fails on unmodified main; admission pass 31/31 on a lab binary and exit 77 (skip) on a shipping binary. Co-authored-by: Copilot <[email protected]> Copilot-Session: 9e4e00d4-9956-456c-93ca-1c66128be594
1a3f09b to
83d1575
Compare
|
adpa-ms thanks; points 1-4 accepted. Reshaped per your proposal (83d1575): dev contract (1.1.0-alpha) and backend only, published parsers untouched, shipping rows replaced by one invalid fixture. Runtime rows run OS-side until MXC passes the public network options, then land in MXC with that change. |
There was a problem hiding this comment.
🔵 Needs a closer look
The checks cover admission only, leaving the private, external host setup and exact-port OS enforcement, including Windows runtime behavior, for a maintainer to verify.
No open issues 🎉
2 resolved since last review
Review effort: Balanced
Gudge (MGudgin)
left a comment
There was a problem hiding this comment.
Gudge needs more time to review this PR before it is merged. Please hold off on merging until that review is complete.
adpa-ms
left a comment
There was a problem hiding this comment.
[AgentAssisted] Thanks: the reshape resolves points 2–4. The runtime rows are gone, the published contracts are untouched, and one fixture replaces the shipping rows.
Point 1 is still open, and it decides whether the lab gate belongs in this PR. MXC still passes no network policy to the OS. A lab binary with the loopback request makes the same OS calls as a shipping binary with the all-allow request. The gate changes what MXC accepts, not what the session enforces.
With the runtime rows gone, who needs a lab build to accept the restricted request before MXC can apply its policy, and for what?
If nothing needs it sooner, could the gate land with the change that passes the public network options to the session, as the runtime rows will? That change is what makes MXC apply the policy the gate admits.
If something needs it sooner, a narrower gate would be enough. In lab builds, the dev parser would accept only all-allow or the loopback shape, and everything else would keep the shipping message. Today, lab builds skip the parser's network check for any request without a proxy. That turns two invalid fixtures into valid all-allow requests: isolation_session_egress_allow_rules.json and isolation_session_egress_deny_rules.json. Normalization treats their empty allow and deny lists as absent.

[IsoSession] Network policy admission pass and lab-only loopback gate
Summary
Adds an admission pass for the network policies the isolation_session backend accepts or
rejects, plus a lab-only gate, compiled out of shipping builds, that admits one narrow shape:
TCP egress to declared 127.0.0.1 ports.
Only the development contract (1.1.0-alpha) and the isolation_session backend change. The
published 0.9.0-alpha and 1.0.0 parsers are untouched. Shipping behavior does not change:
every widening is behind the rustc cfg
isolation_session_network_lab, which no build orpipeline sets.
Changes
tests/scripts/run_isolation_session_network_test.ps1(new)Each row sends a 1.1.0-alpha request to
wxc-exec --dry-runand asserts accept, or rejectwith the expected reason. Row configs are passed as files, not on the command line.
pass reports a skip (exit 77) and runs no rows. Any other L01 failure fails the pass.
src/mxc-sdk/src/backends/isolation_session/common/policy.rscfg(isolation_session_network_lab)only: an egress-deny policy with allow rulesfor 127.0.0.1/32 on exact TCP ports, ingress denied, host loopback denied, goes to
lab::validate_declared_loopback_egress. Everything else is rejected withisolation session network (lab): <reason>. Addslab_tests.src/mxc-sdk/src/backends/isolation_session/common/one_shot.rsEGRESS_RULESto the supported set. Adds lab tests.src/mxc-sdk/src/core/mxc_contract/dev/request.rsconfig_parser.rs: the dev-contract bridge test expects Ok under the lab cfg.tests/mxc_contract/v1_1_0_alpha/request.rs:isolation_session_one_shot_requires_networkexpects a OneShot request under the lab cfg.
tests/mxc_contract/v1_1_0_alpha/fixtures.rs: under the lab cfg, the set of invalidfixtures the parser now defers to the backend must equal an explicit list.
v1_1_0_alpha/.../invalid/isolation_session_declared_loopback_ports.jsonpins that a shipping build rejects the declared-loopback shape.
src/mxc-sdk/Cargo.tomlisolation_session_network_labunder[lints.rust] unexpected_cfgs.scripts/ci/build-windows-sdk-test-bundle.ps1and.azure-pipelines/templates/IsolationSession.TestBundle.Build.Job.ymltest_scriptsfolder. The pipeline step skips it whenabsent, so older branches still build.
Not changed
Validation
Run locally on Windows, on main 8e368f0, shipping and lab cfg
(
RUSTFLAGS=--cfg isolation_session_network_lab):cargo fmt --all -- --checkcargo clippy -p mxc-sdk --features isolation_session --all-targets -- -D warnings--libmxc_contract_v0_9_0_alphamxc_contract_v1_0_0mxc_contract_v1_1_0_alphamxc_contract_version_boundariesThe one
--libfailure isprocess_container::...::host_to_container_loopback_connects(10060). It needs host-to-container networking on the machine and fails the same way on
unmodified main.
Notes
the public network options to the session; until then they run on the OS side.
(lab)prefix. A shipping binary never emits it.