containers.conf: add a no_new_privileges option
Feature request
containers.conf has no key for the no-new-privileges security option, so there is no way to make it the default for every container, or for the containers that load a given --module.
Today it can only be set per run with podman run --security-opt no-new-privileges. A no_new_privileges = true setting under [containers] that sets process.noNewPrivileges in the generated OCI spec would let a containers.conf module bundle it with the other hardening for a tier of untrusted containers, for example:
[containers]
netns = "none"
no_new_privileges = true
[engine]
runtime = "runsc"
Current behaviour
common/pkg/config/config.goonmainhas no such field inContainersConfig.- Unknown keys are only logged at debug level, so
no_new_privileges = truein a module is ignored silently. - Checked on Podman 5.8.9: with that key in a module, the OCI spec has
process.noNewPrivileges: nullandprctl(PR_GET_NO_NEW_PRIVS)returns 0 inside the container. With--security-opt no-new-privilegesit returns 1.
Expected behaviour
A [containers] boolean, defaulting to false, whose effect is the same as passing --security-opt no-new-privileges on every run and create. The command-line flag should still override it.
Hi, I'm interested in working on this. I've already started tracing the existing implementation.
My understanding is that the missing functionality is reading a default from containers.conf and applying it when the container request leaves the setting unspecified.
I believe this will require changes in both repositories - one for adding configuration support in container-libs/common, then consuming it here in Podman. The override behaviour should preserve explicit true or false. In particular, configured true must not override explicit false.
I have a question - does applying the default on the container-creation side (using the remote service’s configuration for remote requests) match the maintainers’ expectations?
/assign