5 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 9c74dac11e fix(logs): a VM's logs are held to their caps while it runs
internal/vmlog owns every log a VM can drive but the proxy's own:
Limit (moved from vmssh's logLimit, with Allow for the link session's
warnings), Capped and Trim for ports.log and links.log while they run,
and KeepVM, which the VM's proxy (proxy.IO.KeepLogs, Config.VMLogs from
backend.Run.Logs) and a Lima build run on the serial consoles' and the
hostagent's logs: redacted as they grow (redact.FileFrom), so a reboot
in place can't leave the proxy password there, and rotated past 10 MiB,
counting what a log holds past the hole its writer left
(platform.DataStart).

The proxy's http.Server logs through its own limited log, and its
copied log counts what reached it as stderr; the build proxy's log is
held as a VM's proxy's is. git-pins.jsonl has a cap. Run logs take at
most 256 MiB together, never the newest or a live run's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:32 -07:00
w3cjandClaude Opus 5.5 a7cc12521e test(fuzz): fuzz targets with properties, fuzzed nightly
Twenty-three new fuzz targets, built-in Go fuzzing, each checking a
property rather than only that nothing panics: parsers of what a VM or
the network sends fail closed and keep to their caps, a secret goes only
where it's bound, and no planted secret survives a redaction.

- internal/proxy: FuzzCursorFrames (passes only what came; no message
  over frameMax or holding a JWT's start, decompressed and unescaped),
  FuzzInject (a binding's value only to a host it names, judged apart
  from the matcher in NormHost's form, for its path and methods, in its
  own header, which held the exact placeholder once; other headers
  untouched), FuzzParseBindings, FuzzLinkList, FuzzParseUpstream (errors
  hold no more of the URL than its scheme), FuzzNoProxy, FuzzParseNarinfo
  (only cache.nixos.org-1's signed narinfo is taken).
- internal/agentlogin: FuzzParseTokenRequest, FuzzRedact (secrets planted
  eight ways in JSON and TOML settings), FuzzCapture (the VM's reply holds
  none of the endpoint's tokens).
- internal/redact: FuzzSplit (a password written in parts through Split,
  as the run log writes it, never survives).
- internal/jsonc: FuzzStrip, differential against encoding/json.
- internal/upgrade: FuzzParsePublicKey, FuzzVerify, FuzzEntryName,
  FuzzUnpack.
- internal/vmssh: FuzzParseHostKeys, FuzzParsePorts.
- internal/vm: FuzzParseCloneState, FuzzParseInit, FuzzParseKept,
  FuzzParseLFSPointer.
- internal/desktop: FuzzHandshakeVM.

What they found, each fixed with a regression test:
- NO_PROXY: an entry with port 0 (git.test:0) was read as the host on
  every port, and git.test:080 or :+80 as port 80, which Go's clients
  match against nothing; an entry whose port no request has, or that
  isn't plain decimal, now matches nothing (TestNoProxy,
  testdata/fuzz/FuzzNoProxy). FuzzHostSites' NO_PROXY site allows this
  difference from its frozen copy, and the design note lists it.
- A JSON token request with more after its object was judged by its
  first object; it's refused now (TestCaptureRefuses).

The Fuzz workflow runs nightly rather than two minutes weekly: five
minutes a target, eight at a time, each target's corpus restored from
and saved to a cache of its own (a failing input added to it, so it
fails nightly until fixed), new inputs minimized in at most 1,000 runs,
and one issue, "Fuzzing found failing inputs", opened, commented on when
the failing targets change and closed on a clean night, by a separate
job with issues: write that runs no repo code, on main alone. Target
names must be unique across packages. bump.sh moves an action in a
folder of its repo (actions/cache/restore, /save) with its repo's
releases.

Docs: Contributing's Fuzzing (running a target, the nightly run, every
target's property), Maintaining's Fuzzing failures and its actions bump,
the proxy README, the NO_PROXY and token request facts in How it works'
network page and the design note.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:31 -07:00
w3cjandClaude Opus 5.5 4d409589bb refactor(redact): every secret's value is a redact.Secret, revealed only where it's used
redact.Secret holds a value that lets whoever has it act as the user or
a VM, behind a pointer, so fmt's raw printing of an unexported field
shows only an address. String, GoString and Format print <redacted> for
every verb; MarshalJSON, UnmarshalJSON and MarshalText return
redact.ErrEncode, so a secret is never silently written as a stand-in
(which would lose a login); there's no LogValue. NewSecret ("" is the
zero Secret), Reveal, Empty and TrimSpace are the rest. internal/redact
joins the proxy's standard-library-only depguard group.

Reveal is refused by forbidigo outside tests; each of the 23 call sites
carries a //nolint:forbidigo saying why, and testdata/lint/forbidigo.go
keeps a call the rule must report. The structure test (checkSecrets)
refuses a struct that embeds redact.Secret outside internal/redact and
an interface that declares Reveal() string.

Typed now: proxy.Config.Password (configFile is the wire type, in
Config's order, held to it by TestConfigFile), the server's password,
proxy.Lookup and the cached values, upstream.auth, upstreamPassword,
Upstream.WithPassword's password; backend.NewProxyPassword, ProxyURL,
Confinement.ProxyPassword, BuildProxy.Password; netpolicy.Key and
NetMade.ProxyKey (netMade wire type); settings.CompanyProxy.Password;
secrets.Store.Value, saved, ProxyPassword, Token, Save, save, Get,
SaveKey, Yours.Save, Claude.Env, saveToken, oauthToken; agentlogin
File.Get, SetKey, ClaudeToken, every format's get, setKey and chatGPT,
refresh's refresh token, capture's access, refresh and id tokens, and
the JWT helpers (a login's map stays the wire, through token and
setToken; piKey is piBound); vm.Net.SecretSave, AgentLoginOptions.Key;
ui.UI.Secret. Strings by design: platform.KeychainGet/Set and the
desktop's VNC password.

Tests: TestSecret (unexported and nested fields too), TestConfigFile,
TestV010ProxyConfigs (0.1.0's proxy.json round-trips byte for byte),
TestFixtureStoreGet saves the Linux secret file back byte for byte,
checkV010Logins (login files read, copied and bound without a change),
secretCases, and e2e netNoLeaks, twice in the network section: every
VM's proxy password and the section's values, also as Basic
credentials, in no run log or proxy log, and the passwords in no
ha.stderr.log or serial log. Docs: Contributing's Secrets in the code,
the owners table, the secrets How it works page, design.md's Where
secret values live.

Fixed, found by netNoLeaks: Lima's boot script 07-etc-environment.sh
runs under set -x, so the console logs (serial*.log) kept the VM's
proxy password; redactLog now stars passwords in them as it does in
ha.stderr.log (CHANGELOG, overview, processes and attack-vectors pages).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:36:31 -07:00
w3cjandClaude Opus 5.5 9c1af22910 fix(redact): find proxy passwords without a scheme and passwords split mid-line
redact.String takes the password out of a proxy URL without a scheme
(user:password@host:port), which needs the port and a user that starts a
word, so emails, mailto: links and ssh targets stay as they are.
redact.Split says where a writer may end part of a line: after its last
space or tab, at most 4 KiB before its end, never inside a secret. The run
log's redacting writer uses it when a line passes 64 KiB and at a logged
command's start (flushPart), and holds the rest for the next write, so a
password split there is still found; DieLogged and the run's end write it all.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 15:22:08 -07:00
w3cjandClaude Opus 5.5 12d1a84149 fix(redact): proxy passwords stay out of Lima's hostagent log and guest commands' output
Lima's hostagent logs a proxy variable's value, password and all, as it
starts a VM (Lima's cidata setupEnv: a loopback proxy pointed at the
guest's gateway, an override of the system's value, or a value it can't
parse), into <lima home>/<vm>/ha.stderr.log. For a VM without network
policy that's the shell's HTTPS_PROXY. devvm's run log already redacted
the copy limactl start prints; Lima's own file kept it.

Start now redacts that file once limactl start ends, started or failed:
each password becomes as many "*", in place. Lima creates the file with
os.Create (no O_APPEND) and the hostagent keeps writing at its own
offset, so the file keeps its length and every other byte, and Lima goes
on where it was. Keeping the password out of the hostagent's
environment would keep it out of the guest too (Lima writes the guest's
/etc/environment from it), so apt and curl there couldn't use the
company proxy. A file devvm can't change warns (lima_log_unredacted).

Output written through UI.LogWriter() (guest commands: a VM's setup, the
home folder's copy, devcontainer.json's commands) now goes through the
run's one redacting writer, flushed at a logged command's start, at
DieLogged and at the run's end.

The patterns and both redactions have one owner, internal/redact (stdlib
leaf): String, the run log's (moved from ui's redact), and File.

- redact.String, redact.File; ui: LogWriter's redacting, flushLog;
  lima: redactLog; message lima_log_unredacted.
- Tests: TestLogWriterRedacts (fails without the fix),
  TestStartRedactsTheHostagentLog, TestString, TestFile; e2e's network
  section restarts its VM without network policy behind the run's
  loopback company proxy, its fake password read from a file: the guest
  has and uses the proxy, the run logs hold <password> only and
  ha.stderr.log stars only.
- Docs: troubleshooting's run log, network policy's Without network
  policy, Contributing's layers and e2e network section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 12:52:42 -07:00