Workloads

a proposal · permissions decided at runtime for app developers for snapd developers

Everything an app starts shares the app's permissions; workloads are a proposed way to give such programs a smaller set, and they are not in snapd at commit 13075b6544.

On the map: the workshops, south of the town hall

▶ Watch this deck — 3 scenes, ~2 min

01 Everything the app starts shares its permissions

WORKLOADS photo-editoreditorfilter: sharpenfilter: by a stranger snap.photo-editor.editorone security tag per app or hookfixed when the snap is built the editor's AppArmor profile and seccomp filterinherited by every program it starts from its own files homenetworkthe filters have these too no smaller box for the filter
photo-editor with its editor app and two filter programs it starts, one written by someone else; both filters run under the editor's AppArmor profile and seccomp filter and so have its home and network connections

Confinement is per app and per hook, with security tags such as snap.photo-editor.editor. Programs an app executes from its snap inherit its AppArmor profile (ix) and seccomp filter, so they have the app's connections.

Say the photo editor runs each of its filters as a separate program, and some filters were written by other people. What may a filter do? Exactly what the editor may do. snapd gives permissions to apps and hooks, each with its own security tag, and they're fixed in snap.yaml when the snap is built. A program the editor starts from its own files inherits the editor's AppArmor profile and seccomp filter. So a filter can read your home folder and reach the network, because the editor can. There's no smaller box to put it in.

02 Workloads are a proposal

A PROPOSAL photo-editoreditorworkload: filtersits own set of permissions $ snapctl add-plug ...$ snapctl attach-plug ...proposed, not real commandsplug you connectthe snap only attaches not in snapd at commit 13075b6544no such snapctl commands · no workloads in the interfaces package
A proposed workload inside photo-editor holding the filters, with plugs added and attached by proposed snapctl add-plug and attach-plug commands; the user still connects; a note that none of this exists in snapd at commit 13075b6544

Workloads, with snapctl add-plug and attach-plug, are a proposed design (spec SD273). At snapd commit 13075b6544 there are no such snapctl commands and no workload code in the interfaces package.

Workloads are a proposed answer. A workload would be a named set of permissions inside a snap, for things the snap starts but doesn't fully trust, like those filters. In the proposal, a snap would add plugs while it runs, with snapctl add-plug, and attach them to a workload with snapctl attach-plug. You'd still decide which plugs are connected; the snap would only choose which workload gets them. None of this is in snapd at the commit this map was checked against. snapctl has no such commands, and the interfaces package has no workloads.

03 Where to go from here

ROADS Workloads For developersonly the plugs each app needs Confinementthe profile a program inherits Containers and supportdocker-support · lxd-support snapctlthe commands a snap has
Roads from workloads: per-app plugs for developers, confinement, the container interfaces and snapctl

Roads: per-app plugs, confinement, the container interfaces and snapctl.

Until workloads exist, the permissions you can shape are the ones in snap.yaml. The developers' deck shows how to give each app only the plugs it needs, so a helper app can have less than the editor. Confinement shows the profile a program inherits. The container interfaces, like docker-support and lxd-support, show what snaps that run containers get today: broad rights, and only with a store rule. And snapctl lists the commands a snap really has.

Read more

What exists today

QuestionAnswer at snapd commit 13075b6544
What is confined separately?each app and each hook of a snap, by its security tag, such as snap.photo-editor.editor and snap.photo-editor.hook.configure
What does a program started by an app get?the app's AppArmor profile, since the snap's own files are executed with ix (inherit), and the app's seccomp filter
Can a snap add plugs or slots while it runs?no; plugs and slots come from snap.yaml, implicit system slots and hotplug
Can a snap connect its own plugs?no; it can only ask with snapctl is-connected
Is there a snapctl add-plug or attach-plug?no

The proposal

Workloads are described in a design specification (SD273) that is not part of the snapd tree. What the map knows of it: a workload is a named set of permissions inside a snap for programs the snap starts but does not fully trust; plugs would be added at runtime with snapctl add-plug and attached to a workload with snapctl attach-plug; connecting would stay with the user. Details may change before any of it lands.

Narrowing permissions today

  • Give each app only the plugs it needs; a top-level plug listed by no app goes to all of them.
  • Run untrusted code in a separate app of the snap with fewer plugs, or in a separate snap.
  • Snaps that manage containers use interfaces such as docker-support and lxd-support, which need a store rule to install.

Further reading

Roads from here

INTERFACES AND CONFINEMENT

SNAPCTL · the snap's API into snapd

INTERFACE FAMILIES · every interface, grouped by what it touches