CVE-2023-35157 (Java, published 2023-06-23T19:15Z)
Description: value: XWiki Platform is a generic wiki platform offering runtime services for applications built on top of it. It's possible to perform an XSS by forging a request to a delete attachment action with a specific attachment name. Now this XSS can be exploited only if the attacker knows the CSRF token of the user, or if the user ignores the warning about the missing CSRF token. The vulnerability has been patched in XWiki 15.1-rc-1 and XWiki 14.10.6.
Severity: nan (CVSS v3 base score: 4.8)
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
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.
Repository: https://github.com/xwiki/xwiki-platform
Files changed:
xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-test/xwiki-platform-flamingo-skin-test-docker/src/test/it/org/xwiki/flamingo/test/docker/AttachmentIT.java
xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiAction.java
xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-ui/src/main/java/org/xwiki/test/ui/TestUtils.java
xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-ui/src/main/java/org/xwiki/test/ui/po/BasePage.java
Commit message: XWIKI-20339: Attachments name are not properly displayed with special characters

  * Ensure to properly escape translations
  * Provide a new integration test for it


Vulnerable code:
        return StringUtils.defaultString(getLocalization().getTranslationPlain(key, parameters), key);
        if (reference.getType() == EntityType.DOCUMENT) {

Fixed code:
import org.xwiki.model.reference.AttachmentReference;
import org.xwiki.test.ui.po.BasePage;
    /**
     * Check the display of delete attachment message when it contains special characters.
     */
    @Test
    @Order(8)
    void deleteAttachmentWithSpecialChar(TestUtils setup, TestReference testReference)
    {
        setup.loginAsSuperAdmin();
        setup.createPage(testReference, "Empty content");
        String attachmentName = "<img src=x>";
        AttachmentReference attachmentReference = new AttachmentReference(attachmentName, testReference);
        setup.gotoPage(attachmentReference, "delattachment");
        BasePage basePage = new BasePage();
        assertEquals(String.format("Error\n"
                + "Failed to delete attachment %s\n"
                + "This attachment does not exist.", attachmentName),
                basePage.getXWikiMessageContent());
    }

import org.xwiki.xml.XMLUtils;
        return XMLUtils.escape(StringUtils.defaultString(getLocalization().getTranslationPlain(key, parameters), key));
        if (reference.getType() == EntityType.DOCUMENT || reference.getType() == EntityType.ATTACHMENT) {
    /**
     * @return the full text of an {@code xwikimessage} box displayed in the full content (e.g. in case of error).
     * @since 15.1RC1
     * @since 14.10.6
     */
    public String getXWikiMessageContent()
    {
        return getDriver()
            .findElementWithoutWaiting(By.xpath("//div[@id = 'mainContentArea']/div[contains(@class, 'xwikimessage')]"))
            .getText();
    }