CVE-2023-26472: Improper Encoding or Escaping of Output (CWE-116)
value: XWiki Platform is a generic wiki platform. Starting in version 6.2-milestone-1, one can execute any wiki content with the right of IconThemeSheet author by creating an icon theme with certain content. This can be done by creating a new page or even through the user profile for users not having edit right. The issue has been patched in XWiki 14.9, 14.4.6, and 13.10.10. An available workaround is to fix the bug in the page `IconThemesCode.IconThemeSheet` by applying a modification from commit 48caf7491595238af2b531026a614221d5d61f38.
CWE description: The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved.
CVSS v3 base score: 8.8
Published: 2023-03-02T19:15Z
Repository: https://github.com/xwiki/xwiki-platform
Language: XML
Files changed: xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-ui/src/main/resources/IconThemesCode/IconThemeSheet.xml
Commit date: 2022-10-20 18:01:04 +0200
Commit message: XWIKI-19731: Fix escaping
* better fix (thanks @michitux for the warning)

Diff: diff --git a/xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-test/xwiki-platform-icon-test-docker/src/test/it/org/xwiki/icon/test/ui/IconThemesSheetIT.java b/xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-test/xwiki-platform-icon-test-docker/src/test/it/org/xwiki/icon/test/ui/IconThemesSheetIT.java
deleted file mode 100644
index 4334887bc8730..0000000000000
--- a/xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-test/xwiki-platform-icon-test-docker/src/test/it/org/xwiki/icon/test/ui/IconThemesSheetIT.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * See the NOTICE file distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.xwiki.icon.test.ui;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Order;
-import org.junit.jupiter.api.Test;
-import org.openqa.selenium.By;
-import org.xwiki.test.docker.junit5.TestReference;
-import org.xwiki.test.docker.junit5.UITest;
-import org.xwiki.test.ui.TestUtils;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-/**
- * Functional tests of the icon theme sheet.
- *
- * @version $Id$
- */
-@UITest
-class IconThemesSheetIT
-{
-    @BeforeEach
-    void setUp(TestUtils testUtils)
-    {
-        // Login as superadmin to define the preferences. 
-        testUtils.loginAsSuperAdmin();
-    }
-
-    @Test
-    @Order(1)
-    void createIconTheme(TestUtils testUtils, TestReference testReference) throws Exception
-    {
-        testUtils.createPage(testReference, ")))**not bold**");
-        testUtils.addObject(testReference, "IconThemesCode.IconThemeClass");
-
-        testUtils.gotoPage(testReference);
-
-        String content = testUtils.getDriver().findElementWithoutWaiting(By.id("xwikicontent")).getText();
-
-        // Make sure the wiki syntax was not interpreted
-        assertTrue(content.contains("**not bold**"));
-    }
-}
diff --git a/xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-ui/src/main/resources/IconThemesCode/IconThemeSheet.xml b/xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-ui/src/main/resources/IconThemesCode/IconThemeSheet.xml
index 1456cf7a45779..8c4cd4116df72 100644
--- a/xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-ui/src/main/resources/IconThemesCode/IconThemeSheet.xml
+++ b/xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-ui/src/main/resources/IconThemesCode/IconThemeSheet.xml
@@ -40,14 +40,13 @@
 #if($doc.fullName != 'IconThemesCode.IconThemeSheet')
 {{info}}
 This document is an Icon Theme.
 {{/info}}
 
-
-{{{
-$doc.content.replace('}}}', '~}}}')
-}}}
+(%class="code"%)(((
+$services.rendering.escape($doc.content, 'xwiki/2.1')
+)))
 #else
 Sheet of [[IconThemesCode.IconThemeClass]]
 #end
 {{/velocity}}</content>
   <object>

Vulnerable code: /*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.icon.test.ui;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.xwiki.test.docker.junit5.TestReference;
import org.xwiki.test.docker.junit5.UITest;
import org.xwiki.test.ui.TestUtils;

import static org.junit.jupiter.api.Assertions.assertTrue;

/**
 * Functional tests of the icon theme sheet.
 *
 * @version $Id$
 */
@UITest
class IconThemesSheetIT
{
    @BeforeEach
    void setUp(TestUtils testUtils)
    {
        // Login as superadmin to define the preferences. 
        testUtils.loginAsSuperAdmin();
    }

    @Test
    @Order(1)
    void createIconTheme(TestUtils testUtils, TestReference testReference) throws Exception
    {
        testUtils.createPage(testReference, ")))**not bold**");
        testUtils.addObject(testReference, "IconThemesCode.IconThemeClass");

        testUtils.gotoPage(testReference);

        String content = testUtils.getDriver().findElementWithoutWaiting(By.id("xwikicontent")).getText();

        // Make sure the wiki syntax was not interpreted
        assertTrue(content.contains("**not bold**"));
    }
}

{{{
$doc.content.replace('}}}', '~}}}')
}}}
Fixed code: (%class="code"%)(((
$services.rendering.escape($doc.content, 'xwiki/2.1')
)))