Deep Review: 20261015-112802-pr-5581
| Date | 2026-10-15 11:28 |
| Repo | lima-vm/lima |
| Round | 3 |
| Author | @ranacseruet |
| PR | #5581 — vz: add networkOpts.hostLoopback to block guest access to host loopback |
| Branch | feat/host-loopback-opt-out |
| Commits | c388098f vz: add networkOpts.hostLoopback to block guest access to host loopback |
| Review SHA | c388098fae8c332e1b18060aca05d21cf2795104 |
| Reviewers | Claude Opus 5.5 (effort: high), Codex GPT 6 Astra (effort: high), Gemini 3.1 Pro (effort: default), Gemini 3.5 Flash (effort: default) |
| Verdict | Merge as-is — no Critical or Important finding; the four suggestions are optional |
| Wall-clock time | 19 min 4 s |
Executive Summary ¶
The PR adds networkOpts.hostLoopback. On vz, false maps host.lima.internal and 0.0.0.0 to the unroutable 0.0.0.1, and the other drivers and user-v2 refuse it. This is the round that converged. The rename reaches every consumer, round 2's I1 tests fail when their fixes are reverted, and gvisor-tap-vsock v0.9.0, now on master, does not open a new path to host loopback. The four remaining suggestions are optional.
Critical Issues ¶
None.
Important Issues ¶
None.
Suggestions ¶
user-v2 test does not pin where the refusal lives Claude Opus 5.5 Codex GPT 6 Astra Gemini 3.1 Pro Gemini 3.5 Flash¶
}
}
func TestValidateRejectsHostLoopbackFalseWithUserV2(t *testing.T) {
t.Setenv("LIMA_HOME", t.TempDir())
cfg := &limatype.LimaYAML{
Firmware: limatype.Firmware{LegacyBIOS: new(false)},
NetworkOpts: limatype.NetworkOpts{HostLoopback: new(false)},
Networks: []limatype.Network{{Lima: "user-v2"}},
}
l := &LimaVzDriver{Instance: &limatype.Instance{Config: cfg}}
assert.ErrorContains(t, l.Validate(t.Context()), "not supported with a `user-v2` network")
}
Round 2's S2 is still open. Deleting the refusal at pkg/driver/vz/vz_driver_darwin.go:262-264 fails this test only through a nil-pointer panic in validateConfig, because the fixture leaves Arch unset. Moving the refusal into validateConfig, which limactl delete runs through Configure, leaves the test green. BATS ok 4 catches the deletion on the vz job but not the move, since limactl start prints the same message either way. The test is optional. A misplaced refusal makes limactl delete fail with an error that names the field.
return scripts, nil
}
func (l *LimaVzDriver) Validate(_ context.Context) error {
// Configure, which deletion also uses, runs validateConfig, so this start-time check is here.
if cfg := l.Instance.Config; cfg != nil && !limayaml.HostLoopbackEnabled(cfg) && limayaml.FirstUsernetIndex(cfg) != -1 {
return errors.New("`networkOpts.hostLoopback: false` is not supported with a `user-v2` network, which is shared by instances")
}
if err := validateConfig(l.Instance.Config); err != nil {
return err
}
if len(l.Instance.Config.BlockDevices) == 0 {
return nil
Fix: load the config and run Configure, as deletion does, before Validate. I ran this version. It passes on the tree, fails with "expected an error, got nil" when the refusal is deleted, and fails with the refusal's message when the refusal moves into validateConfig.
t.Setenv("LIMA_HOME", t.TempDir())
cfg, err := limayaml.Load(t.Context(), []byte("vmType: vz\nnetworkOpts: {hostLoopback: false}\nnetworks: [{lima: user-v2}]\n"), "lima.yaml")
assert.NilError(t, err)
l := &LimaVzDriver{}
_, err = l.Configure(t.Context(), &limatype.Instance{Dir: t.TempDir(), Config: cfg})
assert.NilError(t, err)
assert.ErrorContains(t, l.Validate(t.Context()), "not supported with a `user-v2` network")
setupEnv with hostLoopback false Claude Opus 5.5 Codex GPT 6 Astra Gemini 3.1 Pro Gemini 3.5 Flash¶
for _, ip := range netLookupIP(u.Hostname()) {
if !ip.IsLoopback() {
continue
}
if !hostLoopback {
logrus.Warnf("%#q value %#q points at the host's loopback, which the guest cannot reach with `networkOpts.hostLoopback: false`", name, value)
}
newHost := slirpGateway
if u.Port() != "" {
newHost = net.JoinHostPort(newHost, u.Port())
}
u.Host = newHost
Round 2's S3 is still open. Every setupEnv call in cidata_test.go and fuzz_test.go passes true, so deleting this warning, or the break at line 104, leaves go test ./pkg/cidata/ green. The test is optional, since the warning is diagnostic only.
newHost = net.JoinHostPort(newHost, u.Port())
}
u.Host = newHost
value = u.String()
// Every loopback address gives the same rewrite.
break
}
if value != env[name] {
logrus.Infof("Replacing %#q value %#q with %#q", name, env[name], value)
env[name] = value
}
TestSetupEnv replaces netLookupIP with a one-address stub and does not restore it (pkg/cidata/cidata_test.go:26). A new test must install its own two-address stub; otherwise a full package run cannot catch a missing break.
func fakeLookupIP(_ string) []net.IP {
return []net.IP{net.IPv4(127, 0, 0, 0)}
}
func TestSetupEnv(t *testing.T) {
netLookupIP = fakeLookupIP
urlMustParse := func(urlStr string) *url.URL {
u, err := url.Parse(urlStr)
assert.NilError(t, err)
return u
}
Fix: add a test with this body. In a full go test ./pkg/cidata/ run it passes on the tree, counts 0 warnings when the warning is deleted, and counts 2 when the break is deleted.
netLookupIP = func(string) []net.IP { return []net.IP{net.IPv4(127, 0, 0, 1), net.IPv6loopback} }
hook := logrustest.NewGlobal()
_, err := setupEnv(map[string]string{"http_proxy": "http://localhost:3128"}, false, false, networks.SlirpGateway)
assert.NilError(t, err)
warnings := slices.DeleteFunc(hook.AllEntries(), func(e *logrus.Entry) bool { return e.Level != logrus.WarnLevel })
assert.Equal(t, len(warnings), 1)
# - Only supported with `vmType: vz`. Not supported with a `user-v2` network, which is shared by instances.
# - Does not restrict the host's other addresses: a host service bound to all interfaces is still
# reachable through the host's LAN IP.
# - A proxy on the host's loopback (e.g. `http_proxy=http://127.0.0.1:3128`), whether it comes from
# the host's network settings, `env`, or `propagateProxyEnv`, becomes unreachable from the guest.
# 🟢 Builtin default: true (since Lima v2.3)
hostLoopback: null
# EXPERIMENTAL
# When enabled, an emulated TPM 2.0 device is provided to the guest via swtpm.
# Requires swtpm to be installed on the host. Only supported with vmType: qemu.
In this template, a version note after a builtin default dates a change of default. 9e7fc04b turned loadDotSSHPubKeys's Builtin default: true into false (since Lima v1.0) (line 162), and securityModel has "none" (since Lima v0.13) (line 87). Read the same way, line 705 says the default became true in v2.3, as if earlier releases blocked host loopback. They did not; the field itself is new. The docs' "(available since Lima v2.3)" at website/content/en/docs/config/network/user.md:24 gets this right.
## Host IP (192.168.5.2)
The loopback addresses of the host is `192.168.5.2` and is accessible from the guest as `host.lima.internal`.
This includes services that listen only on the host's `127.0.0.1`. To block this, for example for a guest that runs untrusted code, set `networkOpts.hostLoopback: false` (available since Lima v2.3) in `lima.yaml`:
```yaml
networkOpts:
hostLoopback: false
```
# # 🟢 Builtin default: "openssh-sftp-server" if OpenSSH SFTP Server binary is found, otherwise "builtin"
# sftpDriver: null
# 9p:
# # Supported security models are "passthrough", "mapped-xattr", "mapped-file" and "none".
# # "mapped-xattr" and "mapped-file" are useful for persistent chown but incompatible with symlinks.
# # 🟢 Builtin default: "none" (since Lima v0.13)
# securityModel: null
# # Select 9P protocol version. Valid options are: "9p2000" (legacy), "9p2000.u", "9p2000.L".
# # 🟢 Builtin default: "9p2000.L"
# protocolVersion: null
# # The number of bytes to use for 9p packet payload, where 4KiB is the absolute minimum.
localPort: null
# Load ~/.ssh/*.pub in addition to $LIMA_HOME/_config/user.pub .
# This option is useful when you want to use other SSH-based
# applications such as rsync with the Lima instance.
# If you have an insecure key under ~/.ssh, do not use this option.
# 🟢 Builtin default: false (since Lima v1.0)
loadDotSSHPubKeys: null
# Forward ssh agent into the instance.
# The ssh agent socket can be mounted in a container at the path `/run/host-services/ssh-auth.sock`.
# Set the environment variable `SSH_AUTH_SOCK` value to the path above.
# The socket is accessible by the non-root user inside the Lima instance.
Fix: move the version to its own line.
- # 🟢 Builtin default: true (since Lima v2.3)
+ # Available since Lima v2.3.
+ # 🟢 Builtin default: true
limactl ignores the option Codex GPT 6 Astra Gemini 3.5 Flash Claude Opus 5.5¶
## Host IP (192.168.5.2)
The loopback addresses of the host is `192.168.5.2` and is accessible from the guest as `host.lima.internal`.
This includes services that listen only on the host's `127.0.0.1`. To block this, for example for a guest that runs untrusted code, set `networkOpts.hostLoopback: false` (available since Lima v2.3) in `lima.yaml`:
```yaml
networkOpts:
hostLoopback: false
```
A limactl without this change reads networkOpts as an unknown field. It logs "Non-strict YAML detected" (pkg/limayaml/marshal.go:81) and starts the guest with host loopback reachable, so the option fails open for the untrusted guests it targets. Round 2 recorded this as a design concern.
}
// Finally log a warning if the YAML file violates the "strict" rules
opts = append(opts, yaml.Strict())
var ignore limatype.LimaYAML
if err := yaml.UnmarshalWithOptions(data, &ignore, opts...); err != nil {
logrus.WithField("comment", comment).WithError(err).Warn("Non-strict YAML detected; please check for typos")
}
return nil
}
// Convert converts from x to y, using YAML.
minimumLimaVersion makes an older limactl refuse the template (pkg/limayaml/validate.go:41-49). It has one gap. versionutil.Parse strips a prerelease suffix, and compare then ranks the prerelease above the release (pkg/version/versionutil/versionutil.go:16-42), so minimumLimaVersion: 2.3.0 also accepts the already tagged v2.3.0 betas, which lack the field.
if len(y.Base) > 0 {
errs = errors.Join(errs, errors.New("field `base` must be empty for YAML validation"))
}
if y.MinimumLimaVersion != nil {
if _, err := versionutil.Parse(*y.MinimumLimaVersion); err != nil {
errs = errors.Join(errs, fmt.Errorf("field `minimumLimaVersion` must be a semvar value, got %#q: %w", *y.MinimumLimaVersion, err))
}
// Unparsable version.Version (like commit hashes or "<unknown>") is treated as "latest/greatest"
// and will pass all version comparisons, allowing development builds to work.
if !versionutil.GreaterEqual(version.Version, *y.MinimumLimaVersion) {
errs = errors.Join(errs, fmt.Errorf("template requires Lima version %#q; this is only %#q", *y.MinimumLimaVersion, version.Version))
}
}
switch *y.OS {
case limatype.LINUX, limatype.DARWIN, limatype.FREEBSD:
case limatype.WINDOWS:
// Parse parses a Lima version string by removing the leading "v" character and
// stripping everything from the first "-" forward (which are `git describe` artifacts and
// not semver pre-release markers) or cutting ".m" suffix from exact version.
// So "v0.19.1-16-gf3dc6ed.m" will be parsed as "0.19.1".
func Parse(version string) (*semver.Version, error) {
version = strings.TrimPrefix(version, "v")
version, _, _ = strings.Cut(version, "-")
version = strings.TrimSuffix(version, ".m")
return semver.NewVersion(version)
}
func compare(limaVersion, oldVersion string) int {
if limaVersion == "" {
if oldVersion == "" {
return 0
}
return -1
}
version, err := Parse(limaVersion)
if err != nil {
return 1
}
// Handle Unparsable oldVersion gracefully - treat as 0.0.0 so Unparsable limaVersion is always greater
oldVer, err := semver.NewVersion(oldVersion)
if err != nil {
return 1
}
cmp := version.Compare(*oldVer)
if cmp == 0 && strings.Contains(limaVersion, "-") {
cmp = 1
}
return cmp
}
// GreaterThan returns true if the Lima version used to create an instance is greater
// than a specific older version. Always returns false if the Lima version is the empty string.
Fix: add a sentence to user.md and the template comment telling users that templates relying on the option should set minimumLimaVersion: 2.3.0.
Design Observations ¶
Concerns ¶
- (future) An explicit
hostLoopback: nullin a child template overrides a base template'sfalse. The merge drops every non-map node of the base that the child also sets, null included (pkg/limatmpl/embed.go:235-237). A child copied fromtemplates/default.yaml, which now containshostLoopback: null, therefore turns off a base's isolation without a warning.limactl template copy --embedgiveshostLoopback: nullfor such a child andfalsewithout the null line. Every field merges this way, so the rule belongs to the template system; a docs note would help users of an isolation option. Claude Opus 5.5
Strengths ¶
- (in-scope) Each driver refuses the setting in its
Validate, solimactl deletekeeps working on a misconfigured instance, and the qemu, WSL2 and HCS tests assert thatvalidateConfigaccepts the setting. Claude Opus 5.5 Codex GPT 6 Astra - (in-scope)
netstackConfigurationmakes the gateway's NAT table testable without a VM, and passingfalseat its call site now failsTestNetstackConfigurationNAT. Claude Opus 5.5 Codex GPT 6 Astra Gemini 3.5 Flash - (in-scope) The BATS refusal test tells an immediate refusal (exit 1 with "Connection refused") from a hang (exit 124), and
ok 3shows the same listener answering once the option istrue. Gemini 3.1 Pro Codex GPT 6 Astra Claude Opus 5.5 - (in-scope) gvisor-tap-vsock v0.9.0 keeps the isolation intact. gvisor 2026-04 still drops guest packets with a
127/8source or destination unlessAllowExternalLoopbackTrafficis set (tcpip/network/ipv4/ipv4.go:876-888), and v0.9.0 still builds IPv4 with plainipv4.NewProtocol. The stack still registers only IPv4 and ARP, and the new ICMP forwarder applies the same NAT table. A TCP dial to0.0.0.1still fails at once, well inside the new 30-secondDialTimeout. Claude Opus 5.5 Codex GPT 6 Astra Gemini 3.1 Pro Gemini 3.5 Flash
Testing Assessment ¶
I ran go test -count=1 ./... at the review SHA on macOS arm64: exit 0, 51 packages ok, none failed. I ran it again on the PR merged into current master, which ships gvisor-tap-vsock v0.9.0. go build ./... and go vet on the touched packages passed, and go test reported 51 packages ok, none failed. No CI run has tested that combination; the PR's runs merged it into f6158feb, which has v0.8.9. On c388098f, 36 checks pass and two Netlify checks are skipped. The vz job ran the new BATS file on an Intel runner and passed all four tests.
I applied each mutation alone in the lead worktree:
| Mutation | Existing tests | Proposed test |
|---|---|---|
natTable(gatewayIP, false) at the call site | TestNetstackConfigurationNAT fails | |
| krunkit refusal deleted | TestValidateRejectsHostLoopbackFalse fails | |
vz passes HostLoopbackEnabled without the ! | TestGVisorNetstackOptsHostLoopback fails | |
vz user-v2 refusal deleted | fails by panic | S1 fails |
vz user-v2 refusal moved into validateConfig | green | S1 fails |
setupEnv warning deleted | green | S2 fails |
setupEnv break deleted | green | S2 fails |
- Required: none missing. Every round 2 I1 link now has a test that fails when it is reverted.
- Optional: the vz
user-v2placement (S1). A misplaced refusal fails loudly onlimactl delete. - Optional: the
setupEnvwarning (S2). The warning is diagnostic only.
The krunkit test runs only on Apple silicon machines. CI runs go test on macOS only on Intel runners (.github/workflows/test.yml:289, :513), and the arm64 macos-26 job only lints.
Documentation Assessment ¶
user.mdand the template comment match the code: vz only,user-v2refused, the LAN-address caveat, and a proxy caveat that now names all three proxy sources, as round 2's S1 asked.- The template's "(since Lima v2.3)" says the default changed (S3).
- Neither page tells users to pair the option with
minimumLimaVersion(S4).
Acknowledged Limitations ¶
- External drivers from the registry ignore the option, and a driver feature flag is deferred. The in-tree external vz build receives the field, because the gRPC client sends the instance as JSON.
- krunkit,
user-v2and QEMU'sdisable_host_loopbackare deferred, and each rejectsfalse. - A host service bound to all interfaces stays reachable through the host's LAN IP. The change does not make that worse.
- With the refusals in
Validate,limactl createon an unsupported driver writes the instance and then fails, becausecreateActionrunsinstance.Prepare, which calls the driver'sValidate(cmd/limactl/start.go:578,pkg/instance/start.go:83).limactl startrefuses it too, andlimactl editcan clear the setting. Round 2 said onlystartrefuses. - Do not re-suggest moving the refusals into
limayaml.Validate. It runs on every load (pkg/store/store.go:127), so every instance that sets the option on an unsupported driver would load with an error.limactl listwould show it with errors (pkg/store/instance.go:81-87), and it could not start. Earlier rounds called such an instance unlistable, which overstates it. - Do not re-suggest remapping the gateway to
127.0.0.2or240.0.0.1. On macOS both time out instead of failing at once (round 1 measured 75 s and over 5 s). - Do not re-suggest mapping
127.0.0.1innatTable. gvisor drops guest packets addressed to127/8, and this still holds with gvisor-tap-vsock v0.9.0 and gvisor 2026-04. - Do not re-raise the qemu
Validatepanic on a nil config.CreateConfiguredDriverdereferencesinst.Config(pkg/driverutil/instance.go:22) before any driver method runs. - Do not re-suggest spelling the five refusals one way, through
HostLoopbackEnabledor a single error format. It is style.hcs_driver_windows.go,wsl_driver_windows.goandkrunkit_driver_darwin_arm64.gowould each need a new import for no change in behavior, and every message already names the field and the driver or network it conflicts with.
Agent Performance Retro ¶
Claude Opus 5.5 ¶
Claude alone found S3, by checking what the template's existing version notes mean, and alone found the template-merge concern, which it confirmed with limactl template copy --embed. It also noticed that CI never runs the krunkit test. Its S1 probe held up when rerun, but its S2 probe caught a deleted break only when run alone, because TestSetupEnv leaves a one-address stub installed. It re-raised the refusal-spelling suggestion that round 2 dropped, saying the krunkit and HCS packages already import limayaml; the three files with the inline check do not. It said that a subagent, not Claude itself, read the gvisor sources.
Codex GPT 6 Astra ¶
Codex ran every mutation it reported, and its probes covered serialization, the schema, yq edits and template inheritance for the renamed field. It alone found that minimumLimaVersion: 2.3.0 accepts the 2.3 betas. It also corrected two acknowledged limitations. limactl create itself fails after writing the instance, and a load-time refusal leaves the instance listable with errors. But it judged the template's "(since Lima v2.3)" consistent with the repo's convention, which lines 87 and 162 contradict, and it marked the template reviewed with no issues.
Gemini 3.1 Pro ¶
Gemini Pro found the two carried-over test gaps and nothing else. It edited tracked files in place with sed -i.bak and patch, which the prompt forbids, restored each with git checkout after its test run, and left .bak and .orig copies in its worktree. It also ran limactl create twice against a scratch LIMA_HOME; both runs failed before writing an instance. Its review cites none of those runs. It marked templates/default.yaml and user.md reviewed with no issues.
Gemini 3.5 Flash ¶
Flash rated the vz user-v2 test gap Important, arguing that a misplaced refusal would break limactl delete silently. The failure names the field, so it stays a Suggestion; its proposed fix follows the qemu tests' pattern, and I did not run it. It re-raised the dropped refusal-spelling item and cited line 105 for a break that is on line 104. Its limitations section says 127.0.0.2 reaches host loopback, which contradicts round 1's measured timeout. The two Gemini models agree on both test gaps, which counts as one opinion.
Summary ¶
| Claude Opus 5.5 | Codex GPT 6 Astra | Gemini 3.1 Pro | Gemini 3.5 Flash | |
|---|---|---|---|---|
| Duration | 10m 28s | 9m 37s | 10m 56s | 10m 26s |
| Findings | 4S | 3S | 2S | 3S |
| Tool calls | 50 (Bash 43, Read 6, Agent 1) | 24 (shell 24) | 61 (runshellcommand 61) | 86 (grepsearch 29, readfile 23, runshellcommand 18) |
| Design observations | 4 | 3 | 2 | 3 |
| False positives | 0 | 0 | 0 | 0 |
| Unique insights | 3 | 2 | 0 | 0 |
| Files reviewed | 23 | 23 | 23 | 23 |
| Coverage misses | 0 | 1 | 2 | 0 |
| Totals | 4S | 3S | 2S | 3S |
| Downgraded | 0 | 0 | 0 | 1 |
| Dropped | 1 | 0 | 0 | 1 |
Claude supplied the most value and Codex the most careful evidence. The Gemini models found nothing the others missed.
Reconciliation. Gemini 3.5 Flash P1 I1 (vz user-v2 test): important → suggestion S1. Claude Opus 5.5 P1 S4 and Gemini 3.5 Flash P1 S3 (one spelling of the refusals): dropped, as in round 2.
Review Process Notes ¶
Skill improvements ¶
- When a probe depends on a package-level variable that tests stub (a resolver, a clock, a hook), run it in a full package run as well as alone. A sibling test that swaps the variable and never restores it can make the probe pass, or fail, for a reason unrelated to the code under test.
- When a change reuses a notation that the file already uses (a version note, a marker, a status tag), check what the notation means at its other uses. A note copied into a new context can state something false while looking consistent.
Repo context updates ¶
- [repo] UPDATE "gvisor-tap-vsock dials guest destinations from the host": as of gvisor-tap-vsock v0.9.0, the TCP forwarder dials with
net.DialTimeout(30 s by default,TCPConnectTimeout) and admits 128 connection attempts in flight by default (TCPMaxInFlight), and a new ICMP forwarder applies the same NAT table to guest pings. gvisor still drops guest packets with a127/8source or destination, and the stack still registers only IPv4 and ARP. - [repo] ADD: In
templates/default.yaml, a version note after a builtin default, as in "Builtin default: false (since Lima v1.0)", dates a change of default. The version that introduced a field goes on its own comment line, so a reader does not take a new option for a changed default. - [repo] ADD:
TestSetupEnvinpkg/cidatareplacesnetLookupIPwith a stub that returns one loopback address and does not restore it. A later test in the package that depends on name resolution must install its own stub, or its result depends on test order.