Xwiki · Xwiki Platform · CVE-2022-36097
**Name of the Vulnerable Software and Affected Versions**
XWiki Platform versions 14.0-rc-1 through 14.4-rc-1
**Description**
The issue allows storing JavaScript in an attachment name, which will be executed by anyone trying to move the corresponding attachment. For example, an attachment with name `><img src=1 onerror=alert(1)>.jpg` will execute the alert. This is possible due to the lack of proper sanitization of attachment names.
**Recommendations**
For versions 14.0-rc-1 through 14.4-rc-1, update to XWiki 14.4-rc-1 to resolve the issue.
As a temporary workaround for versions 14.0-rc-1 through 14.4-rc-1, copy `moveStep1.vm` to `webapp/xwiki/templates/moveStep1.vm` and replace the vulnerable code with the patched code, specifically replacing
```
#set($titleToDisplay = $services.localization.render('attachment.move.title',
[$attachment.name, $escapetool.xml($doc.plainTitle), $doc.getURL()]))
```
with
```
#set($titleToDisplay = $services.localization.render('attachment.move.title', [
$escapetool.xml($attachment.name),
$escapetool.xml($doc.plainTitle),
$escapetool.xml($doc.getURL())
]))
```