mxc icon indicating copy to clipboard operation
mxc copied to clipboard

[LXC] runtimeConfig.networkProxy is rejected: the backend never declares RUNTIME_PROXY, so GA model 2 cannot be expressed

Open SohamDas2021 opened this issue 2 months ago • 1 comments

Status update — PR #1041 merged (2026-09-16, 0d4d6934)

The enforcement half of this issue is now delivered. Only the reachability half and the declaration remain.

The body below lists two prerequisites before RUNTIME_PROXY could be declared honestly:

  1. Reachability — translate the loopback endpoint to an address the container can reach.
  2. Enforcement — D5's backend rule requires making only that outbound endpoint reachable, which the FORWARD-only hook could not do (#998).

#1041 closes (2). LXC egress now hooks OUTPUT inside the container's own network namespace via nsenter (network_iptables.rs:1581), so container-to-host traffic traverses the chain instead of bypassing it on the host INPUT path. The proxy E2E asserts GATEWAY_DNS_BLOCKED where it previously only reported GATEWAY_DNS_REACHED, which is exactly the acceptance criterion (2) needed. #998 is closed on that basis.

Remaining work: the loopback-to-gateway translation, declaring RUNTIME_PROXY in lxc_network_policy_support(), the enforcement probe test that keeps the bit honest, and the doc updates. The rejection quoted below (validator.rs:167-173) is unchanged and still fires.

One caveat that survives #1041: the translation target has not been measured across LXC topologies. The bridge gateway is the host from inside a bridged container, but a directly-routed veth is a different shape, and nothing in this issue or #1041 establishes which address is correct there.

The body below is unchanged apart from this note.


Relevant area(s)

Linux

Brief description of your issue

