host: carlos-app@ is operator-trusted; add the syscall and IPC floor
State in the unit header, the Backing and SetBacking comments and the README that unit backing is for operator-trusted tenants only (Paul, 2026-11-16): a unit tenant reaches loopback, the VPC and abstract unix sockets. Add the hardening that cannot break such a tenant, copied from carlos-instance@: the #527 syscall filter, PrivateIPC with a read-only /dev/mqueue, and ProtectControlGroups. No PrivatePIDs (#528) and no loopback or private-range IPAddressDeny; the IMDS pair stays exact. TestAppUnitHardeningFloor pins both halves.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 files changed,
+67
−0
README.md+4 −0internal/host/units/carlos-app@.service+27 −0internal/host/units_isolation_test.go+29 −0internal/registry/registry.go+7 −0
diff --git a/README.md b/README.md| index 6c448fc4d..df7f03104 100644 |
| --- a/README.md |
| +++ b/README.md |
| @@ -1381,6 +1381,10 @@ design's §5 migration steps). Stamping it arms the **hourly** |
| `carlos-adopt.timer`, and `carlos adopt` for a `daemon` route enables and |
| STARTS the service — so the data copy comes before the stamp, not after it. |
| +**Unit backing is for operator-trusted tenants only.** A `carlos-app@<host>` |
| +tenant can reach loopback, the VPC and abstract unix sockets, so never set |
| +`--backing unit` for a tenant you would not give a shell on the box. |
| + |
| A declared-but-ungranted capability does not fail the app or fail adoption: |
| the drop-in simply is not written, and the hourly adopt pass logs one line |
| naming the route, the capability, and the exact grant command. The mirror |
diff --git a/internal/host/units/carlos-app@.service b/internal/host/units/carlos-app@.service| index 3b79b44bf..b4ced2b1b 100644 |
| --- a/internal/host/units/carlos-app@.service |
| +++ b/internal/host/units/carlos-app@.service |
| @@ -2,6 +2,17 @@ |
| # is also the live/<host> symlink the adopt pass repoints and the unit |
| # the agent's restartRoute try-restarts). |
| # |
| +# Trust: unit backing is for operator-trusted tenants only (Paul, |
| +# 2026-11-16). It is set only by box root through |
| +# `carlos route --backing unit` / `carlos add --backing unit`, never by |
| +# the console. It does not carry the instance sandbox's network fence or |
| +# abstract-socket scoping: a unit tenant can reach loopback, the VPC and |
| +# abstract unix sockets. Never set it for a tenant you would not give a |
| +# shell on the box. The hardening below is only what cannot break such a |
| +# tenant: no PrivatePIDs= (#528), and no loopback or private-range |
| +# IPAddressDeny (the edge dials Addr tenants on loopback, and the box's |
| +# resolver may sit in the VPC). |
| +# |
| # DynamicUser: systemd mints an ephemeral uid per service at start — apps |
| # share no identity with each other or the platform, and nobody manages |
| # user accounts. State lives in /var/lib/carlos-app/<host> (chowned to |
| @@ -61,6 +72,14 @@ ProtectKernelLogs=yes |
| ProtectClock=yes |
| ProtectHostname=yes |
| RemoveIPC=yes |
| +# Each unit gets its own SysV and POSIX IPC namespace (#178). PrivateDevices= |
| +# carries the host's /dev/mqueue into the private /dev, and that mount would |
| +# still reach the host namespace's queues, so it is replaced. |
| +PrivateIPC=yes |
| +TemporaryFileSystem=/dev/mqueue:ro |
| +# /sys/fs/cgroup read-only: no write to another unit's cgroup.kill or |
| +# cgroup.freeze. |
| +ProtectControlGroups=yes |
| LockPersonality=yes |
| RestrictRealtime=yes |
| RestrictNamespaces=yes |
| @@ -68,6 +87,14 @@ CapabilityBoundingSet= |
| RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX |
| IPAddressDeny=169.254.169.254/32 fd00:ec2::254/128 |
| MemoryDenyWriteExecute=yes |
| +SystemCallArchitectures=native |
| +# The tenant syscall surface (#527 Q5), as on carlos-instance@: systemd's |
| +# baseline for an ordinary service, less io_uring, the kernel keyring and |
| +# userfaultfd. A refused call answers ENOSYS, so runtimes take the fallback |
| +# they already have rather than being killed. |
| +SystemCallFilter=@system-service |
| +SystemCallFilter=~@keyring io_uring_setup io_uring_enter io_uring_register userfaultfd |
| +SystemCallErrorNumber=ENOSYS |
| MemoryMax=512M |
| # Throttle-and-reclaim before the kill — the same band the exec path's |
| # memory.high gives (internal/cgroup applyLimit, 90% of max). |
diff --git a/internal/host/units_isolation_test.go b/internal/host/units_isolation_test.go| index 9deda0edd..c1b745a1f 100644 |
| --- a/internal/host/units_isolation_test.go |
| +++ b/internal/host/units_isolation_test.go |
| @@ -824,3 +824,32 @@ func TestMailerUnitShape(t *testing.T) { |
| } |
| } |
| } |
| + |
| +// carlos-app@ is for operator-trusted tenants only (Paul, 2026-11-16): it |
| +// keeps loopback, the VPC and abstract sockets open, so it gets only the |
| +// hardening that cannot break such a tenant. The syscall floor and private |
| +// IPC come from the instance template; PrivatePIDs= (#528's stop race) and |
| +// a loopback or RFC 1918 fence (the edge dials Addr tenants on loopback, |
| +// and the box's DNS may sit in the VPC) do not. The IMDS pair stays exact: |
| +// widening it to 169.254.0.0/16 would cut the VPC resolver at .253. |
| +func TestAppUnitHardeningFloor(t *testing.T) { |
| + u := readUnit(t, "carlos-app@.service") |
| + for _, want := range append(slices.Clone(syscallBlock), |
| + "ProtectControlGroups=yes", "PrivateIPC=yes", "TemporaryFileSystem=/dev/mqueue:ro", |
| + "IPAddressDeny=169.254.169.254/32 fd00:ec2::254/128") { |
| + if !hasDirective(u, want) { |
| + t.Errorf("carlos-app@.service lacks %q", want) |
| + } |
| + } |
| + for _, d := range directives(u) { |
| + if strings.HasPrefix(d, "PrivatePIDs=") { |
| + t.Errorf("carlos-app@.service carries %q (#528)", d) |
| + } |
| + if strings.HasPrefix(d, "IPAddressDeny=") && d != "IPAddressDeny=169.254.169.254/32 fd00:ec2::254/128" { |
| + t.Errorf("carlos-app@.service carries %q; only the IMDS pair is fenced here", d) |
| + } |
| + } |
| + if !strings.Contains(u, "operator-trusted tenants only") { |
| + t.Error("carlos-app@.service does not state that unit backing is for operator-trusted tenants only") |
| + } |
| +} |
diff --git a/internal/registry/registry.go b/internal/registry/registry.go| index 05b31ad4c..cf2f74a73 100644 |
| --- a/internal/registry/registry.go |
| +++ b/internal/registry/registry.go |
| @@ -307,6 +307,8 @@ type Route struct { |
| // agent (the activator spawns live/<host> itself — the Eleven shape), or |
| // BackingUnit = a carlos-app@<host> systemd unit (whole-app tenants: |
| // DynamicUser, StateDirectory) that the activator drives via systemctl. |
| + // Unit backing is for operator-trusted tenants only: the unit has no |
| + // network fence or abstract-socket scoping (carlos-app@.service). |
| Backing string |
| // Unit is the systemd unit that owns this route's process when it is |
| @@ -2343,6 +2345,11 @@ func (r *Registry) SetInstancePaths(host, fromDB, fromSock, toDB, toSock string) |
| // merges into (SetCaps's case) and not a value an hourly pass rewrites |
| // (SetDBPath's): it is one operator, at one step of a documented migration, |
| // naming the value they want. |
| +// |
| +// BackingUnit is for operator-trusted tenants only: a carlos-app@ tenant |
| +// can reach loopback, the VPC and abstract unix sockets |
| +// (carlos-app@.service's header), so never stamp it for a tenant you would |
| +// not give a shell on the box. |
| func (r *Registry) SetBacking(host, backing string) error { |
| if r.remote != nil { |
| _, err := r.remote.call(nil, remoteRequest{Method: "SetBacking", Host: host, Backing: backing}, nil) |