Interfaces: containers, VMs and support

interface family for app developers for snapd developers for administrators for users

Socket interfaces (docker, lxd, podman, libvirt) grant a client one unix socket; the *-support interfaces let the daemon behind it run containers, with a super-privileged plug that only a store rule can grant.

On the map: interfaces district, family row

▶ Watch this deck — 8 scenes, ~6 min

01 Two shapes, socket and support

TWO SHAPES acme-agentlxd lxd, the daemon snapunix socketsocket interfaceslxd, docker, podman, libvirtthe socket; the daemon is root lxd, the daemon snaplxd-supportthe system:lxd-support support interfaceslxd-support, docker-support, …super-privileged: store rule to install a few, such as lxd-support: the daemon runs its own device cgroup; snapd writes no udev tagging rules for it
Two shapes: acme-agent plugging the LXD daemon's unix socket, and the lxd daemon snap plugging the super-privileged lxd-support interface on the system

Socket interfaces grant the daemon's socket, plus little else; the daemon behind it holds the privilege. Support interfaces are for the daemon: a system slot and, for nearly all of them, a super-privileged plug that needs a store rule to install. A few, such as lxd-support and docker-support, let the daemon manage its own device cgroup.

Say acme-agent on the gateway should run each job in a container of its own. It asks a daemon, LXD, to build them. That's the first shape in this family. Socket interfaces such as lxd, docker, podman and libvirt grant a client the daemon's unix socket, plus little else. The privilege stays with the daemon. The second shape is for the daemon itself: the support interfaces, like lxd-support. Their slot is the system's, and for nearly all of them the plug is super-privileged: only a snap whose declaration grants it can install. A few, lxd-support among them, also let the daemon manage its own device-cgroup.

02 Two halves of one product

TWO HALVES $ snap install lxdlxd-support is connected by the store rule the system:lxd-supportlxd, the daemon snaplxd-supportthis connection is root; connected at install lxdacme-agentlxda client snap $ snap connect acme-agent:lxd lxd:lxd $ snap connections lxdlxd acme-agent:lxd lxd:lxd manuallxd-support lxd:lxd-support :lxd-support -
The lxd snap on the gateway with lxd-support connected to the system and an lxd slot that acme-agent connects to with one command; snap connections lxd lists both

A store-installed daemon snap holds its super-privileged *-support plug, connected by its store rule; that is root. The socket interface is the second half: a client gets access only after snap connect acme-agent:lxd lxd:lxd. snap connections lxd shows both.

So you install lxd on the gateway. It arrives with lxd-support already connected, because the lxd snap's declaration in the store grants that super-privileged plug and auto-connects it. That connection is what lets the daemon run containers at all, and it amounts to root on the device. The second half is the lxd slot, the socket, offered to other snaps. acme-agent plugs lxd and gets nothing until it's connected: snap connect, naming acme-agent's lxd plug and the lxd snap's slot. snapd's own tests connect a client to lxd that way. snap connections lxd then shows both halves.

03 The policy ladder for app developers for Ubuntu Core developers for snapd developers for administrators

THE POLICY LADDER libvirtdeny-auto-connection: trueno plug rule: an administrator connects a client by hand on classic; no slot exists on Ubuntu Core dockerdeny-connection: on-classic: falsemanual connect works on classic; on Ubuntu Core the connection needs a store rule podmandeny-connection: truedenied everywhere by the base declaration: the client snap needs a snap-declaration, even on classic lxdallow-installation: false (on the slot)the lxd snap needs a snap-declaration to install, and every connection needs a store rule each rung moves one more decision from the administrator to the store
Four socket interfaces as four rungs of base-declaration policy: libvirt, docker, podman, lxd, each stricter than the last

libvirt: manual connect allowed, on classic only. docker: deny-connection: on-classic: false. podman: deny-connection: true everywhere. lxd: allow-installation: false on the slot, and deny-connection: true, so a snap-declaration rule decides who may connect.

Why could acme-agent connect to lxd at all? Four socket interfaces, four rungs. libvirt's slot exists only on classic and only denies auto-connection, so an administrator connects a client by hand. docker adds deny-connection, on-classic: false: by hand on classic, but on Ubuntu Core only with a store rule. podman says deny-connection true: even on classic, the client needs a store rule. lxd goes one rung further: the slot has allow-installation: false, so the lxd snap itself needs a declaration to install. Every lxd connection is denied in the base too, so a snap-declaration rule is what lets yours through.

