CVE-2022-23622: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (CWE-79)
value: XWiki Platform is a generic wiki platform offering runtime services for applications built on top of it. In affected versions there is a cross site scripting (XSS) vector in the `registerinline.vm` template related to the `xredirect` hidden field. This template is only used in the following conditions: 1. The wiki must be open to registration for anyone. 2. The wiki must be closed to view for Guest users or more specifically the XWiki.Registration page must be forbidden in View for guest user. A way to obtain the second condition is when administrators checked the "Prevent unregistered users from viewing pages, regardless of the page rights" box in the administration rights. This issue is patched in versions 12.10.11, 14.0-rc-1, 13.4.7, 13.10.3. There are two main ways for protecting against this vulnerability, the easiest and the best one is by applying a patch in the `registerinline.vm` template, the patch consists in checking the value of the xredirect field to ensure it matches: `<input type="hidden" name="xredirect" value="$escapetool.xml($!request.xredirect)" />`. If for some reason it's not possible to patch this file, another workaround is to ensure "Prevent unregistered users from viewing pages, regardless of the page rights" is not checked in the rights and apply a better right scheme using groups and rights on spaces.
CWE description: The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
CVSS v3 base score: 6.1
Published: 2022-02-09T22:15Z
Repository: https://github.com/xwiki/xwiki-platform
Language: Other
Files changed: xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/registerinline.vm
Commit date: 2022-01-04 11:11:05 +0100
Commit message: XWIKI-19291: redirect parameter is badly handled in register page

  * Fix the typo

Diff: diff --git a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/registerinline.vm b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/registerinline.vm
index 2657b2cddf5a..b25f72f1e166 100644
--- a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/registerinline.vm
+++ b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/registerinline.vm
@@ -43,11 +43,11 @@
   #if (!$reg || $reg < 0)
     <form id="register" action="" method="post" class="xform third">
       <div>
         <input type="hidden" name="form_token" value="$!services.csrf.token" />
         <input type="hidden" name="register" value="1" />
-        <input type="hidden" name="xredirect" value="$!request.xredirect" />
+        <input type="hidden" name="xredirect" value="$escapetool.xml($!request.xredirect)" />
         #set ($class = $xwiki.getClass('XWiki.XWikiUsers'))
         #set ($obj = $class.newObject())
         #set ($serverobj = $class.newObject())
         #set ($discard = $doc.use('XWiki.XWikiUsers'))
         #if ($request.register_first_name)

Vulnerable code:         <input type="hidden" name="xredirect" value="$!request.xredirect" />
Fixed code:         <input type="hidden" name="xredirect" value="$escapetool.xml($!request.xredirect)" />