Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master] Fix Access to remapped root allows privilege escalation to real root (CVE-2021-21284) #41964

Merged
merged 3 commits into from
Feb 2, 2021

Conversation

thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Feb 2, 2021

This forward-ports the changes related to CVE-2021-21284 (Advisory: GHSA-7452-xqpj-6rpc). These changes are already included in the v20.10.3 and v19.03.15 security releases, and this PR forwards those changes to the master branch

Cherry-pick was clean:

git cherry-pick -s -S -x edb62a3 bfedd27 e908cc3

Generally if we ever need to change perms of a dir, between versions,
this ensures the permissions actually change when we think it should
change without having to handle special cases if it already existed.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit edb62a3)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The remapped root does not need access to this dir.
Having this owned by the remapped root opens the host up to an
uprivileged user on the host being able to escalate privileges.

While it would not be normal for the remapped UID to be used outside of
the container context, it could happen.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit bfedd27)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Various dirs in /var/lib/docker contain data that needs to be mounted
into a container. For this reason, these dirs are set to be owned by the
remapped root user, otherwise there can be permissions issues.
However, this uneccessarily exposes these dirs to an unprivileged user
on the host.

Instead, set the ownership of these dirs to the real root (or rather the
UID/GID of dockerd) with 0701 permissions, which allows the remapped
root to enter the directories but not read/write to them.
The remapped root needs to enter these dirs so the container's rootfs
can be configured... e.g. to mount /etc/resolve.conf.

This prevents an unprivileged user from having read/write access to
these dirs on the host.
The flip side of this is now any user can enter these directories.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit e908cc3)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
Copy link
Member Author

@cpuguy83 @tiborvass @tonistiigi PTAL

@tiborvass
Copy link
Contributor

Unrelated failure in https://ci-next.docker.com/public/blue/organizations/jenkins/moby/detail/PR-41964/1/tests

=== RUN   TestDockerSuite/TestLinksPingLinkedContainers
    --- FAIL: TestDockerSuite/TestLinksPingLinkedContainers (5.84s)
        cli.go:29: assertion failed: 
            Command:  /usr/local/cli/docker run --rm --link container1:alias1 --link container2:alias2 --net default busybox sh -c ping -c 1 alias1 -W 1 && ping -c 1 alias2 -W 1
            ExitCode: 1
            Error:    exit status 1
            Stdout:   PING alias1 (172.18.0.2): 56 data bytes
            
            --- alias1 ping statistics ---
            1 packets transmitted, 0 packets received, 100% packet loss
            
            Stderr:   
            
            Failures:
            ExitCode was 1 expected 0
            Expected no error

@tiborvass tiborvass merged commit 64bd448 into moby:master Feb 2, 2021
@thaJeztah thaJeztah deleted the CVE-2021-21284_master branch February 2, 2021 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants