Skip to content

[IsoSession] Network policy admission pass and lab-only loopback gate - #1796

Open
Ion Vasilian (ionvasilian) wants to merge 1 commit into
mainfrom
user/ionv/isolation-session-network-test-pass
Open

Ion Vasilian (ionvasilian) wants to merge 1 commit into
mainfrom
user/ionv/isolation-session-network-test-pass

Conversation

@ionvasilian

@ionvasilian Ion Vasilian (ionvasilian) commented Nov 18, 2026 •

Copy link
Copy Markdown

[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 or
pipeline sets.

Changes

  • tests/scripts/run_isolation_session_network_test.ps1 (new)
    • 31 dry-run admission rows, ordered: network on/off, L3/L4 egress rules, loopback, proxy.
      Each row sends a 1.1.0-alpha request to wxc-exec --dry-run and asserts accept, or reject
      with the expected reason. Row configs are passed as files, not on the command line.
    • Rows assert capability outcomes only, never ProcessContainer field shapes.
    • Lab-only. L01 runs first as a canary: if a shipping binary rejects it at parse time, the
      pass reports a skip (exit 77) and runs no rows. Any other L01 failure fails the pass.
    • Runs under PowerShell 7 and Windows PowerShell 5.1.
  • src/mxc-sdk/src/backends/isolation_session/common/policy.rs
    • Under cfg(isolation_session_network_lab) only: an egress-deny policy with allow rules
      for 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 with
      isolation session network (lab): <reason>. Adds lab_tests.
  • src/mxc-sdk/src/backends/isolation_session/common/one_shot.rs
    • Lab cfg only: adds EGRESS_RULES to the supported set. Adds lab tests.
  • src/mxc-sdk/src/core/mxc_contract/dev/request.rs
    • Lab cfg only: with no runtime proxy, the network shape is left to the backend gate.
  • Tests that differ under the lab cfg state the lab-cfg expected result (no exemptions):
    • config_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_network
      expects a OneShot request under the lab cfg.
    • tests/mxc_contract/v1_1_0_alpha/fixtures.rs: under the lab cfg, the set of invalid
      fixtures the parser now defers to the backend must equal an explicit list.
  • New invalid fixture v1_1_0_alpha/.../invalid/isolation_session_declared_loopback_ports.json
    pins that a shipping build rejects the declared-loopback shape.
  • src/mxc-sdk/Cargo.toml
    • Registers isolation_session_network_lab under [lints.rust] unexpected_cfgs.
  • scripts/ci/build-windows-sdk-test-bundle.ps1 and
    .azure-pipelines/templates/IsolationSession.TestBundle.Build.Job.yml
    • Stage the script into the TestBundle test_scripts folder. The pipeline step skips it when
      absent, so older branches still build.

Not changed

  • Published contracts (0.9.0-alpha, 1.0.0) and their parsers.
  • Shipping admission. Existing network rejection fixtures are untouched.
  • Public types, CLI flags, CI suites.

Validation

Run locally on Windows, on main 8e368f0, shipping and lab cfg
(RUSTFLAGS=--cfg isolation_session_network_lab):

Check Shipping Lab
cargo fmt --all -- --check clean clean
cargo clippy -p mxc-sdk --features isolation_session --all-targets -- -D warnings clean clean
--lib 2822 passed, 1 failed 2834 passed, 1 failed
mxc_contract_v0_9_0_alpha 278/278 278/278
mxc_contract_v1_0_0 281/281 281/281
mxc_contract_v1_1_0_alpha 390/390 390/390
mxc_contract_version_boundaries 21/21 21/21
Admission pass exit 77 (skip, L01 rejected at parse time) 31/31

The one --lib failure is process_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

  • Runtime reachability rows are not part of this change. They land with the change that passes
    the public network options to the session; until then they run on the OS side.
  • A lab binary rejects shapes with the (lab) prefix. A shipping binary never emits it.

@ionvasilian
Ion Vasilian (ionvasilian) requested a review from a team November 18, 2026 00:02
@ionvasilian
Ion Vasilian (ionvasilian) requested a review from a team as a code owner November 18, 2026 00:02
Copilot AI balanced review requested due to automatic review settings November 18, 2026 00:02
@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.

🟡 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
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

@ionvasilian
Ion Vasilian (ionvasilian) force-pushed the user/ionv/isolation-session-network-test-pass branch from b7bd3f4 to 1a3f09b Compare November 18, 2026 00:20
Copilot AI balanced review requested due to automatic review settings November 18, 2026 00:20

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.

🔵 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

@ionvasilian

Ion Vasilian (ionvasilian) commented Nov 18, 2026 •

Copy link
Copy Markdown
Author

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: run_isolation_session_network_test.ps1 -Lab -Runtime -RuntimeSetupScript <host setup> -WxcExePath <lab wxc-exec>. It ran in an interactive user session, not a service session.

Result: 40/40 passed (exit 0).

  • Admission: 31/31
  • Runtime: R01 external TCP denied, R02 external UDP denied, R03 undeclared loopback port denied, R04 ::1 on declared port denied, R05 declared port with host listener down, R06 declared loopback port reachable, R07 DNS resolution denied, R08 session exited cleanly, R99 no leaked session resources: all PASS.

Restoration and cleanup, checked independently after the run:

  • The host setup script's Restore removed every value it had set; none remained.
  • No relay, wxc-exec or test processes were left.
  • The agent-user count matched the pre-run baseline.

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 adpa-ms 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.

[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-exec with 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
@ionvasilian
Ion Vasilian (ionvasilian) force-pushed the user/ionv/isolation-session-network-test-pass branch from 1a3f09b to 83d1575 Compare November 18, 2026 22:50
Copilot AI balanced review requested due to automatic review settings November 18, 2026 22:50
@ionvasilian Ion Vasilian (ionvasilian) changed the title [IsoSession] Network policy capability test pass and lab-only loopback gate [IsoSession] Network policy admission pass and lab-only loopback gate Nov 18, 2026
@ionvasilian

Copy link
Copy Markdown
Author

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.

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.

🟡 Changes recommended

The test script skips the shipping-mode admission checks and lacks the runtime path needed to reproduce the claimed reachability, process-exit, and resource-cleanup validation.

2 open issues

Review effort: Balanced

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.

🔵 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

@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.

Gudge needs more time to review this PR before it is merged. Please hold off on merging until that review is complete.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs-Author-Feedback Waiting for additional information or action from the issue or pull-request author. label Nov 19, 2026

@adpa-ms adpa-ms 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.

[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.

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

Needs-Author-Feedback Waiting for additional information or action from the issue or pull-request author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants