@@ -267,21 +267,29 @@ xref:s2i.adoc#creating-images-s2i[S2I Requirements] topic.
267
267
[[use-uid]]
268
268
*Support Arbitrary User IDs*
269
269
270
- In order to support running containers with volumes mounted in a secure fashion,
271
- images should be capable of being run as any arbitrary user ID. When
272
- {product-title} mounts volumes for a container, it configures the volume so it
273
- can only be written to be a particular user ID, and then runs the image using
274
- that same user ID. This ensures the volume is only accessible to the appropriate
275
- container, but requires the image be able to run as an arbitrary user ID.
276
-
277
- Running a container with an arbitrary user ID also has the benefit of ensuring
278
- that a process which is able to escape the container due to a vulnerability in
279
- the container framework will not have specific user permissions on the host
280
- system.
281
-
282
- To accomplish this, directories that must be written to by processes in the
283
- image should be world-writable. In addition, the processes running in the
284
- container must not listen on privileged ports (ports below 1024).
270
+ To provide additional security against processes escaping the container due
271
+ to a container engine vulnerability and thereby achieving escalated permissions
272
+ on the host node, {product-title} runs containers using an arbitrarily assigned uid by default.
273
+
274
+ For an image to support running as an arbitray user, directories and files that may be
275
+ written to by processes in the image should be owned by the root group and read/writable
276
+ by that group. Files to be executed should also have group execute permissions. The following
277
+ Dockerfile fragment sets root group ownership and permissions for *_/some/directory_* and all child
278
+ directories:
279
+
280
+ ----
281
+ RUN chgrp -R 0 /some/directory
282
+ RUN chmod -R g+rw /some/directory
283
+ RUN find /some/directory -type d -exec chmod g+x {} +
284
+ ----
285
+
286
+ Adding these commands to your Dockerfile sets the directory and file permissions to allow users
287
+ in the root group to access them in the built image. Because the container user is always a member
288
+ of the root group, the container user can read and write these files. The root group does not have
289
+ any special permissions (unlike the root user) so there are no security concerns with this arrangement.
290
+
291
+ In addition, the processes running in the container must not listen on privileged ports (ports below
292
+ 1024), since they are not running as a privileged user.
285
293
286
294
Because the user ID of the container is generated dynamically, it will not have
287
295
an associated entry in *_/etc/passwd_*. This can cause problems for applications
0 commit comments