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 a SCC as described in the OpenShift documentation, ensuring that the Allow Host PID field is set to false.
Default Value:
By default, OpenShift 4 clusters include the following SCCs:
anyuid Allow Host PID: false
hostaccess Allow Host PID: true
Hostmount-anyuid Allow Host PID: false
hostnetwork Allow Host PID: false
node-exporter Allow Host PID: true
non-root Allow Host PID: false
privileged Allow Host PID: false
restricted Allow Host PID: false