diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2022-02-28 09:48:52 +0100 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2022-03-30 15:32:18 +0200 |
commit | 7b368768c2990b9781b2b6813e1c7f91c7e6cb13 (patch) | |
tree | 298f78b19f0c6d86251ff3a84280f89e04b922bc /pkg | |
parent | 05f083461047d0b5425e22334e8259038a51492e (diff) | |
download | podman-7b368768c2990b9781b2b6813e1c7f91c7e6cb13.tar.gz podman-7b368768c2990b9781b2b6813e1c7f91c7e6cb13.tar.bz2 podman-7b368768c2990b9781b2b6813e1c7f91c7e6cb13.zip |
do not set the inheritable capabilities
The kernel never sets the inheritable capabilities for a process, they
are only set by userspace. Emulate the same behavior.
Closes: CVE-2022-27649
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
(cherry picked from commit aafa80918a245edcbdaceb1191d749570f1872d0)
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/specgen/generate/security.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pkg/specgen/generate/security.go b/pkg/specgen/generate/security.go index 9c6709905..988c29832 100644 --- a/pkg/specgen/generate/security.go +++ b/pkg/specgen/generate/security.go @@ -146,6 +146,10 @@ func securityConfigureGenerator(s *specgen.SpecGenerator, g *generate.Generator, configSpec := g.Config configSpec.Process.Capabilities.Ambient = []string{} + + // Always unset the inheritable capabilities similarly to what the Linux kernel does + // They are used only when using capabilities with uid != 0. + configSpec.Process.Capabilities.Inheritable = []string{} configSpec.Process.Capabilities.Bounding = caplist user := strings.Split(s.User, ":")[0] @@ -153,7 +157,6 @@ func securityConfigureGenerator(s *specgen.SpecGenerator, g *generate.Generator, if (user == "" && s.UserNS.NSMode != specgen.KeepID) || user == "root" || user == "0" { configSpec.Process.Capabilities.Effective = caplist configSpec.Process.Capabilities.Permitted = caplist - configSpec.Process.Capabilities.Inheritable = caplist } else { mergedCaps, err := capabilities.MergeCapabilities(nil, s.CapAdd, nil) if err != nil { @@ -175,12 +178,12 @@ func securityConfigureGenerator(s *specgen.SpecGenerator, g *generate.Generator, } configSpec.Process.Capabilities.Effective = userCaps configSpec.Process.Capabilities.Permitted = userCaps - configSpec.Process.Capabilities.Inheritable = userCaps // Ambient capabilities were added to Linux 4.3. Set ambient // capabilities only when the kernel supports them. if supportAmbientCapabilities() { configSpec.Process.Capabilities.Ambient = userCaps + configSpec.Process.Capabilities.Inheritable = userCaps } } |