You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// otherwise apply the plugin + task capability configuration
cfg.Capabilities=&lconfigs.Capabilities{
Bounding: command.Capabilities,
}
Since the task is unprivileged (i.e. not run as "root"), the privileges set up by libcontainer will not survive execve unless they are specified in the Ambient set.
This is a set of capabilities that are preserved across an execve(2) of a program that is not privileged. The ambient capability set obeys the invariant that no capability can ever be ambient if it is not both permitted and inheritable.
The text was updated successfully, but these errors were encountered:
Currently, the `exec` driver is only setting the Bounding set, which is
not sufficient to actually enable the requisite capabilities for the
task process. In order for the capabilities to survive `execve`
performed by libcontainer, the `Permitted`, `Inheritable`, and `Ambient`
sets must also be set.
Per CAPABILITIES (7):
> Ambient: This is a set of capabilities that are preserved across an
> execve(2) of a program that is not privileged. The ambient capability
> set obeys the invariant that no capability can ever be ambient if it
> is not both permitted and inheritable.
Fixes: hashicorp#16642
Hi @elprans! I did some code spelunking and it looks like we split out this capabilities set when we fixed CVE-2019-12618 a while back, but then when we added the add_caps feature in #10600 we didn't configure the the Ambient set, as you've noted. I'm reviewing and testing your PR #16643 and that looks roughly correctly. I'll get back to you if I find any issues. Thanks!
Nomad version
Nomad v1.5.3-dev
Revision b84c455
Operating system and Environment details
Ubuntu Linux 22.04
Issue
Capabilities configured in
allow_caps
(andcap_add
) have no effect on the task process as Nomad only configures the Bounding capability set.Reproduction steps
cap-test.hcl:
Expected Result
Job runs successfully,
nc
can bind to port 443 becausenet_bind_service
is effective.Actual Result
Job fails with
Root Cause
The issue stems from how Nomad configures the capability sets in libcontainer config:
nomad/drivers/shared/executor/executor_linux.go
Lines 528 to 531 in b84c455
Since the task is unprivileged (i.e. not run as "root"), the privileges set up by libcontainer will not survive
execve
unless they are specified in theAmbient
set.Per CAPABILITIES(7):
The text was updated successfully, but these errors were encountered: