RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1665077 - setuid/setgid binaries in Docker running as a non priv user with no capabilities, may still create root owned files outside container on (bind-)mounted volume
Summary: setuid/setgid binaries in Docker running as a non priv user with no capabilit...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: docker
Version: 7.6
Hardware: All
OS: Linux
medium
high
Target Milestone: rc
: ---
Assignee: Daniel Walsh
QA Contact: atomic-bugs@redhat.com
URL:
Whiteboard:
Depends On:
Blocks: 1186913
TreeView+ depends on / blocked
 
Reported: 2019-01-10 13:36 UTC by Oliver Falk
Modified: 2022-03-13 16:43 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-06-09 22:12:49 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Comment 2 Daniel Walsh 2019-01-10 13:54:44 UTC
Are you sure the processes inside of the container were running as non-root. 

Could you run a container and check the UID of the processes inside the container.  I think either Docker in userns mode is not working correctly or you did not set it up correctly.

ps -auxww | grep docker

Comment 3 Oliver Falk 2019-01-10 14:44:29 UTC
Hi Daniel!

Well, no, the binary inside (bash in that case) is setuid:

I have no name!@967ff252e80d:/$ ls -ahl /bash
-rwsrwxrwx. 1 root root 1.1M Dec  7 20:10 /bash
I have no name!@967ff252e80d:/$ /bash -p
bash-4.4# id
uid=99 gid=99 euid=0(root) groups=99

I've asked the customer to check the ps on his system. On my system:

# ps auxw|grep 'bash -p'|grep -v grep
root     27913  0.0  0.0  18124  1932 pts/1    S+   15:39   0:00 /bash -p
# pscap |grep 27913
#

That the basic point. How can we avoid setuid binaries inside a container to become "root" and create root-owned files (outside, via the bind-mounted volume).

Comment 4 Daniel Walsh 2019-01-10 15:01:44 UTC
The ps command above shows the process within the container runing as root on the host?

# ps auxw|grep 'bash -p'|grep -v grep
root     27913  0.0  0.0  18124  1932 pts/1    S+   15:39   0:00 /bash -p

That would be wrong

docker run -d fedora sleep 1000

 ps auxw|grep sleep |grep -v grep

The sleep should be running as Docker root, if it is running as root then the container is not running in a user namespace.

You can also execute something like

docker run -d fedora cat /proc/self/uid_map

And see if there is a mapping.

If the process is running in a Usernamespace and can create a setuid files on the host, then this is a bug in the kernel.

Comment 7 Daniel Walsh 2019-01-10 17:06:13 UTC
That means the docker daemon is not running in user namespace.

Tell them to use podman. :^)

Comment 8 Daniel Walsh 2019-01-10 17:49:36 UTC
Are they actually saying that a user running as non root can create a setuid file?

Comment 14 Daniel Walsh 2019-01-11 16:19:10 UTC
Yes getting setuid from --cap-drop=all should not happen.

If you run a docker container with --cap-drop-call what does /proc/self/status capsbnd show?

Giving a user access to the docker socket, is worse then giving them sudo without password.

http://www.projectatomic.io/blog/2014/09/granting-rights-to-users-to-use-docker-in-fedora/

Talk to this customer about podman.

Comment 16 Daniel Walsh 2019-01-21 19:54:25 UTC
That should prevent you from gaining any privs.

Comment 25 Tom Sweeney 2020-06-09 22:12:49 UTC
We have no plans to ship another version of Docker at this time. RHEL7 is in final support stages where only security fixes will get released.  Customers should move to use Podman which is available starting in RHEL 7.6.


Note You need to log in before you can comment on or make changes to this bug.