mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 14:33:17 -10:00
Behind a company proxy, network policy's proxy connected to servers itself and reached nothing. It now reaches allowed hosts through the host's HTTPS_PROXY / HTTP_PROXY, still deciding each request by the name the VM asked for. Step 1, credentials (traced in the code and the backends' published docs; not yet proven on a real build, which the new e2e checks do): - Lima: build VMs (images, the tools build, --from's conversion VM) started with propagateProxyEnv on, its default. Lima's 07-etc-environment.sh writes the propagated settings into the guest's /etc/environment between #LIMA-START/#LIMA-END on each boot, and a stopped build VM's disk keeps it, so an image built with HTTPS_PROXY=http://user:pass@... kept the password. Fixed: propagateProxyEnv is on only for NetDirect; build scripts get the variables exported on their input (a loopback proxy as host.lima.internal), and /etc/sudoers.d/devvm-build-proxy keeps them for sudo until the scripts end. - Docker: the CLI puts ~/.docker/config.json's proxies into every container it creates, and a commit keeps them (Docker's docs). Fixed: every container devvm makes sets each proxy variable empty (noClientProxy); a Linux engine's build gets the host's settings from an env file (hostProxyEnv); Desktop's build proxy goes through the company proxy. - smolvm: passes the host's proxy only with --use-host-proxy, which devvm doesn't use: nothing to fix. The upstream: - backend.HostProxy (new): ReadHostProxy (capitals, then lowercase), None, Upstream (the proxy's -upstream file; only http:// proxies: upstream_proxy_scheme, upstream_proxy_invalid), Env. - internal/proxy/upstream.go (new): -upstream FILE; ParseUpstream, ErrUpstreamScheme; NO_PROXY as Go reads it; localhost, *.localhost and loopback/unspecified addresses always direct; CONNECT by name with Proxy-Authorization: Basic for tunnels and for the TLS connections that put secrets in (checked against the system roots and -upstream-cas); plain HTTP in absolute form, canonical host, credentials only in the header to the upstream; floorUpstream: addresses judged as before, a name refused when the host's resolver answers with any internal or denied address, unjudged when it can't resolve; Event.Upstream (host:port), and devvm log's "through host:port". - hostOK refuses shorthand addresses (127.1, 2130706433, 0x7f000001), which a company proxy may read as inet_aton does (found in review). - netpolicy: Proxy.Getenv, run/<vm>.proxy.upstream (mode 600), stale() (a changed upstream starts the proxy again), writeUpstream for both files. Also, from a review of the company-CA change: a proxy that needed starting again and didn't end within 2 s of SIGTERM was kept, with its old roots, silently. Stop now sends SIGKILL after 2 s and reports whether it ended; Prepare fails with proxy_stop_failed instead of keeping it (Proxy.Signal seam). Messages: proxy_stop_failed, upstream_proxy_scheme, upstream_proxy_invalid, with doc links. Tests: proxy (TestParseUpstream, TestNoProxy, TestUpstreamTunnel, TestUpstreamNoProxyDirect, TestUpstreamPlainHTTP, TestUpstreamIntercept, shorthand hosts in TestOddHostsRefused), backend (TestHostProxy), lima (TestBuildImageHostProxy, TestGuestProxyURL, propagateProxyEnv expectations), docker (TestBuildHostProxy, create's empty proxy variables), netpolicy (TestPrepareUpstream, TestPrepareStopsTheOldProxy, FormatEvent's upstream). e2e: images (a layer built with a fake proxy password: its script and sudo see it; the image's disk, Lima's files and devvm's logs don't), network (a devvm _proxy as the company proxy: allowed hosts through it by name, blocked ones never reach it, its password nowhere, and back to direct). Docs: safety/network (Behind a company proxy, Without network policy), using/troubleshooting (Behind a company proxy), internals/network (Through a company proxy, restarts, -upstream), internals/design (A company proxy: what an upstream changes, credentials, builds, checks), internals/images, internal/proxy/README.md. Review (security-audit skill, independent pass over the proxy change): the shorthand-address bypass, fixed; a VM-controlled name can force the unjudged branch, documented; refusals name the company proxy's address (no credentials), accepted as on the direct path; a loopback company proxy isn't reachable from macOS builds, documented. Co-Authored-By: Claude Opus 5.5 <[email protected]>