Repository navigation
fix(docker): don't give app containers CAP_MKNOD - #598
Open
andrewdunndev wants to merge 1 commit into
Open
andrewdunndev wants to merge 1 commit into
andrewdunndev wants to merge 1 commit into
Conversation
Wolf lets every app container open any input and hidraw device through the `c 13:* rwm` and `c <hidraw>:* rwm` device cgroup rules, and the default profiles add CAP_MKNOD so that Wolf's hotplug exec can create the nodes. Together they let any root process in an app container create and open another session's virtual devices, or the host's own input devices. Run the hotplug exec privileged instead, and strip MKNOD from the app container: remove it from CapAdd and add it to CapDrop (Docker grants it by default). Privileged containers are left as they are. The default config and the docs no longer add MKNOD. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CPq1qsThei84HS1zfu4Zvy
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #597.
Summary
App containers get
c 13:* rwmandc <hidraw>:* rwmdevice cgroup rules, and the default profiles add MKNOD (Docker grants it anyway). Root in an app container can therefore create and open other sessions' input nodes, or the host's. This drops MKNOD from app containers.The change
DockerAPI::exectakesbool privileged = false; the plug exec (mkdir, mknod, chmod, fake-udev) now runs privileged. The unplug exec is unchanged.drop_mknod_capability()runs at create: it removes MKNOD/CAP_MKNOD fromCapAddand adds MKNOD toCapDrop. Containers withPrivileged: trueare left alone. TheCapAddstrip matters on Podman, which rejects an add and a drop of the same capability.config.v7.toml, its include and the docs. Older config versions are untouched, since the strip at create covers them.Hotplug keeps working because Wolf's exec creates the node, so the container no longer needs the capability.
Testing
One AMD host, Podman and Docker 27.5.1 (Docker-in-Podman), scripted sessions, 3 reps per arm per engine, base is beta ac2461f.
Both halves are needed: without the privileged exec no node is created, and without the CapDrop Docker keeps MKNOD.
Unit: 1120 assertions in 40 test cases pass (daemon
[DOCKER]cases not run), plus a new case for the capability handling (8 assertions).Limits
CapAdd: ["ALL"], native Docker. In the hotplug rows the event nodes were partly masked by stale nodes; a run with stale nodes removed first, and the js, mouse and hidraw nodes, show fresh creation (3/3).We have a test bench (one AMD host with a discrete and an integrated GPU, one NVIDIA host, scripted Moonlight clients) and are glad to take on A/B runs or side quests. GPU age is the one limit worth naming.