04 What privileged-containers adds for app developers for snapd developers for administrators

PRIVILEGED-CONTAINERS snap.yamlplugs:privileged:interface: docker-supportprivileged-containers: true already in the default rule set:capability, mount, umount, pivot_root,change_profile unsafe … -> {,&}docker-default,ptrace (trace) peer=@{profile_name},plus Delegate=true and its own device cgroup privileged-containers: true adds/dev/** mrwkl, @{PROC}/** mrwkl, /** rwlix,change_profile unsafe /**, signal (send) peer=unconfined,seccomp: @unrestricted AARE has no negation, so InsertAAREExclusionPatterns expands each /** rule to leave out/snap/{snapd,core}/*/usr/lib/snapd/snap-confine
A docker-support plug with privileged-containers: true, the rules it adds on top of the default set, and the exclusion patterns around snap-confine

The boolean privileged-containers adds /dev/** mrwkl,, change_profile unsafe to any profile and @unrestricted seccomp. Without it the daemon moves to or stacks docker-default. The rules are expanded with InsertAAREExclusionPatterns to leave out snap-confine.

If the gateway ran Docker instead of LXD, the daemon would plug docker-support. Even the plain plug is broad. The daemon can mount, pivot_root, use every capability, and move each container onto the docker-default profile, or stack that profile on its own. docker-support has one attribute, privileged-containers, a boolean, and setting it true adds three more things: raw access to every device file under dev, a change profile to any profile at all, which is how an unconfined container starts, and an unrestricted seccomp filter. AppArmor patterns can't say "everything except", so snapd expands those rules into patterns that leave out snap-confine.

05 lxd-support and the unconfined flag for app developers for Ubuntu Core developers for snapd developers for administrators

THE UNCONFINED FLAG snap.yamlplugs:lxd-support:enable-unconfined-mode: true# the only appArmorUnconfinedPlugs interface ordinary rules, already wide:/{,usr/}{,s}bin/aa-exec ux,@unrestricted (seccomp)userns, when the parser has itplus Delegate=true and its own device cgroup the AppArmor backend emits the whole profile with the flagprofile "snap.lxd.daemon" flags=(attach_disconnected,mediate_deleted,unconfined) {only if parser features include unconfined and kernel features include policy:unconfined_restrictions
The lxd-support plug with enable-unconfined-mode: true, its ordinary rules, and the unconfined profile flag the backend adds

Only lxd-support sets appArmorUnconfinedPlugs; with enable-unconfined-mode: true the backend adds the unconfined profile flag when the parser has unconfined and the kernel has policy:unconfined_restrictions.

Back to LXD. Its support plug is already wide: aa-exec with an unconfined transition, so LXD can move to any profile, and an unrestricted seccomp filter. It can go further. lxd-support is the one interface that sets the static flag for unconfined plugs, and its plug attribute enable-unconfined-mode, set true, makes the AppArmor backend write the whole profile with the unconfined flag. That needs the parser to report unconfined and the kernel to report policy:unconfined_restrictions. A strict snap is then deliberately not confined.

06 userns, one line, sometimes omitted for app developers for snapd developers

USERNS the whole interfaceAppArmor:userns,seccomp:clone unshare why it existsnewer AppArmor can mediate the creationof user namespaces; browsers and containertools create themcommit 4c01e47f82, 2023 ParserFeatures()userns in the list? yes: add userns,no: no AppArmor rule the same probe, with the same line added by the interface itself:lxd-support docker-support greengrass-support steam-support browser-support plug: allow-installation: false, super-privileged all the same
The userns interface: one AppArmor rule and two seccomp lines; the parser features are probed and the AppArmor rule is omitted when userns is not among them

One AppArmor rule, userns,, plus clone and unshare in seccomp; added only when the parser reports the userns feature. lxd-support, docker-support, greengrass-support, steam-support and browser-support (with allow-sandbox: true) add the line themselves.

Containers need user namespaces, and so do browser sandboxes. Newer AppArmor can mediate creating them, which is why userns exists. It's the smallest interface here: one AppArmor line, userns, plus clone and unshare in seccomp. Before adding the line, snapd checks the parser's features. If userns isn't among them, the interface adds no AppArmor rule; the seccomp lines still apply. lxd-support, docker-support, greengrass-support, steam-support and browser support with allow-sandbox run the same check and add the line themselves, so the LXD daemon doesn't plug userns. The plug is still super-privileged.

07 Where to go from here

ROADS containers, VMs and support Confinementthe profiles; what unconfined means System control and observethe same pattern, aimed at the host Workloadsa proposal, not in snapd yet InterfacesImplementationthe gatehouse and the gatekeepers' hall: the way back
Roads from this family to confinement, system control and observe, workloads, and back to the gatehouse and the gatekeepers' hall

Confinement for the profiles; system control and observe for the neighbouring family; workloads for a proposal, not in snapd yet, that would give started programs fewer permissions. The gatehouse and the gatekeepers' hall lead back.

A socket for acme-agent, root for the daemon behind it, and a store that decides who gets which. Here's where to go next. Confinement shows what the profiles these interfaces widen are, and what unconfined means for a process. System control and observe is the neighbouring family: the same super-privileged pattern, aimed at the host rather than a daemon. Workloads is a proposal, not in snapd yet, for giving the programs an app starts fewer permissions than the app itself. And the gatehouse and the gatekeepers' hall lead back to interfaces in general.

08 All 27 interfaces at a glance

ALL 27 INTERFACES AT A GLANCE acrn-support adb-support checkbox-support * classic-support * core-support devlxd * docker docker-support * empty firmware-updater-support * greengrass-support * kubernetes-support * libvirt lxd-support * microceph-support * microstack-support * multipass-support * nomad-support * nvidia-drivers-support * ros-snapd-support * steam-support * userns * fwupd lxd * microceph * microovn * podman auto-connectsconditionalby handstore rule to connect* store rule to install · italic: Ubuntu Touch era
Every interface in the containers, VMs and support family, sorted and coloured by how it gets connected: auto-connect, conditional, by hand, or store rule needed

Every interface in the family by connection class: 0 auto-connect, 0 conditionally, 22 by hand, 5 need a store rule to connect; 19 are super-privileged.

All 27 interfaces of the containers, VMs and support family at a glance, sorted by how they get connected. 22 connect by hand with snap connect, which is most of the family. 5 need a store rule even to connect: fwupd, lxd, microceph, microovn, podman. 19, marked with a star, are super-privileged and need a store rule to install. 1, in italics, are Ubuntu Touch era and effectively legacy. Every one of them is in the catalogue below this deck, with what it grants and its rule.

Read more

The two shapes

Socket interfaceSupport interface
Membersdocker, lxd, podman, libvirt, microceph, microovn, devlxd, fwupdthe *-support interfaces
Used bya client of the daemonthe daemon itself
The plug getsread and write on one unix socketwhat the daemon needs to run containers or VMs
Where the slot isthe system on classic (docker, podman, libvirt), or the daemon snap (lxd, microceph, microovn)the system
Store gatevaries, see belowthe plug is super-privileged, except acrn-support, adb-support and core-support

The socket interfaces, from loose to strict

InterfaceBase declaration on the slotEffect
libvirtdeny-auto-connection: truean administrator connects by hand; the slot exists only on classic
dockerdeny-connection: on-classic: falseby hand on classic; a store rule on Ubuntu Core
podmandeny-connection: truea store rule everywhere
lxd, microceph, microovnallow-installation: false, deny-connection: truethe daemon snap needs a snap-declaration to install, and connections need a store rule

Gotchas

  • Connecting a socket interface gives the client full control of that daemon. For lxd and docker that is close to root on the host.
  • Only some support interfaces take over the device cgroup: docker-support, lxd-support, nomad-support, microstack-support, and greengrass-support for its container flavors. snapd then writes no udev tagging rules for that snap, and the interface adds Delegate=true to its services.
  • The family relaxes confinement on purpose in four places: lxd-support's unconfined profile flag, steam-support's allow all, rule, docker-support's privileged-containers rules, and classic-support's chroot with sudo Uxr.
  • Every *-support plug in this family except core-support refuses parallel instances of the snap.
  • Without privileged-containers, docker-support lets the daemon move a container to the docker-default profile or stack that profile on its own. With it, the daemon may switch to any profile.
  • greengrass-support accepts any flavor and emits almost no rules for an unknown one; kubernetes-support checks its flavor against kubelet, kubeproxy and autobind-unix.
  • firmware-updater-support and ros-snapd-support add no sandbox rules at all; they only unlock parts of the snapd REST API.
  • core-support is kept for compatibility and grants nothing.

Further reading

Roads from here

INTERFACES AND CONFINEMENT

INTERFACE FAMILIES · every interface, grouped by what it touches