Skip to content

Conversation

@justincormack
Copy link
Contributor

This is a rework of support for ambient capabilities, to avoid
the issues in the previous version, where there was a conflict
between two use cases, programs that want to use sudo and programs
that want to grant unprivileged users direct capabilities.

If you do not use the --security-opt no-new-privileges flag,
nothing changes with this patch. sudo, suid binaries and filesystem
capabilities elevate privileges, and non root users can only use
privileges via these mechanisms as on a normal Linux userspace.

With the no-new-privileges flag, the kernel does not allow caps
to be granted via suid binaries, so it is assumed that the user wants
to be granted capabilities directly, so ambient capabilities are
granted. For root this makes little difference, but for a normal
user this means that they can be granted capabilities directly, so
that privileged operations can be performed directly.

As previously no capabilities were granted to a non root user with
no-new-privileges, we take the opoprtunity to reduce the default
capability set in this case to only the three safest capabilities:
CAP_KILL, CAP_AUDIT_WRITE and CAP_NET_SERVICE. Other capabilities
must be granted with --cap-add.

runc commit is in opencontainers/runc#1286
Spec commit is in opencontainers/runtime-spec#668

These upstream commits need merging first so marked as WIP, but this allows people to test.

fix #8460

See #26979 for previous version.

Signed-off-by: Justin Cormack [email protected]

spring-lamb-003

This is a rework of support for ambient capabilities, to avoid
the issues in the previous version, where there was a conflict
between two use cases, programs that want to use sudo and programs
that want to grant unprivileged users direct capabilities.

If you do not use the `--security-opt no-new-privileges` flag,
nothing changes with this patch. `sudo`, suid binaries and filesystem
capabilities elevate privileges, and non root users can only use
privileges via these mechanisms as on a normal Linux userspace.

With the `no-new-privileges` flag, the kernel does not allow caps
to be granted via suid binaries, so it is assumed that the user wants
to be granted capabilities directly, so ambient capabilities are
granted. For root this makes little difference, but for a normal
user this means that they can be granted capabilities directly, so
that privileged operations can be performed directly.

As previously no capabilities were granted to a non root user with
`no-new-privileges`, we take the opoprtunity to reduce the default
capability set in this case to only the three safest capabilities:
`CAP_KILL`, `CAP_AUDIT_WRITE` and `CAP_NET_SERVICE`. Other capabilities
must be granted with `--cap-add`.

`runc` commit is in opencontainers/runc#1286
Spec commit is in opencontainers/runtime-spec#668

fix moby#8460

Signed-off-by: Justin Cormack <[email protected]>
@justincormack
Copy link
Contributor Author

cc @jessfraz as you like to use no new privileges, how about some capabilities with that?

@justincormack
Copy link
Contributor Author

I am going to close this as it looks like OCI is not going to take this spec change as is, will leave this branch for anyone who wants to test, and redo if/when the spec is finalised...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't bind to privileged ports as non-root

2 participants