mxc icon indicating copy to clipboard operation
mxc copied to clipboard

Process container: hostLoopback allow opens every localhost port; egress allow/deny rules are ignored

Open trevotai-amd opened this issue 4 weeks ago • 1 comments

Relevant area(s)

Windows

Brief description of your issue

In the Windows process container backend, setting "ingress": {"hostLoopback": "allow"} gives the sandbox access to every port on the host's loopback interface. The egress rules in the same policy are not applied to that traffic: an allow rule for one port does not restrict the others, and an explicit egress deny for a port is also ignored. There is no error or warning.

This contradicts docs/networking.md (1.0.0 and current main), which says egress rules "narrow the outbound public and private destinations" and that "an explicit block always wins over an allow".

Impact: a policy that lets an agent reach one local service (e.g. a local model server on 127.0.0.1:8080) also exposes every other local service on the host. Proxy mode (runtimeConfig.networkProxy) does restrict this correctly; plain host loopback does not.

Related: #998 (same class of gap on the LXC backend, fixed); #830 (closed by design, covers the inbound direction of privateNetworkClientServer, not the outbound port rule reported here).

Versions: MXC 1.0.0 and 1.0.1 (wxc-exec.exe from npm @microsoft/mxc-sdk), Windows 11 26300.9550 and 26300.9711, reproduced on three PCs.

Steps to reproduce

Work in one folder. In the config, replace <DIR> with that folder and <PY> with the folder that holds python.exe (in JSON, double each backslash).

  1. Start two listeners on the host: python -m http.server 8080 and python -m http.server 8081.
  2. Create probe.py:
    import socket
    for port in (8080, 8081):
        try:
            socket.create_connection(('127.0.0.1', port), 3); print(port, 'REACHED')
        except OSError as e:
            print(port, 'blocked', e)
    
  3. Create B.json:
    {"version": "1.0.0", "containment": "processcontainer",
     "process": {"commandLine": "python probe.py", "timeout": 60000},
     "filesystem": {"readonlyPaths": ["<DIR>", "<PY>"]},
     "processContainer": {"capabilities": ["internetClient", "privateNetworkClientServer"]},
     "network": {"egress": {"default": "deny", "allow": [{"to": [{"cidr": "127.0.0.1/32"}], "ports": [{"protocol": "tcp", "port": 8080}]}]},
                 "ingress": {"default": "deny", "hostLoopback": "allow"}}}
    
  4. Run wxc-exec B.json.
  5. Add an explicit deny for 8081 to egress and run again: "deny": [{"to": [{"cidr": "127.0.0.1/32"}], "ports": [{"protocol": "tcp", "port": 8081}]}]

Expected behavior

8080 REACHED, 8081 blocked (both runs).

Actual behavior

Both runs:

8080 REACHED
8081 REACHED

No error or warning.

Variations (same result on 1.0.0 and 1.0.1):

Egress (default deny) Ingress default hostLoopback 8080 8081
allow 8080 (no explicit capabilities) deny allow REACHED REACHED
allow 8080 allow allow REACHED REACHED
no allow rules deny allow REACHED REACHED
allow 8080 + explicit deny 8081 deny allow REACHED REACHED
allow 8080 allow deny blocked blocked

Host loopback is effectively all-or-nothing.

trevotai-amd avatar Nov 03 '26 23:11 trevotai-amd

Hey @trevotai-amd thanks for the bug. Yup, hostloopback: allow for v1 is a toggle to turn on and off loopback networking in general. That said, you should still be able to individually block loopback/ports in the deny list even with this toggled on which is a bug. This will require an OS fix which likely won't start get pushed to devices until the end of January. I'll update this issue once we have a date and KB number.

Thanks!

bbonaby avatar Nov 23 '26 06:11 bbonaby