LXC supports the cooperative proxy (since #798) but rejects the schema 0.8 GA spelling for it, so GA connectivity model 2 cannot be expressed on LXC at all.

lxc_network_policy_support() omits RUNTIME_PROXY:

// src/backends/lxc/common/src/lxc_runner.rs:678-683
fn lxc_network_policy_support() -> NetworkPolicySupport {
    NetworkPolicySupport::EGRESS_DEFAULT
        | NetworkPolicySupport::EGRESS_RULES
        | NetworkPolicySupport::INGRESS_DEFAULT
        | NetworkPolicySupport::HOST_LOOPBACK
}

validate_runner (:687) passes that set to the shared gate, which refuses the field outright:

// src/core/wxc_common/src/validator.rs:167-173
if !support.contains(NetworkPolicySupport::RUNTIME_PROXY)
    && request.policy.runtime_network_proxy_specified
{
    return Err(ScriptResponse::error(
        "runtimeConfig.networkProxy is not supported by the selected backend",
    ));
}

The check keys on runtime_network_proxy_specified — set purely from which field the caller wrote — so it fires regardless of the URL's value, and before the shared loopback validation is ever consulted.

LXC is the only backend that supports a proxy and refuses this spelling:

Backend RUNTIME_PROXY Source
BaseContainer (PSEC) declared (ALL) base_container_runner.rs:2065
AppContainer declared appcontainer_runner.rs:1524
Seatbelt declared seatbelt_runner.rs:110
Bubblewrap declared bwrap_runner.rs:86
LXC absent lxc_runner.rs:678

Every spelling the GA spec maps onto model 2 is refused on LXC:

Form LXC Where
runtimeConfig.networkProxy rejected validator.rs:167
proxy.builtinTestServer rejected config_parser.rs:975
proxy.localhost: <port> rejected config_parser.rs:982
proxy.url — loopback literal rejected config_parser.rs:1016
proxy.url — remote IPv4 accepted — the only working form —

D5 (docs/sandbox-policy/0.8.0/networking/networking.md:325-330) states the proxy must be on localhost for GA and that "Remote proxies are out of scope for GA". So the one form LXC accepts is the one GA excludes, and the one GA prescribes is refused.

This is not a one-line fix, and declaring the bit alone would be a regression. LXC rejects loopback proxy endpoints for a real reason: the container has its own network namespace, so 127.0.0.1 names the container, and LXC has no host-loopback reachability primitive (contrast Bubblewrap, which rewrites such endpoints to slirp's gateway 10.0.2.2). Two things are needed before the bit can be declared honestly:

  1. Reachability — translate the loopback endpoint to an address the container can reach (the bridge gateway is the host), the way LXC already pins a resolved proxy hostname into the container's /etc/hosts.
  2. Enforcement — D5's backend implementation rule requires making "only that outbound endpoint reachable". Today the egress chain is hooked only into host FORWARD, so traffic addressed to the bridge gateway traverses host INPUT and is unfiltered (#998). A proxy reached at the gateway would come with the rest of the host-local surface open.

Declaring RUNTIME_PROXY without (2) would add a fourth over-declared capability bit — precisely the class of defect #998 was filed for.

Steps to reproduce

  1. Save the GA model-2 example from docs/sandbox-policy/0.8.0/networking/networking.md:189-204, retargeted at LXC:

    {
      "version": "0.8.0-alpha",
      "containment": "lxc",
      "process": { "commandLine": "curl -fsSL https://api.github.com/zen" },
      "network": {
        "egress": { "default": "deny" },
        "ingress": { "default": "deny", "hostLoopback": "deny" }
      },
      "runtimeConfig": { "networkProxy": "http://127.0.0.1:8080" }
    }
    
  2. Start any HTTP proxy on the host at 127.0.0.1:8080.

  3. Run it: sudo lxc-exec --config model2.json

Expected behavior

The container runs with egress confined to the configured proxy endpoint, matching connectivity model 2 as defined in the GA spec — the same posture Bubblewrap, Seatbelt, AppContainer and BaseContainer already provide for this exact configuration.

Actual behavior

The run is refused before the container starts:

runtimeConfig.networkProxy is not supported by the selected backend

The message names the field rather than the address, so it is not a "wrong endpoint" diagnostic — LXC declines the GA spelling entirely. Substituting "networkProxy": "http://localhost:8080" or "http://[::1]:8080" produces the identical error, since the gate fires on field presence.

The only configuration that runs a proxy on LXC today is the legacy shape with a remote endpoint plus enforcementMode:

{
  "version": "0.8.0-alpha",
  "containment": "lxc",
  "process": { "commandLine": "curl -fsSL https://api.github.com/zen" },
  "network": {
    "defaultPolicy": "block",
    "enforcementMode": "firewall",
    "proxy": { "url": "http://proxy.corp.example.com:8080" }
  }
}

which is the posture D5 places out of scope for GA.


Additional context

  • Follow-up to #655 (closed 2026-08-29), whose last expected-outcome bullet was "Confirm which backends honor the relocated proxy." That confirmation was never recorded, and LXC was left out.
  • Overlaps #998 for the enforcement half.
  • PR #1041 moves LXC egress enforcement into the container's own namespace OUTPUT chain, which would put container-to-host traffic under the chain and supply the enforcement half. If it lands, this becomes materially easier.
  • #1074 is the SDK-side gate on the legacy network.proxy for LXC — related but distinct.

Suggested acceptance criteria

  • A config matching the GA model-2 example runs on LXC, or the rejection is documented in the spec's LXC section as a known non-conformance.
  • Only the configured proxy endpoint is reachable; other host-local destinations are not.
  • The declaration is paired with an enforcement probe test, as bwrap_runner.rs::every_network_policy_support_bit_is_a_deliberate_decision does, so the bit cannot be declared without enforcement behind it.
  • docs/lxc-support/lxc-backend.md and the backend table in docs/sandbox-policy/0.8.0/networking/networking.md updated.

Release tracking

Completed by #1554 after v1.0.1. Programs in an LXC container can now use a proxy listening on the host's local address. MXC relays those connections while the program runs. This supersedes the earlier remaining-work note above.

SohamDas2021 avatar Sep 03 '26 23:09 SohamDas2021

Proxy with host loopback was never supported in LXC in the past and this would be new feature work. Tracking in post 1.0 ADO items.

SohamDas2021 avatar Sep 16 '26 22:09 SohamDas2021