Activity log for bug #1452239

Date Who What changed Old value New value Message
2015-05-06 11:08:20 Marc Deslauriers bug added bug
2015-05-06 11:08:50 Marc Deslauriers cve linked 2015-1324
2015-05-06 11:58:26 Marc Deslauriers bug added subscriber Martin Pitt
2015-05-06 11:59:45 Martin Pitt nominated for series Ubuntu Trusty
2015-05-06 11:59:45 Martin Pitt bug task added apport (Ubuntu Trusty)
2015-05-06 11:59:45 Martin Pitt nominated for series Ubuntu Wily
2015-05-06 11:59:45 Martin Pitt bug task added apport (Ubuntu Wily)
2015-05-06 11:59:45 Martin Pitt nominated for series Ubuntu Utopic
2015-05-06 11:59:45 Martin Pitt bug task added apport (Ubuntu Utopic)
2015-05-06 12:00:08 Martin Pitt nominated for series Ubuntu Vivid
2015-05-06 12:00:08 Martin Pitt bug task added apport (Ubuntu Vivid)
2015-05-06 12:04:33 Martin Pitt bug task added apport
2015-05-06 12:04:38 Martin Pitt apport: status New In Progress
2015-05-06 12:04:40 Martin Pitt apport: importance Undecided High
2015-05-06 12:04:43 Martin Pitt apport: assignee Martin Pitt (pitti)
2015-05-06 12:06:49 Martin Pitt nominated for series Ubuntu Precise
2015-05-06 12:06:49 Martin Pitt bug task added apport (Ubuntu Precise)
2015-05-06 15:36:21 Martin Pitt attachment added patch for trunk (including test cases) https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4392277/+files/trunk.patch
2015-05-06 15:37:07 Martin Pitt apport (Ubuntu Wily): status New In Progress
2015-05-06 15:37:10 Martin Pitt apport (Ubuntu Wily): importance Undecided High
2015-05-07 09:51:59 Martin Pitt attachment removed patch for trunk (including test cases) https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4392277/+files/trunk.patch
2015-05-07 10:03:24 Martin Pitt attachment added patch for trunk (including test cases) https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4392884/+files/trunk.patch
2015-05-08 10:56:37 Martin Pitt attachment added debdiff for vivid https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4393586/+files/vivid.debdiff
2015-05-08 12:46:40 Martin Pitt attachment added debdiff for utopic https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4393632/+files/utopic.debdiff
2015-05-08 13:07:12 Martin Pitt attachment added debdiff for trusty https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4393639/+files/trusty.debdiff
2015-05-08 15:38:47 Martin Pitt attachment added debdiff for precise https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4393695/+files/precise.debdiff
2015-05-13 06:05:03 Martin Pitt description Sander Bos discovered that Apport enabled a user to perform a root escalation since it now configures fs.suid_dumpable=2. Here's a brief description of the issue: 1- A regular user can trigger a coredump with /proc/$PID/stat as root:root simply by doing chmod u-r 2- The root-owned coredump will them be written in the CWD, which in the PoC is /etc/logrotate.d 3- logrotate will gladly skip parts of the coredump it doesn't understand and will successfully run the parts it does I've requested a CRD of 2015-05-12 for the publication of this issue. I have assigned CVE-2015-1324 to this issue. We can either: 1- Disable fs.suid_dumpable=2 2- Stop creating core dump files when they are to be created as root 3- Create root-owned core dump files in a well-known location Sander Bos discovered that Apport enabled a user to perform a root escalation since it now configures fs.suid_dumpable=2. Here's a brief description of the issue: 1- A regular user can trigger a coredump with /proc/$PID/stat as root:root simply by doing chmod u-r 2- The root-owned coredump will them be written in the CWD, which in the PoC is /etc/logrotate.d 3- logrotate will gladly skip parts of the coredump it doesn't understand and will successfully run the parts it does I've set a CRD of 2015-05-21 (original proposal: 2015-05-12) for the publication of this issue. I have assigned CVE-2015-1324 to this issue. We can either: 1- Disable fs.suid_dumpable=2 2- Stop creating core dump files when they are to be created as root 3- Create root-owned core dump files in a well-known location
2015-05-13 09:19:48 Martin Pitt attachment removed patch for trunk (including test cases) https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4392884/+files/trunk.patch
2015-05-13 09:22:58 Martin Pitt attachment added patch for trunk (including test cases) https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4396666/+files/trunk.patch
2015-05-13 09:50:24 Martin Pitt attachment removed debdiff for vivid https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4393586/+files/vivid.debdiff
2015-05-13 09:51:22 Martin Pitt attachment added debdiff for vivid https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4396694/+files/vivid.debdiff
2015-05-13 10:00:14 Martin Pitt attachment removed debdiff for utopic https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4393632/+files/utopic.debdiff
2015-05-13 10:00:45 Martin Pitt attachment added debdiff for utopic https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4396695/+files/utopic.debdiff
2015-05-13 10:04:17 Martin Pitt attachment removed debdiff for trusty https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4393639/+files/trusty.debdiff
2015-05-13 10:04:41 Martin Pitt attachment added debdiff for trusty https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4396704/+files/trusty.debdiff
2015-05-13 11:59:31 Martin Pitt attachment removed debdiff for precise https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4393695/+files/precise.debdiff
2015-05-13 12:01:35 Martin Pitt cve linked 2015-1325
2015-05-13 12:01:35 Martin Pitt attachment added debdiff for precise https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1452239/+attachment/4396758/+files/precise.debdiff
2015-05-21 17:00:09 Launchpad Janitor apport (Ubuntu Utopic): status New Fix Released
2015-05-21 17:00:10 Launchpad Janitor apport (Ubuntu Precise): status New Fix Released
2015-05-21 17:00:20 Launchpad Janitor apport (Ubuntu Trusty): status New Fix Released
2015-05-21 17:01:39 Launchpad Janitor branch linked lp:~ubuntu-core-dev/ubuntu/precise/apport/ubuntu
2015-05-21 17:01:54 Launchpad Janitor branch linked lp:~ubuntu-core-dev/ubuntu/utopic/apport/ubuntu
2015-05-21 17:02:06 Launchpad Janitor branch linked lp:~ubuntu-core-dev/ubuntu/vivid/apport/ubuntu
2015-05-21 17:03:20 Martin Pitt apport (Ubuntu Wily): status In Progress Fix Committed
2015-05-21 17:03:36 Martin Pitt apport: status In Progress Fix Released
2015-05-21 17:04:19 Martin Pitt apport (Ubuntu Wily): assignee Martin Pitt (pitti)
2015-05-21 17:05:21 Launchpad Janitor apport (Ubuntu Vivid): status New Fix Released
2015-05-21 17:08:47 Marc Deslauriers information type Private Security Public Security
2015-05-21 20:22:21 Ubuntu Foundations Team Bug Bot tags patch
2015-05-22 04:36:23 Launchpad Janitor apport (Ubuntu Wily): status Fix Committed Fix Released
2015-05-22 19:59:40 Marc Deslauriers description Sander Bos discovered that Apport enabled a user to perform a root escalation since it now configures fs.suid_dumpable=2. Here's a brief description of the issue: 1- A regular user can trigger a coredump with /proc/$PID/stat as root:root simply by doing chmod u-r 2- The root-owned coredump will them be written in the CWD, which in the PoC is /etc/logrotate.d 3- logrotate will gladly skip parts of the coredump it doesn't understand and will successfully run the parts it does I've set a CRD of 2015-05-21 (original proposal: 2015-05-12) for the publication of this issue. I have assigned CVE-2015-1324 to this issue. We can either: 1- Disable fs.suid_dumpable=2 2- Stop creating core dump files when they are to be created as root 3- Create root-owned core dump files in a well-known location Sander Bos discovered that Apport enabled a user to perform a root escalation since it now configures fs.suid_dumpable=2. Here's a brief description of the issue: 1- A regular user can trigger a coredump with /proc/$PID/stat as root:root simply by doing chmod u-r 2- The root-owned coredump will them be written in the CWD, which in the PoC is /etc/logrotate.d 3- logrotate will gladly skip parts of the coredump it doesn't understand and will successfully run the parts it does I've set a CRD of 2015-05-21 (original proposal: 2015-05-12) for the publication of this issue. I have assigned CVE-2015-1324 to this issue. We can either: 1- Disable fs.suid_dumpable=2 2- Stop creating core dump files when they are to be created as root 3- Create root-owned core dump files in a well-known location ---------------- Here is the original report from Sander Bos (now with the CVE number included): OVERVIEW -------- Date: 2015-05-05 Bug name: SCORE: Simple Coredump-Oriented Root Exploit CVE: CVE-2015-1324 Author: Sander Bos Author's e-mail address: sbos _at_ sbosnet _dot_ nl SUMMARY ------- I found a combination of vulnerabilities to lead to privilege escalation (root exploitation) by local users in Ubuntu releases 12.04 up to and including 15.04. Depending on configuration, remote exploitation might be possible as well. Local exploitation can even be done as the local, passwordless LightDM "Guest" account user on systems supporting it -- indeed: from anonymous guest user to root. DESCRIPTION ----------- The Apport package creates user core dumps in the crashed process' CWD, and does so since Bazaar revision number 602 [1] / release 0.59. This is okay, but not always: there is a flaw in the fact that Apport also does this, as root, for tainted/protected binaries (setuid() and friends, capabilities(7) enabled binaries, non-readable binaries) when the sysctl(8)'s fs.suid_dumpable variable is set to 2 (see core(5)). This means that users can create core dumps as root, in arbitrary directories which are otherwise write-protected for those users. In short: Apport should _not_ create user core dumps in the CWD in dump mode 2 for such tainted binaries; it should either not make user core dumps at all then, or if possible use a designated and safe directory for that. All Ubuntu releases starting with 12.04 have the Apport service enabled by default [2] (and Ubuntu has Apport installed by default for much longer). All Ubuntu releases starting with 12.04 (or patched that way after their release) have sysctl(8)'s fs.suid_dumpable set to 2 by default, through the Apport package; see bug #1194541, "Create core dumps for setuid binaries", 2013-06-25 [3]. Along with solving that bug (that is, adding the "missing feature" of setuid core dumps), the patch to that bug report actually created a root exploit hole in the upcoming release 13.10, as well as being backported into the at that time supported Ubuntu releases 12.04, 12.10 and 13.04. The exact Apport package versions (with their Ubuntu releases) that were "patched" to have fs.suid_dumpable set to "2" are: 2.0.1-0ubuntu17.4 (Ubuntu 12.04) 2.6.1-0ubuntu12 (Ubuntu 12.10) 2.9.2-0ubuntu8.3 (Ubuntu 13.04) The value fs.suid_dumpable=2 remained in Ubuntu ever since. The exception to this is the systemd Apport script in Ubuntu 15.04: the option setting fs.suid_dumpable to "2" was forgotten to be enabled here, although in the Upstart script in Ubuntu 15.04 the option is still enabled. I recently contacted the Apport package maintainer to make sure the systemd script will not enable the option, as that would enable the root hole in 15.04 with systemd (which is the default init system) as well. Please note: 15.04 with systemd being safe regarding this vulnerabilty has nothing to do with systemd itself. Please note that even though Ubuntu has the value of fs.suid_dumpable set to 2 in releases 12.04 and later, Apport itself has been creating user coredumps (to CWD, and also with fs.suid_dumpable=2) since Ubuntu 7.04, which has Apport package release 0.76/0.76.1. Any system since Ubuntu 7.04 that has had fs.suid_dumpable set to 2, even though it wasn't Ubuntu's default, has been exploitable. Thus, the proof of concept attached will and should essentially work on any Ubuntu release starting with 7.04; it was in fact tested and found to be working on 7.04 itself, but later releases until 12.04 were not tested. VULNERABLE RELEASES ------------------- The proof of concept attached should work out of the box on (and is in fact tested to work on most of them) all of the following releases: 12.04 LTS 12.04.1 LTS 12.04.2 LTS 12.04.3 LTS 12.04.4 LTS 12.04.5 LTS 12.10 (EOL) 13.04 (EOL) 13.10 (EOL) 14.04 LTS 14.04.1 LTS 14.04.2 LTS 14.10 15.04 (only with Upstart, not systemd) Of all of the above releases all of the Server, Desktop and, where available, Alternate editions are affected. In other words: anything Ubuntu from the past three years is vulnerable, out of the box. All releases older than 12.04, starting with 7.04, are vulnerable as well in the sense that they have installed Apport by default or otherwise provide it as an installable package, being an Apport package which creates user core dumps (in CWD, also with fs.suid_dumpable=2); however, those releases do not have the Apport service enabled by default, nor do they have fs.suid_dumpable set to "2" by default. OTHER OSes / DISTRIBUTIONS / UBUNTU VERSIONS / DERIVATIVES ---------------------------------------------------------- Any OS / distribution with an Apport version creating a user core dump (meaning, the core dump created apart from the Apport report in /var/crash) in CWD is vulnerable. If fs.suid_dumpable=2 is the default, the OS is exploitable by default. This may or may not include Ubuntu derivatives, forks and Ubuntu based distributions like Ubuntu GNOME, Kubuntu, Ubuntu MATE, Ubuntu Studio, Edubuntu, Lubuntu, Mythbuntu, Xubuntu, Linux Mint (the Ubuntu based version), Peppermint, elementary OS, Bodhi Linux, BackBox, et cetera[5]. (As a quick test, at least BackBox 3.13 was found to be exploitable by default.) Further investigation will need to reveil what OSes / distributions / Ubuntu versions and derivatives are vulnerable, and which aren't. WORKAROUND ---------- Disable the Apport service. PROPOSED IMMEDIATE, TEMPORARY FIX --------------------------------- Disable suid_dumpable=2 in _all_ Ubuntu Apport packages; let it stay 0, which is the kernel's default. Thus, revert the damage done almost two years ago, e.g., by removing the lines echo 2 > /proc/sys/fs/suid_dumpable and echo 0 > /proc/sys/fs/suid_dumpable from the debian/apport.upstart files. Additionally, do _not_ enable fs.suid_dumpable=2 in the Apport systemd scripts for Ubuntu until a proper solution is implemented. PROPOSED LONG TERM FIX ---------------------- Apport should _never_ dump core to CWD with fs.suid_dumpable=2 for tainted/protected binaries (just like the kernel does not do this anymore[4]). If creating a user core dump at all, Apport should dump it to a safe, dedicated directory. Apport should use the kernel's "%d" kernel.core_pattern template specifier (see core(5)), which will present the dumpable state of the crashed process ("0", "1" or "2"). Please note though that the "%d" template is only available in (upstream) kernels >=3.7. REFERENCES ---------- [1] <http://bazaar.launchpad.net/~apport-hackers/apport/trunk/revision/602> [2] <https://wiki.ubuntu.com/Apport#How_to_enable_apport> [3] <https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1194541> [4] <https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=9520628e8ceb69fa9a4aee6b57f22675d9e1b709> [5] <https://en.wikipedia.org/wiki/List_of_Ubuntu-based_distributions#Ubuntu-based> CREDITS ------- The issue was found, analyzed, and reported to Ubuntu by Sander Bos, along with a detailed explanation of the problem, proposed workarounds and fixes, and an exploit proof of concept.
2015-06-05 11:06:33 Marc Deslauriers description Sander Bos discovered that Apport enabled a user to perform a root escalation since it now configures fs.suid_dumpable=2. Here's a brief description of the issue: 1- A regular user can trigger a coredump with /proc/$PID/stat as root:root simply by doing chmod u-r 2- The root-owned coredump will them be written in the CWD, which in the PoC is /etc/logrotate.d 3- logrotate will gladly skip parts of the coredump it doesn't understand and will successfully run the parts it does I've set a CRD of 2015-05-21 (original proposal: 2015-05-12) for the publication of this issue. I have assigned CVE-2015-1324 to this issue. We can either: 1- Disable fs.suid_dumpable=2 2- Stop creating core dump files when they are to be created as root 3- Create root-owned core dump files in a well-known location ---------------- Here is the original report from Sander Bos (now with the CVE number included): OVERVIEW -------- Date: 2015-05-05 Bug name: SCORE: Simple Coredump-Oriented Root Exploit CVE: CVE-2015-1324 Author: Sander Bos Author's e-mail address: sbos _at_ sbosnet _dot_ nl SUMMARY ------- I found a combination of vulnerabilities to lead to privilege escalation (root exploitation) by local users in Ubuntu releases 12.04 up to and including 15.04. Depending on configuration, remote exploitation might be possible as well. Local exploitation can even be done as the local, passwordless LightDM "Guest" account user on systems supporting it -- indeed: from anonymous guest user to root. DESCRIPTION ----------- The Apport package creates user core dumps in the crashed process' CWD, and does so since Bazaar revision number 602 [1] / release 0.59. This is okay, but not always: there is a flaw in the fact that Apport also does this, as root, for tainted/protected binaries (setuid() and friends, capabilities(7) enabled binaries, non-readable binaries) when the sysctl(8)'s fs.suid_dumpable variable is set to 2 (see core(5)). This means that users can create core dumps as root, in arbitrary directories which are otherwise write-protected for those users. In short: Apport should _not_ create user core dumps in the CWD in dump mode 2 for such tainted binaries; it should either not make user core dumps at all then, or if possible use a designated and safe directory for that. All Ubuntu releases starting with 12.04 have the Apport service enabled by default [2] (and Ubuntu has Apport installed by default for much longer). All Ubuntu releases starting with 12.04 (or patched that way after their release) have sysctl(8)'s fs.suid_dumpable set to 2 by default, through the Apport package; see bug #1194541, "Create core dumps for setuid binaries", 2013-06-25 [3]. Along with solving that bug (that is, adding the "missing feature" of setuid core dumps), the patch to that bug report actually created a root exploit hole in the upcoming release 13.10, as well as being backported into the at that time supported Ubuntu releases 12.04, 12.10 and 13.04. The exact Apport package versions (with their Ubuntu releases) that were "patched" to have fs.suid_dumpable set to "2" are: 2.0.1-0ubuntu17.4 (Ubuntu 12.04) 2.6.1-0ubuntu12 (Ubuntu 12.10) 2.9.2-0ubuntu8.3 (Ubuntu 13.04) The value fs.suid_dumpable=2 remained in Ubuntu ever since. The exception to this is the systemd Apport script in Ubuntu 15.04: the option setting fs.suid_dumpable to "2" was forgotten to be enabled here, although in the Upstart script in Ubuntu 15.04 the option is still enabled. I recently contacted the Apport package maintainer to make sure the systemd script will not enable the option, as that would enable the root hole in 15.04 with systemd (which is the default init system) as well. Please note: 15.04 with systemd being safe regarding this vulnerabilty has nothing to do with systemd itself. Please note that even though Ubuntu has the value of fs.suid_dumpable set to 2 in releases 12.04 and later, Apport itself has been creating user coredumps (to CWD, and also with fs.suid_dumpable=2) since Ubuntu 7.04, which has Apport package release 0.76/0.76.1. Any system since Ubuntu 7.04 that has had fs.suid_dumpable set to 2, even though it wasn't Ubuntu's default, has been exploitable. Thus, the proof of concept attached will and should essentially work on any Ubuntu release starting with 7.04; it was in fact tested and found to be working on 7.04 itself, but later releases until 12.04 were not tested. VULNERABLE RELEASES ------------------- The proof of concept attached should work out of the box on (and is in fact tested to work on most of them) all of the following releases: 12.04 LTS 12.04.1 LTS 12.04.2 LTS 12.04.3 LTS 12.04.4 LTS 12.04.5 LTS 12.10 (EOL) 13.04 (EOL) 13.10 (EOL) 14.04 LTS 14.04.1 LTS 14.04.2 LTS 14.10 15.04 (only with Upstart, not systemd) Of all of the above releases all of the Server, Desktop and, where available, Alternate editions are affected. In other words: anything Ubuntu from the past three years is vulnerable, out of the box. All releases older than 12.04, starting with 7.04, are vulnerable as well in the sense that they have installed Apport by default or otherwise provide it as an installable package, being an Apport package which creates user core dumps (in CWD, also with fs.suid_dumpable=2); however, those releases do not have the Apport service enabled by default, nor do they have fs.suid_dumpable set to "2" by default. OTHER OSes / DISTRIBUTIONS / UBUNTU VERSIONS / DERIVATIVES ---------------------------------------------------------- Any OS / distribution with an Apport version creating a user core dump (meaning, the core dump created apart from the Apport report in /var/crash) in CWD is vulnerable. If fs.suid_dumpable=2 is the default, the OS is exploitable by default. This may or may not include Ubuntu derivatives, forks and Ubuntu based distributions like Ubuntu GNOME, Kubuntu, Ubuntu MATE, Ubuntu Studio, Edubuntu, Lubuntu, Mythbuntu, Xubuntu, Linux Mint (the Ubuntu based version), Peppermint, elementary OS, Bodhi Linux, BackBox, et cetera[5]. (As a quick test, at least BackBox 3.13 was found to be exploitable by default.) Further investigation will need to reveil what OSes / distributions / Ubuntu versions and derivatives are vulnerable, and which aren't. WORKAROUND ---------- Disable the Apport service. PROPOSED IMMEDIATE, TEMPORARY FIX --------------------------------- Disable suid_dumpable=2 in _all_ Ubuntu Apport packages; let it stay 0, which is the kernel's default. Thus, revert the damage done almost two years ago, e.g., by removing the lines echo 2 > /proc/sys/fs/suid_dumpable and echo 0 > /proc/sys/fs/suid_dumpable from the debian/apport.upstart files. Additionally, do _not_ enable fs.suid_dumpable=2 in the Apport systemd scripts for Ubuntu until a proper solution is implemented. PROPOSED LONG TERM FIX ---------------------- Apport should _never_ dump core to CWD with fs.suid_dumpable=2 for tainted/protected binaries (just like the kernel does not do this anymore[4]). If creating a user core dump at all, Apport should dump it to a safe, dedicated directory. Apport should use the kernel's "%d" kernel.core_pattern template specifier (see core(5)), which will present the dumpable state of the crashed process ("0", "1" or "2"). Please note though that the "%d" template is only available in (upstream) kernels >=3.7. REFERENCES ---------- [1] <http://bazaar.launchpad.net/~apport-hackers/apport/trunk/revision/602> [2] <https://wiki.ubuntu.com/Apport#How_to_enable_apport> [3] <https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1194541> [4] <https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=9520628e8ceb69fa9a4aee6b57f22675d9e1b709> [5] <https://en.wikipedia.org/wiki/List_of_Ubuntu-based_distributions#Ubuntu-based> CREDITS ------- The issue was found, analyzed, and reported to Ubuntu by Sander Bos, along with a detailed explanation of the problem, proposed workarounds and fixes, and an exploit proof of concept. Sander Bos discovered that Apport enabled a user to perform a root escalation since it now configures fs.suid_dumpable=2. Here's a brief description of the issue: 1- A regular user can trigger a coredump with /proc/$PID/stat as root:root simply by doing chmod u-r 2- The root-owned coredump will then be written in the CWD, which in the PoC is /etc/logrotate.d 3- logrotate will gladly skip parts of the coredump it doesn't understand and will successfully run the parts it does I've set a CRD of 2015-05-21 (original proposal: 2015-05-12) for the publication of this issue. I have assigned CVE-2015-1324 to this issue. We can either: 1- Disable fs.suid_dumpable=2 2- Stop creating core dump files when they are to be created as root 3- Create root-owned core dump files in a well-known location ---------------- Here is the original report from Sander Bos (now with the CVE number included): OVERVIEW -------- Date: 2015-05-05 Bug name: SCORE: Simple Coredump-Oriented Root Exploit CVE: CVE-2015-1324 Author: Sander Bos Author's e-mail address: sbos _at_ sbosnet _dot_ nl SUMMARY ------- I found a combination of vulnerabilities to lead to privilege escalation (root exploitation) by local users in Ubuntu releases 12.04 up to and including 15.04. Depending on configuration, remote exploitation might be possible as well. Local exploitation can even be done as the local, passwordless LightDM "Guest" account user on systems supporting it -- indeed: from anonymous guest user to root. DESCRIPTION ----------- The Apport package creates user core dumps in the crashed process' CWD, and does so since Bazaar revision number 602 [1] / release 0.59. This is okay, but not always: there is a flaw in the fact that Apport also does this, as root, for tainted/protected binaries (setuid() and friends, capabilities(7) enabled binaries, non-readable binaries) when the sysctl(8)'s fs.suid_dumpable variable is set to 2 (see core(5)). This means that users can create core dumps as root, in arbitrary directories which are otherwise write-protected for those users. In short: Apport should _not_ create user core dumps in the CWD in dump mode 2 for such tainted binaries; it should either not make user core dumps at all then, or if possible use a designated and safe directory for that. All Ubuntu releases starting with 12.04 have the Apport service enabled by default [2] (and Ubuntu has Apport installed by default for much longer). All Ubuntu releases starting with 12.04 (or patched that way after their release) have sysctl(8)'s fs.suid_dumpable set to 2 by default, through the Apport package; see bug #1194541, "Create core dumps for setuid binaries", 2013-06-25 [3]. Along with solving that bug (that is, adding the "missing feature" of setuid core dumps), the patch to that bug report actually created a root exploit hole in the upcoming release 13.10, as well as being backported into the at that time supported Ubuntu releases 12.04, 12.10 and 13.04. The exact Apport package versions (with their Ubuntu releases) that were "patched" to have fs.suid_dumpable set to "2" are: 2.0.1-0ubuntu17.4 (Ubuntu 12.04) 2.6.1-0ubuntu12 (Ubuntu 12.10) 2.9.2-0ubuntu8.3 (Ubuntu 13.04) The value fs.suid_dumpable=2 remained in Ubuntu ever since. The exception to this is the systemd Apport script in Ubuntu 15.04: the option setting fs.suid_dumpable to "2" was forgotten to be enabled here, although in the Upstart script in Ubuntu 15.04 the option is still enabled. I recently contacted the Apport package maintainer to make sure the systemd script will not enable the option, as that would enable the root hole in 15.04 with systemd (which is the default init system) as well. Please note: 15.04 with systemd being safe regarding this vulnerabilty has nothing to do with systemd itself. Please note that even though Ubuntu has the value of fs.suid_dumpable set to 2 in releases 12.04 and later, Apport itself has been creating user coredumps (to CWD, and also with fs.suid_dumpable=2) since Ubuntu 7.04, which has Apport package release 0.76/0.76.1. Any system since Ubuntu 7.04 that has had fs.suid_dumpable set to 2, even though it wasn't Ubuntu's default, has been exploitable. Thus, the proof of concept attached will and should essentially work on any Ubuntu release starting with 7.04; it was in fact tested and found to be working on 7.04 itself, but later releases until 12.04 were not tested. VULNERABLE RELEASES ------------------- The proof of concept attached should work out of the box on (and is in fact tested to work on most of them) all of the following releases: 12.04 LTS 12.04.1 LTS 12.04.2 LTS 12.04.3 LTS 12.04.4 LTS 12.04.5 LTS 12.10 (EOL) 13.04 (EOL) 13.10 (EOL) 14.04 LTS 14.04.1 LTS 14.04.2 LTS 14.10 15.04 (only with Upstart, not systemd) Of all of the above releases all of the Server, Desktop and, where available, Alternate editions are affected. In other words: anything Ubuntu from the past three years is vulnerable, out of the box. All releases older than 12.04, starting with 7.04, are vulnerable as well in the sense that they have installed Apport by default or otherwise provide it as an installable package, being an Apport package which creates user core dumps (in CWD, also with fs.suid_dumpable=2); however, those releases do not have the Apport service enabled by default, nor do they have fs.suid_dumpable set to "2" by default. OTHER OSes / DISTRIBUTIONS / UBUNTU VERSIONS / DERIVATIVES ---------------------------------------------------------- Any OS / distribution with an Apport version creating a user core dump (meaning, the core dump created apart from the Apport report in /var/crash) in CWD is vulnerable. If fs.suid_dumpable=2 is the default, the OS is exploitable by default. This may or may not include Ubuntu derivatives, forks and Ubuntu based distributions like Ubuntu GNOME, Kubuntu, Ubuntu MATE, Ubuntu Studio, Edubuntu, Lubuntu, Mythbuntu, Xubuntu, Linux Mint (the Ubuntu based version), Peppermint, elementary OS, Bodhi Linux, BackBox, et cetera[5]. (As a quick test, at least BackBox 3.13 was found to be exploitable by default.) Further investigation will need to reveil what OSes / distributions / Ubuntu versions and derivatives are vulnerable, and which aren't. WORKAROUND ---------- Disable the Apport service. PROPOSED IMMEDIATE, TEMPORARY FIX --------------------------------- Disable suid_dumpable=2 in _all_ Ubuntu Apport packages; let it stay 0, which is the kernel's default. Thus, revert the damage done almost two years ago, e.g., by removing the lines         echo 2 > /proc/sys/fs/suid_dumpable and         echo 0 > /proc/sys/fs/suid_dumpable from the debian/apport.upstart files. Additionally, do _not_ enable fs.suid_dumpable=2 in the Apport systemd scripts for Ubuntu until a proper solution is implemented. PROPOSED LONG TERM FIX ---------------------- Apport should _never_ dump core to CWD with fs.suid_dumpable=2 for tainted/protected binaries (just like the kernel does not do this anymore[4]). If creating a user core dump at all, Apport should dump it to a safe, dedicated directory. Apport should use the kernel's "%d" kernel.core_pattern template specifier (see core(5)), which will present the dumpable state of the crashed process ("0", "1" or "2"). Please note though that the "%d" template is only available in (upstream) kernels >=3.7. REFERENCES ---------- [1] <http://bazaar.launchpad.net/~apport-hackers/apport/trunk/revision/602> [2] <https://wiki.ubuntu.com/Apport#How_to_enable_apport> [3] <https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1194541> [4] <https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=9520628e8ceb69fa9a4aee6b57f22675d9e1b709> [5] <https://en.wikipedia.org/wiki/List_of_Ubuntu-based_distributions#Ubuntu-based> CREDITS ------- The issue was found, analyzed, and reported to Ubuntu by Sander Bos, along with a detailed explanation of the problem, proposed workarounds and fixes, and an exploit proof of concept.