Skip to content

[WSLC] Custom proxies and host loopback for the built-in proxy - #1816

Open
Elliot (theelliotm) wants to merge 2 commits into
mainfrom
user/emichlin/wslc-proxy-custom-proxy
Open

Elliot (theelliotm) wants to merge 2 commits into
mainfrom
user/emichlin/wslc-proxy-custom-proxy

Conversation

@theelliotm

@theelliotm Elliot (theelliotm) commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

📖 Description

Adds custom proxies and host loopback to WSLC create-and-run requests that use the built-in proxy. Also allows host loopback with bridged create-and-run.

Custom proxies (runtimeConfig.networkProxy)

  • With egress filtering, the workload's traffic goes only to the custom proxy, through the built-in proxy. These requests are no longer rejected.
  • Hostname proxies keep their URL and resolve to the built-in proxy; IP proxies are rewritten to its address.
  • Proxies on Windows 127.0.0.1 or localhost are relayed to Windows 127.0.0.1. Other loopback addresses, 0.0.0.0, IPv6 and hostnames that resolve to loopback are rejected.
  • networkProxy with egress allow and a non-allow ingress default is rejected.
  • Port mappings work together with networkProxy.

Host loopback (network.ingress.hostLoopback: "allow")

  • Built-in proxy: the session's host loopback is enabled and reached through the proxy as host.wslc.internal (NET_ADMIN is added to the proxy container only).
  • Bridged: egress and ingress allow now uses bridged networking whatever hostLoopback is. host.wslc.internal is reachable only with hostLoopback: "allow".
  • Create-and-run only. Container lifecycle operations are unchanged: they still require all-allow or all-deny and never enable host loopback.
  • Fails with backend_unavailable if the WSL runtime is too old or capability additions are disabled.

🔗 References

Refs #1462

Closes #1810
Closes #1811

