Configuration Guide for SCC - Security Context Constraints with Priority
Environment
- OpenShift Container Platform
- 3.x
Issue
- The
privilegedsccis ignored though it already granted todefaultserviceaccount. - How does the
prioritywork inscc? - How to grant and revoke the
scctoservice accountsusingocCLI ?
Resolution
- Changing
priorityis affected overOCPcluster, so you should adjust it according to yoursecurityorauthorizationpolicy on the aspect of cluster administration in advance. - If you want to use specific
sccexceptanyuid, you should adjust thepriorityof the targetscc.- Because the other
scc(e.g.privileged,nonroot...) havenonepriority, it's meaning0priority, butanyuidhas configured10priorityasdefaultvalue.- the larger value takes precedence in
priorityofscc.
- the larger value takes precedence in
- Because the other
- For example, it's a standard guide for granting
privilegedto adefaultservice accountas follows.
# oc new-project scctest
# oc patch scc privileged -p "priority: 5"
securitycontextconstraints "privileged" patched
# oc get scc privileged
NAME PRIV CAPS SELINUX RUNASUSER FSGROUP SUPGROUP PRIORITY READONLYROOTFS VOLUMES
privileged true [*] RunAsAny RunAsAny RunAsAny RunAsAny 5 false [*]
# oc adm policy add-scc-to-user privileged -z default
scc "privileged" added to: ["system:serviceaccount:scctest:default"]
# oc run testpod --image=registry.access.redhat.com/rhel7 -- tail -f /dev/null
deploymentconfig "testpod" created
# oc describe pod
...
Annotations:
...
openshift.io/scc=privileged
...
- Grant a scc to a service account using
oc adm policy add-scc-to-user.
# oc adm policy add-scc-to-user <scc name> -z <service account name>
- Revoke a scc from a service account using
oc adm policy remove-scc-from-user.
# oc adm policy remove-scc-from-user <scc name> -z <service account name>
Root Cause
- When the complete set of available
SCCs are determined they are ordered by the SCC Prioritization Rules as follows.- Highest
priorityfirst,nil(<none>) is considered a0priority - If priorities are equal, the
SCCs will be sorted from most restrictive to least restrictive - If both priorities and restrictions are equal the
SCCs will be sorted by name
- Highest
- For example, If you grant the
privilegedto aservice accountwithout adjustingpriority,restrictedscctakes effect following above rules.- Because the
restrictedhave more strict thanprivilegedscc, thoughprivilegedandrestricted(defaultscc) are samepriorityasnonevalue.
- Because the
- Also be mindful of both groups and users who have permission to use the
SCCs, as this will affect whichSCCis chosen by default as well.
SBR
Product(s)
Category
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.