|
| 1 | +:_mod-docs-content-type: ASSEMBLY |
| 2 | +[id="telco-security-sec-context-constraints"] |
| 3 | += Security context constraints |
| 4 | +include::_attributes/common-attributes.adoc[] |
| 5 | +:context: telco-security-sec-context-constraints |
| 6 | +:imagesdir: images |
| 7 | + |
| 8 | +toc::[] |
| 9 | + |
| 10 | +Similar to the way that RBAC resources control user access, administrators can use security context constraints (SCCs) to control permissions for pods. These permissions determine the actions that a pod can perform and what resources it can access. You can use SCCs to define a set of conditions that a pod must run. |
| 11 | + |
| 12 | +Security context constraints allow an administrator to control the following security constraints: |
| 13 | + |
| 14 | +* Whether a pod can run privileged containers with the `allowPrivilegedContainer` flag |
| 15 | +* Whether a pod is constrained with the `allowPrivilegeEscalation` flag |
| 16 | +* The capabilities that a container can request |
| 17 | +* The use of host directories as volumes |
| 18 | +* The SELinux context of the container |
| 19 | +* The container user ID |
| 20 | +* The use of host namespaces and networking |
| 21 | +* The allocation of an `FSGroup` that owns the pod volumes |
| 22 | +* The configuration of allowable supplemental groups |
| 23 | +* Whether a container requires write access to its root file system |
| 24 | +* The usage of volume types |
| 25 | +* The configuration of allowable `seccomp` profiles |
| 26 | +
|
| 27 | +Default SCCs are created during installation and when you install some Operators or other components. As a cluster administrator, you can also create your own SCCs by using the OpenShift CLI (`oc`). |
| 28 | + |
| 29 | +For information about default security context constraints, see xref:../../../authentication/managing-security-context-constraints.adoc#default-sccs_configuring-internal-oauth[Default security context constraints]. |
| 30 | + |
| 31 | +[IMPORTANT] |
| 32 | +==== |
| 33 | +Do not modify the default SCCs. Customizing the default SCCs can lead to issues when some of the platform pods deploy or {product-title} is upgraded. Additionally, the default SCC values are reset to the defaults during some cluster upgrades, which discards all customizations to those SCCs. |
| 34 | +
|
| 35 | +Instead of modifying the default SCCs, create and modify your own SCCs as needed. For detailed steps, see xref:../../../authentication/managing-security-context-constraints.adoc#security-context-constraints-creating_configuring-internal-oauth[Creating security context constraints]. |
| 36 | +==== |
| 37 | + |
| 38 | +You can use the following basic SCCs: |
| 39 | + |
| 40 | +* `restricted` |
| 41 | +* `restricted-v2` |
| 42 | +
|
| 43 | +The `restricted-v2` SCC is the most restrictive SCC provided by a new installation and is used by default for authenticated users. It aligns with Pod Security Admission (PSA) restrictions and improves security, as the original `restricted` SCC is less restrictive. It also helps transition from the original SCCs to v2 across multiple releases. Eventually, the original SCCs get deprecated. Therefore, it is recommended to use the `restricted-v2` SCC. |
| 44 | + |
| 45 | +You can examine the `restricted-v2` SCC by running the following command: |
| 46 | +[source,terminal] |
| 47 | +---- |
| 48 | +$ oc describe scc restricted-v2 |
| 49 | +---- |
| 50 | +.Example output |
| 51 | +[source,terminal] |
| 52 | +---- |
| 53 | +Name: restricted-v2 |
| 54 | +Priority: <none> |
| 55 | +Access: |
| 56 | + Users: <none> |
| 57 | + Groups: <none> |
| 58 | +Settings: |
| 59 | + Allow Privileged: false |
| 60 | + Allow Privilege Escalation: false |
| 61 | + Default Add Capabilities: <none> |
| 62 | + Required Drop Capabilities: ALL |
| 63 | + Allowed Capabilities: NET_BIND_SERVICE |
| 64 | + Allowed Seccomp Profiles: runtime/default |
| 65 | + Allowed Volume Types: configMap,downwardAPI,emptyDir,ephemeral,persistentVolumeClaim,projected,secret |
| 66 | + Allowed Flexvolumes: <all> |
| 67 | + Allowed Unsafe Sysctls: <none> |
| 68 | + Forbidden Sysctls: <none> |
| 69 | + Allow Host Network: false |
| 70 | + Allow Host Ports: false |
| 71 | + Allow Host PID: false |
| 72 | + Allow Host IPC: false |
| 73 | + Read Only Root Filesystem: false |
| 74 | + Run As User Strategy: MustRunAsRange |
| 75 | + UID: <none> |
| 76 | + UID Range Min: <none> |
| 77 | + UID Range Max: <none> |
| 78 | + SELinux Context Strategy: MustRunAs |
| 79 | + User: <none> |
| 80 | + Role: <none> |
| 81 | + Type: <none> |
| 82 | + Level: <none> |
| 83 | + FSGroup Strategy: MustRunAs |
| 84 | + Ranges: <none> |
| 85 | + Supplemental Groups Strategy: RunAsAny |
| 86 | + Ranges: <none> |
| 87 | +---- |
| 88 | + |
| 89 | +The `restricted-v2` SCC explicitly denies everything except what it explicitly allows. The following settings define the allowed capabilities and security restrictions: |
| 90 | + |
| 91 | +* Default add capabilities: Set to `<none>`. It means that no capabilities are added to a pod by default. |
| 92 | +* Required drop capabilities: Set to `ALL`. This drops all the default Linux capabilities of a pod. |
| 93 | +* Allowed capabilities: `NET_BIND_SERVICE`. A pod can request this capability, but it is not added by default. |
| 94 | +* Allowed `seccomp` profiles: `runtime/default`. |
| 95 | +
|
| 96 | +For more information, see xref:../../../authentication/managing-security-context-constraints.adoc[Managing security context constraints]. |
0 commit comments