Every VM runs a proxy and is on one of four tiers, so the proxy's messages
name the VM's proxy, the unenforced ones its network tier, and the
redaction ones say devvm keeps secrets on this machine on every tier.
Message IDs are unchanged.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
config.toml's [proxy] table (https, http, no-proxy) is the company proxy that
VMs' proxies and builds go through when devvm's environment sets neither
HTTPS_PROXY nor HTTP_PROXY; the environment's settings win whole, never mixed
with config.toml's. Each value is checked as config.toml is read
(backend.CheckProxyURL, backend.CheckNoProxy), and a URL holding a password is
refused (proxy_password_in_config): config.toml is copied between machines
and kept with dotfiles.
The password is the host-only secret proxy (devvm secret set proxy, in the
Keychain or devvm's secrets folder). A URL that names a user gets
upstream.secret in the proxy's config, and the proxy looks the value up
through IO.Secret as it starts (upstreamPassword), so no file of devvm's holds
it. No VM is ever bound to it: devvm secret use refuses (secret_host_only) and
secrets.Names drops it. A new VM and a VM's proxy refuse to start while it
isn't saved (proxy_password_missing, netpolicy.Proxy.Upstream).
A start whose VM's proxy last ran with an upstream and now has none warns
(upstream_proxy_gone), naming config.toml, with a doc link.
- settings.HostProxy: the environment's, else config.toml's; used by
netpolicy, Lima's build proxy (buildUpstream) and devvm doctor's CA hint.
- proxy.Upstream.Secret, proxy.UpstreamSecret; secrets.Secret.HostOnly;
secrets.Token keeps spaces inside the proxy password.
- Messages: proxy_password_in_config, proxy_password_missing,
upstream_proxy_gone, secret_host_only, proxy_password_howto,
password_prompt (answered by --stdin).
- Tests: TestHostProxy, TestUpstreamSecret, TestPrepareUpstreamConfig,
TestBuildUpstreamConfig, config.toml refusals, the warning in
TestPrepareUpstream, company_proxy.txtar, secret.txtar and ca.txtar cases.
- Docs: troubleshooting's Behind a company proxy, network policy's Behind a
company proxy and secrets, config.toml's reference, How it works.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
devvm _proxy runs with one argument, -config FILE: proxy.Config as JSON
(version 1), which a VM's proxy (vms/<hash>/run/proxy.json, written by
netpolicy.Proxy) and a build's (build-proxy/proxy.json, written by
backend.ProxyStarter) both use. It holds what the flags and the run
folder's sidecars held: the address, the VM, the password (proxy.auth),
the built-in policies and the user's files (proxy.policy), the logs, the
lifeline, the CA, the secrets, the user's CAs (proxy.cas), the company
proxy (proxy.upstream, now proxy.Upstream), upstream_unresolved, the Nix
cache and its cap, the links, and the SHA-256 of devvm's binary and CA
(proxy.bin, proxy.ca), which the proxy doesn't read. devvm writes it whole,
mode 600, before each start, and starts a running VM's proxy again when
the config it would start it with has another Sum. ReadConfig reads it as
the links' list is read (readPrivate): O_NOFOLLOW and O_NONBLOCK, fstat,
a regular file owned by the proxy's user that nobody else may read or
write, at most 1 MiB, of ConfigVersion, no unknown field, a password, a
loopback listen address. The VM's proxy is found by _proxy -config with
its own config's path. paths.VM names ProxyConfig, ProxyPID and
ProxyStatus.
Policy files are read only as regular files of at most 1 MiB
(proxy.ReadRegular, PolicyMax), in the proxy, devvm network and doctor, so
a FIFO or a link to /dev/zero can't hang them (ErrNotRegular, ErrTooLong;
ErrNotPrivate for the config and the links' list); the proxy keeps a
file's last rules and logs why once.
hostOK refuses a name with an empty label (evil.test.., evil..test,
.evil.test), so no form of a name gets past a deny the policy's own trim
would miss.
A build proxy that can't be spawned leaves no config behind.
Tests: config round trip and Sum; ReadConfig refusing a link, a FIFO, a
folder, group-readable and group-writable files, a long file, other
versions, unknown fields, two configs, no password, non-loopback
addresses, a CA without its key, a negative cap; ReadRegular and the
policy readers on a FIFO, /dev/zero and a big file without hanging; the
running proxy keeping its last rules; hostOK and requests with empty
labels (failing on the code before); Prepare's config, restarts on a
binary change, a missing config and one others may read; concurrent
config writes; the build proxy's config and its removal; proxy.txtar,
network.txtar, nix_cache.txtar and layout.txtar; e2e checks of the
config's mode, password and the proxy's arguments.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>