CVE-2023-26472 (XML, published 2023-03-02T19:15Z)
Description: 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.
Severity: nan (CVSS v3 base score: 8.8)
Weakness: CWE-116 \u2014 Improper Encoding or Escaping of Output
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.
Repository: https://github.com/xwiki/xwiki-platform
Files changed:
xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-ui/src/main/resources/IconThemesCode/IconThemeSheet.xml
Commit message: XWIKI-19731: Fix escaping
* better fix (thanks @michitux for the warning)


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')
)))