feat(smolmachines): per-bottle loopback alias scopes TSI to single /32 #76
Reference in New Issue
Block a user
Delete Branch "smolmachines-loopback-alias-scoping"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Per-bottle loopback alias scoping for smolmachines bottles. Each bottle reserves a unique
127.0.0.16..127.0.0.31alias onlo0, binds the bundle's port-forwards to it, and the agent's TSI allowlist is the alias's/32. Result: the agent can only reach its own bundle — not other bottles' ports, not host loopback services (postgres, dev servers), not the internet.End-to-end verified on macOS / Docker Desktop:
Smolvm 0.8.0 quirk + workaround
The CLI's
--allow-cidrflag is silently dropped when combined with--from <smolmachine>. Verified empirically: the persistedagent.config.jsonshowsallowed_cidrs: nulldespite the flag, and the booted VM reaches all of127.0.0.0/8.Workaround: smolvm stores each machine's config as a JSON BLOB in
~/Library/Application Support/smolvm/server/smolvm.db(vms.data), and reads it atmachine start. The launcher patches that row betweenmachine createandmachine startto setallowed_cidrsdirectly. TSI enforces from the patched value.This hack falls away once smolvm honors the flag upstream —
force_allowlistbecomes a no-op call to remove.Other paths tried (all dead-ends):
machine update --allow-cidrdoesn't existagent.config.json-restart fails (file is removed on stop)--smolfilemutually exclusive with--from--image localhost:<port>/...— smolvm's pull agent can't reach host loopback during pullSudo policy (one-time per reboot)
The launcher lazily sudo-prompts to add missing
lo0aliases on first launch per reboot. Aliases persist until reboot; subsequent launches don't prompt. Linux native daemons share the host's network namespace and skip the alias dance entirely.Code
loopback_aliasmodule:ensure_pool(),allocate(slug),force_allowlist(machine_name, cidrs). Detects macOS / Linux at runtime.BundleLaunchSpec.publish_host_ipcarries the alias;start_bundlebinds-p <alias>::<port>.bundle_host_porthonors the host IP sodocker portoutput disambiguation works against the per-bottle alias.launch.pycallsensure_pool+allocateearly, thenforce_allowlistbetweenmachine_createandmachine_start.force_allowlist, alias allocation, and the in-use detection).feat(smolmachines): per-bottle loopback alias scopes TSI to single /32to infra(smolmachines): per-bottle loopback alias scoping (TSI enforcement upstream-blocked)infra(smolmachines): per-bottle loopback alias scoping (TSI enforcement upstream-blocked)to feat(smolmachines): per-bottle loopback alias scopes TSI to single /32