podman icon indicating copy to clipboard operation
podman copied to clipboard

containers.conf: add a no_new_privileges option

Open Bad3r opened this issue 1 month ago • 2 comments

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.go on main has no such field in ContainersConfig.
  • Unknown keys are only logged at debug level, so no_new_privileges = true in a module is ignored silently.
  • Checked on Podman 5.8.9: with that key in a module, the OCI spec has process.noNewPrivileges: null and prctl(PR_GET_NO_NEW_PRIVS) returns 0 inside the container. With --security-opt no-new-privileges it 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.

Bad3r avatar Oct 24 '26 18:10 Bad3r

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?

nadav78 avatar Oct 30 '26 08:10 nadav78

/assign

Garvity avatar Nov 03 '26 14:11 Garvity