Skip to content

Commit 99035a6

Browse files
committed
add more information on SCC->PSa level mapping
1 parent 6bfc780 commit 99035a6

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

enhancements/authentication/pod-security-admission-autolabeling.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,74 @@ Given the need for human interaction with PSa check functions when creating the
193193
SCC-\>PSa mapping, and the complexity of this task, each OpenShift version should
194194
always ever consider the "latest" PSa checks.
195195

196+
#### Deriving PSa Level from SCC fields
197+
198+
The SCC fields perform different tasks for fields of a security context:
199+
200+
1. restrict the values to a certain value domain
201+
2. modify the field value in case the field is unset
202+
3. combination of the above
203+
4. restrict the values of an already allowed set (e.g. `AllowedFlexVolumes` only
204+
further restricts flex volumes allowed by `Volumes` but upstream makes no
205+
difference there)
206+
207+
For the conversion between SCC and PSa levels, we are only interested in fields
208+
that do 1. and 3. The conversion itself needs to make sure that the values allowed
209+
by SCCs are a subset of the values allowed by the given PSa level in order for the
210+
SCC to match the PSa level.
211+
212+
**Caveats and Gotchas Found During SCC Mapping Investigation**
213+
214+
1. Currently, there exists no default SCC supplied with the platform that would
215+
match any PSa level more restricted than `baseline`
216+
- the `restricted` (and any dependent) SCC needs to be modified to match the
217+
pod security standards of today:
218+
- `RequiredDropCapabilities` should now contain just one value - `ALL`
219+
- `AllowPrivilegeEscalation` should now be `false`
220+
2. The SCC to PSa conversion depends on a namespace for the conversion
221+
- the `MustRunAs` strategy of `RunAsUser` allows setting an empty range and
222+
its evaluation for a given pod retrieves the range from the pod's namespace
223+
annotations
224+
3. The upstream checks can be updated at any time and there is nothing that would
225+
allow a simple machine conversion between SCC and PSa levels, this is all human driven
226+
4. PSa is designed in a way that allows improving security with time if such a need
227+
arises
228+
- this could mean that our SCCs might slip to less restrictive PSa levels in
229+
time
230+
- we will need to have a process to tighten SCC permissions that would match
231+
the PSa capabilities in this regard
232+
233+
From the above points, we can safely skip 2. as that is just an interesting observation.
234+
We are evaluating the PSa levels on namespace level anyway when we are checking the
235+
SCC-related permissions for each of the SA, which are namespaced by nature.
236+
237+
**Addressing 1.** might be a bit hard in order to make sure we prevent workloads from
238+
breaking. There is no way to add another SCC for the same groups as `restricted`
239+
has because that would achieve no further enforcement (the `restricted` SCC is
240+
usable by the `system:authenticated` group).
241+
242+
The above 1. required changes have been requested by the podman team in the past,
243+
though, and any current reasonable workload should still work even if these more
244+
restrictive policies are implemented. It is impossible to tell which workloads
245+
might be broken by this step because most of the platform users very likely just
246+
went with the platform defaults and did not perform further steps in order to
247+
tighten their workloads to their actual needs. The proposed solution is therefore
248+
to simply perform the changes to the SCC. We ship the SCC with the "create-only"
249+
manifest mode and so the customers might revert them back to the state that's
250+
working for them as a mitigation.
251+
252+
**For 3**, a process needs to be introduce that allows to simply check the changes to
253+
the `k8s.io/pod-security-admission/policy` folder during k8s.io rebases. The
254+
repository containing the SCC conversion should include the commit hash of the
255+
latest checked version of the `k8s.io/pod-security-admission/policy` folder that
256+
the current mapping corresponds to and developers will need to manually check that
257+
no significant changes happened to the folder in between the two rebases that would
258+
cause updates to checks. If there were, the conversion needs to be updated. In both
259+
cases, the commit hash should be updated to match the latest checked version of the
260+
folder.
261+
262+
The **process for 4.** should be drawn in a follow-up enhancement.
263+
196264
### API Extensions
197265

198266
A new `Namespace` label is being introduced - `security.openshift.io/scc.podSecurityLabelSync`.
@@ -203,6 +271,7 @@ section.
203271

204272
### Risks and Mitigations
205273

274+
#### PSa Label Synchronization Risks
206275
Turning on the PSa to restricted level enforcing even with the namespace label
207276
synchronization described in this enforcement brings the risk of breaking direct
208277
pod application for pods that don't rely on SA permissions, i.e. pods created
@@ -218,6 +287,19 @@ the labels are properly synchronized on their namespace. There is no way to
218287
mitigate that, the pods will eventually succeed to be created if the given
219288
service account running them has the correct permissions.
220289

290+
#### Restricted SCC Change Risks
291+
292+
The `restricted` SCC and its variations (e.g. `nonroot`) need to be changed
293+
in order to match the current pod security standards (see [Deriving PSa Level from SCC fields](#deriving-psa-level-from-scc-fields)
294+
for details on the changes).
295+
296+
This may cause some workloads to break. Such failures should however be very rare
297+
since most restricted workloads have been adjusted through time to being able
298+
to work without the privilege escalation bit and with all capabilities being dropped.
299+
300+
The SCCs we provide allow modifications and so if this is causing workloads to break,
301+
users should be able to turn the change back as a mitigation.
302+
221303
## Design Details
222304

223305
### Open Questions

0 commit comments

Comments
 (0)