Spec: docs/development/architecture/designs/1462-wslc-builtin-proxy/README.md (#1625)

🔍 Validation

  • cargo test -p mxc-sdk --features wslc --lib -- wslc: passed (475)
  • cargo fmt --all -- --check and cargo clippy -p mxc-sdk --features wslc --all-targets -- -D warnings: passed
  • node scripts/versioning/validate-configs.js: passed (471 configs)
  • WSL 3.0.5, ARM64:
    • Custom proxies: a 24-test subset of tests/scripts/run_wslc_all_tests.ps1 (built-in proxy, port mappings, new custom proxy runs, rejections) passed.
    • Host loopback: the new configs ran directly with wxc-exec against a Windows 127.0.0.1 test server and passed: built-in proxy with and without a port mapping, loopback custom proxy, bridged with hostLoopback allow (host.wslc.internal returns 200) and omitted (name doesn't resolve), and the loopback and egress-allow rejections.
  • Manual lifecycle check: a bridged container with hostLoopback: "allow" can't resolve or reach host.wslc.internal, and can still reach the internet.
  • Not run: full tests/scripts/run_wslc_all_tests.ps1, and the Node/.NET WSLC E2E suites (only the removed rejection cases changed there).

✅ Checklist

  • Signed the Contributor License Agreement
  • Linked to an issue
  • For features or changes requiring a spec: linked the issue with maintainer-applied feature-accepted
  • For implementation: linked the required approved and merged design/API spec, or explained why no spec is required
  • Feature issue remains open unless this PR completes all agreed implementation, validation, and documentation
  • Updated documentation (if applicable)
  • Updated Copilot instructions (if build, architecture, or conventions changed)
  • If this PR changes Cargo.lock, the dependency-feed-check check passes (see pull request builds)

📋 Issue Type

  • Bug fix
  • Feature
  • Task
Microsoft Reviewers: Open in CodeFlow

Elliot (theelliotm) and others added 2 commits November 18, 2026 17:10
With egress denied in create-and-run mode, runtimeConfig.networkProxy now runs
behind the built-in proxy, which relays the workload only to the custom proxy.
Hostname proxies keep their URL and resolve to the built-in proxy; IP proxies
are rewritten to its address. Loopback proxies are rejected for now.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c3f64c2c-9005-43eb-a803-a91fb7265c5b
Copilot AI balanced review requested due to automatic review settings November 19, 2026 01:15
@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

V1 requests now use unfiltered bridged networking instead of the built-in proxy, breaking compatibility and removing direct-traffic restrictions, while bridged proxy configurations also strip required Windows-loopback exemptions.

2 open issues
What changed in this PR

Extends MXC’s WSLC create-and-run networking with custom-proxy relaying and Windows host-loopback access, building on the built-in proxy design. Container lifecycle behavior remains unchanged.

Changes:

  • Adds custom-proxy validation, hostname preservation, IP rewriting, and port-mapping support.
  • Enables host loopback for proxied and bridged runs, with runtime and administrative-policy checks.
  • Extends functional validation, removes obsolete SDK rejection cases, and updates backend documentation.
File Description
tests/​scripts/​run_wslc_all_tests.ps1 Adds proxy and host-loopback validation scenarios.
tests/​configs/​wslc_network_egress_rules_host_loopback_rejected.json Removes obsolete host-loopback rejection fixture.
tests/​configs/​wslc_network_egress_port_mapping_network_proxy.json Tests custom proxies alongside port mappings.
tests/​configs/​wslc_network_egress_port_mapping_network_proxy_rejected.json Removes obsolete proxy/port-mapping rejection fixture.
tests/​configs/​wslc_network_egress_port_mapping_host_loopback.json Tests host loopback alongside port mappings.
tests/​configs/​wslc_network_egress_port_mapping_host_loopback_rejected.json Removes obsolete loopback/port-mapping rejection fixture.
tests/​configs/​wslc_network_egress_network_proxy_unresolvable_rejected.json Tests rejection of unresolvable proxy hostnames.
tests/​configs/​wslc_network_egress_network_proxy_loopback_rejected.json Tests rejection of unsupported loopback addresses.
tests/​configs/​wslc_network_egress_network_proxy_https_ip_rejected.json Tests rejection of HTTPS proxies using IP addresses.
tests/​configs/​wslc_network_egress_network_proxy_egress_allow_rejected.json Tests rejection of incompatible proxy/network defaults.
tests/​configs/​wslc_network_egress_host_loopback.json Tests host-loopback access with egress filtering.
tests/​configs/​wslc_network_egress_custom_proxy_loopback.json Tests relaying to a Windows-loopback proxy.
tests/​configs/​wslc_network_egress_custom_proxy_ip.json Tests IP-based proxy rewriting and isolation.
tests/​configs/​wslc_network_egress_custom_proxy_https_name.json Tests hostname preservation and TLS verification.
tests/​configs/​wslc_network_bridged.json Adds a bridged host-loopback probe.
tests/​configs/​wslc_network_bridged_host_loopback_denied.json Tests bridged networking without host loopback.
src/​mxc-sdk/​src/​backends/​wslc/​common/​wslc_bindings.rs Adds loopback/capability SDK bindings and error constants.
src/​mxc-sdk/​src/​backends/​wslc/​common/​wsl_container_runner.rs Configures session loopback and workload proxy environments.
src/​mxc-sdk/​src/​backends/​wslc/​common/​policy.rs Updates network selection and custom-proxy validation.
src/​mxc-sdk/​src/​backends/​wslc/​common/​egress_gateway.rs Configures relays, DNS, proxy environments, and capabilities.
sdk/​node/​tests/​integration/​wslc-e2e.test.ts Removes the obsolete host-loopback rejection case.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​V1/​MxcContainerWslcE2ETests.cs Removes the obsolete host-loopback rejection case.
docs/​backends/​wslc/​wsl-container-getting-started.md Documents networking behavior, usage, and limitations.

Review effort: Balanced

Comment on lines +199 to +201
return Ok(NetworkMode::Bridged {
host_loopback: ingress.host_loopback == NetworkAction::Allow,
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not true ; will respond tomorrow.

Comment on lines +1139 to +1140
let effective_env: Vec<String> = if let Some(gateway) = &gateway {
gateway.workload_env(request.env_entries(), process_env::EnvScope::of(request))
@theelliotm
Elliot (theelliotm) marked this pull request as draft November 19, 2026 01:29
@theelliotm
Elliot (theelliotm) marked this pull request as ready for review November 19, 2026 01:31

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[WSLC] Support hostloopback when using the built-in proxy. [WSLC] Support custom proxies when using the built-in proxy.

2 participants