Bug 1409531 (CVE-2016-9962)

Summary: CVE-2016-9962 docker: insecure opening of file-descriptor allows privilege escalation
Product: [Other] Security Response Reporter: Martin Prpič <mprpic>
Component: vulnerabilityAssignee: Trevor Jay <tjay>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: adimania, admiller, agoldste, ajia, amurdaca, bbreard, chris.binnie, crrobins, dwalsh, erich, ichavero, imcleod, jcajka, jchaloup, jhonce, joelsmith, knakayam, lsm5, marianne, mattdm, mhicks, miminar, nalin, rcyriac, riek, security-response-team, tjay, vbatts, ykawada
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: docker 1.12.6 Doc Type: Bug Fix
Doc Text:
The runc component used by `docker exec` feature of docker allowed additional container processes to be ptraced by the pid 1 of the container. This allows the main processes of the container, if running as root, to gain low-level access to these new processes during initialization. An attacker can, depending on the nature of the incoming process, leverage this to elevate access to the host. This ranges from accessing host content through the file descriptors of the incoming process to, potentially, a complete container escape by leveraging memory access or syscall interception.
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-01-18 08:17:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1409705, 1409706, 1409707, 1409708, 1412147, 1412189, 1412237, 1412238, 1412239    
Bug Blocks: 1409535    
Attachments:
Description Flags
CVE-2016-9962 patch none

Description Martin Prpič 2017-01-02 12:23:40 UTC
The following issue was reported in Docker:

RunC allowed additional container processes via `runc exec` to be ptraced by the pid 1 of the container.  This allows the main processes of the container, if running as root, to gain access to file-descriptors of these new processes during the initialization and can lead to container escapes or modification of runC state before the process is fully placed inside the container.

Comment 1 Martin Prpič 2017-01-02 12:23:52 UTC
Acknowledgments:

Name: the Docker project
Upstream: Aleksa Sarai (SUSE), Tõnis Tiigi (Docker)

Comment 2 Martin Prpič 2017-01-02 12:32:26 UTC
Created attachment 1236624 [details]
CVE-2016-9962 patch

Comment 8 Trevor Jay 2017-01-03 18:35:43 UTC
This is an extremely difficult to exploit flaw on standard RHEL and Fedora systems. 

I checked the 1.10.3 and 1.12.5 builds on Brew. Both drop the `CAP_SYS_PTRACE` capability by default. 1.10.3 blacklists `ptrace` calls under the default seccomp profile. Thus, this flaw only comes into play for containers that already have elevated privileges. 

Even if `ptrace` is available. The proposed exploit scenario of quickly attaching to a process joining the container space and using its file descriptors is *not* possible under the default SELinux configuration. The containerized PID 1 will have a type of `container_t` or similar SELinux type and thus will be blocked by standard type enforcement from accessing accessing any resources that haven't already been made available to containerized processes.

Comment 12 Andrej Nemec 2017-01-11 08:58:12 UTC
Public via:

http://seclists.org/oss-sec/2017/q1/54

Comment 13 Trevor Jay 2017-01-11 15:27:11 UTC
Created runc tracking bugs for this issue:

Affects: fedora-all [bug 1412238]

Comment 15 Vincent Danen 2017-01-11 21:34:32 UTC
External References:

https://access.redhat.com/security/vulnerabilities/cve-2016-9962

Comment 16 errata-xmlrpc 2017-01-17 20:45:29 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7 Extras

Via RHSA-2017:0116 https://rhn.redhat.com/errata/RHSA-2017-0116.html

Comment 17 errata-xmlrpc 2017-01-17 20:47:16 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7 Extras

Via RHSA-2017:0123 https://rhn.redhat.com/errata/RHSA-2017-0123.html

Comment 18 errata-xmlrpc 2017-01-17 20:48:01 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7 Extras

Via RHSA-2017:0127 https://rhn.redhat.com/errata/RHSA-2017-0127.html

Comment 20 Jason Shepherd 2020-06-22 01:21:50 UTC
Mitigation:

On Red Hat systems with SELinux enabled, the dangers of even privileged containers are mitigated. SELinux prevents container processes from accessing host content even if those container processes manage to gain access to the actual file descriptors.

Comment 21 Jason Shepherd 2020-06-22 01:25:40 UTC
The impact of this vulnerability was upgraded to Important because the CAP_SYS_PTRACE capability is not required to exploit it, as previously thought.