5.2.2 Minimize the admission of containers wishing to share the host process ID namespace

Information

Do not generally permit containers to be run with the hostPID flag set to true.

Rationale:

A container running in the host's PID namespace can inspect processes running outside the container. If the container also has access to ptrace capabilities this can be used to escalate privileges outside of the container.

There should be at least one Security Context Constraint (SCC) defined which does not permit containers to share the host PID namespace.

If you need to run containers which require hostPID, this should be defined in a separate SCC and you should carefully check RBAC controls to ensure that only limited service accounts and users are given permission to access that SCC.

Impact:

Pods defined with Allow Host PID: true will not be permitted unless they are run under a specific SCC.

Solution

Create an SCC that sets allowHostPID to false and take it into use by assigning it to applicable users and groups.

Default Value:

By default, the following SCCs do not allow users to run within the host process namespace:

'anyuid'

'hostmount-anyuid'

'hostnetwork'

'hostnetwork-v2'

'machine-api-termination-handler'

'nonroot'

'nonroot-v2'

'restricted'

'restricted-v2'

See Also

https://workbench.cisecurity.org/benchmarks/14166