@@ -193,6 +193,81 @@ Given the need for human interaction with PSa check functions when creating the
193
193
SCC-\> PSa mapping, and the complexity of this task, each OpenShift version should
194
194
always ever consider the "latest" PSa checks.
195
195
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
+ - ` AllowedCapabilities ` should include ` NET_BIND_SERVICE ` which allows
221
+ the application to use domain privileged ports (numbers lower than 1024)
222
+ 2 . The SCC to PSa conversion depends on a namespace for the conversion
223
+ - the ` MustRunAs ` strategy of ` RunAsUser ` allows setting an empty range and
224
+ its evaluation for a given pod retrieves the range from the pod's namespace
225
+ annotations
226
+ 3 . The upstream checks can be updated at any time and there is nothing that would
227
+ allow a simple machine conversion between SCC and PSa levels, this is all human driven
228
+ 4 . PSa is designed in a way that allows improving security with time if such a need
229
+ arises
230
+ - this could mean that our SCCs might slip to less restrictive PSa levels in
231
+ time
232
+ - we will need to have a process to tighten SCC permissions that would match
233
+ the PSa capabilities in this regard
234
+
235
+ From the above points, we can safely skip 2. as that is just an interesting observation.
236
+ We are evaluating the PSa levels on namespace level anyway when we are checking the
237
+ SCC-related permissions for each of the SA, which are namespaced by nature.
238
+
239
+ The above changes required ** to make 1. work** might cause workloads to break
240
+ if applied directly to the ` restricted ` SCC. It is impossible to tell which
241
+ workload would break by this step because most of the platform users very likely just
242
+ went with the platform defaults and did not perform further steps in order to
243
+ tighten their workloads to their actual needs. To solve this issue, new
244
+ ` *-v2 ` (e.g. ` restricted-v2 ` , ` nonroot-v2 ` ) SCCs with tighter security policies
245
+ should be introduced for the ` restricted ` SCC and SCCs derived from it. The ` restricted `
246
+ SCC will also drop ` system:authenticated ` from its ` Groups ` field in favour of adding
247
+ it to the ` restricted-v2 ` SCC. This effectively causes older clusters to keep the looser
248
+ permissions of ` restricted ` SCC for their workloads but tighten up the policies
249
+ for workloads of newly created clusters.
250
+
251
+ In case the changes above still break any of user workloads in upgraded clusters
252
+ (` restricted-v2 ` has better restrictive score during evaluation and so it's chosen
253
+ first for field defaulting), the users will need to fix their workloads' ` securityContext `
254
+ accordingly but they should still be able to since they would still have access to
255
+ the ` restricted ` SCC. The ** documentation should include information** how
256
+ to fix such a workload, and how to remove broad user audience access to the legacy
257
+ ` restricted ` SCC.
258
+
259
+ ** For 3** , a process needs to be introduce that allows to simply check the changes to
260
+ the ` k8s.io/pod-security-admission/policy ` folder during k8s.io rebases. The
261
+ repository containing the SCC conversion should include the commit hash of the
262
+ latest checked version of the ` k8s.io/pod-security-admission/policy ` folder that
263
+ the current mapping corresponds to and developers will need to manually check that
264
+ no significant changes happened to the folder in between the two rebases that would
265
+ cause updates to checks. If there were, the conversion needs to be updated. In both
266
+ cases, the commit hash should be updated to match the latest checked version of the
267
+ folder.
268
+
269
+ The ** process for 4.** should be drawn in a follow-up enhancement.
270
+
196
271
### API Extensions
197
272
198
273
A new ` Namespace ` label is being introduced - ` security.openshift.io/scc.podSecurityLabelSync ` .
@@ -203,6 +278,7 @@ section.
203
278
204
279
### Risks and Mitigations
205
280
281
+ #### PSa Label Synchronization Risks
206
282
Turning on the PSa to restricted level enforcing even with the namespace label
207
283
synchronization described in this enforcement brings the risk of breaking direct
208
284
pod application for pods that don't rely on SA permissions, i.e. pods created
@@ -218,6 +294,19 @@ the labels are properly synchronized on their namespace. There is no way to
218
294
mitigate that, the pods will eventually succeed to be created if the given
219
295
service account running them has the correct permissions.
220
296
297
+ #### Restricted SCC Change Risks
298
+
299
+ The ` restricted ` SCC and its variations (e.g. ` nonroot ` ) will need a duplicit ` <name>-v2 `
300
+ variant that should match the updated pod security standards (see
301
+ [ Deriving PSa Level from SCC fields] ( #deriving-psa-level-from-scc-fields ) for
302
+ details of the proposed changes).
303
+
304
+ The ` restricted ` SCC changes may cause some workloads to break. Such failures
305
+ should be rather rare as modern restricted workloads should not be susceptible to
306
+ the * setuid* bits and should tolerate dropped capabilities. Nevertheless, the
307
+ documentation should state how to fix such workloads by modifying the ` dropCapabilities `
308
+ to match the previous ` restricted ` SCC.
309
+
221
310
## Design Details
222
311
223
312
### Open Questions
0 commit comments