diff --git a/runsc/cmd/cmd.go b/runsc/cmd/cmd.go index 3c726bd24..a46dc0e55 100644 --- a/runsc/cmd/cmd.go +++ b/runsc/cmd/cmd.go @@ -89,6 +89,10 @@ func callSelfAsNobody(args []string) error { if _, _, err := unix.RawSyscall(unix.SYS_SETUID, uintptr(nobody), 0, 0); err != 0 { return fmt.Errorf("error setting gid: %v", err) } + // Drop all capabilities. + if err := applyCaps(&specs.LinuxCapabilities{}); err != nil { + return fmt.Errorf("error dropping capabilities: %w", err) + } binPath := specutils.ExePath diff --git a/runsc/sandbox/sandbox.go b/runsc/sandbox/sandbox.go index 1703e4f7f..91f530005 100644 --- a/runsc/sandbox/sandbox.go +++ b/runsc/sandbox/sandbox.go @@ -881,7 +881,12 @@ func (s *Sandbox) createSandboxProcess(conf *config.Config, args *Args, startSyn // A sandbox process will construct an empty root for itself, so it has // to have CAP_SYS_ADMIN and CAP_SYS_CHROOT capabilities. - cmd.SysProcAttr.AmbientCaps = append(cmd.SysProcAttr.AmbientCaps, uintptr(capability.CAP_SYS_ADMIN), uintptr(capability.CAP_SYS_CHROOT)) + cmd.SysProcAttr.AmbientCaps = append(cmd.SysProcAttr.AmbientCaps, + uintptr(capability.CAP_SYS_ADMIN), + uintptr(capability.CAP_SYS_CHROOT), + // CAP_SETPCAP is required to clear the bounding set. + uintptr(capability.CAP_SETPCAP), + ) } else { return fmt.Errorf("can't run sandbox process as user nobody since we don't have CAP_SETUID or CAP_SETGID")