# CVE-2023-36471: HTML sanitizer allows form elements in restricted in org.xwiki.commons:xwiki-commons-xml

> An HTML sanitizer flaw in XWiki commons allows attackers to inject form elements, potentially leading to remote code execution or phishing when an admin submits the crafted form.

- **Severity:** Critical 9.1 (`CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 29 Jun 2023
- **Updated:** 26 Nov 2024
- **Also known as:** GHSA-6pqf-c99p-758v

## What is CVE-2023-36471?

CVE-2023-36471 is a critical cross-site scripting vulnerability in xwiki-commons, published on 29 Jun 2023. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official description

Xwiki commons is the common modules used by other XWiki top level projects. The HTML sanitizer that is included in XWiki since version 14.6RC1 allowed form and input HTML tags. In the context of XWiki, this allows an attacker without script right to either create forms that can be used for phishing attacks or also in the context of a sheet, the attacker could add an input like `{{html}}<input type="hidden" name="content" value="{{groovy}}println(&quot;Hello from Groovy!&quot;)" />{{/html}}` that would allow remote code execution when it is submitted by an admin (the sheet is rendered as part of the edit form). The attacker would need to ensure that the edit form looks plausible, though, which can be non-trivial as without script right the attacker cannot display the regular content of the document. This has been patched in XWiki 14.10.6 and 15.2RC1 by removing the central form-related tags from the list of allowed tags. Users are advised to upgrade. As a workaround an admin can manually disallow the tags by adding `form, input, select, textarea, button` to the configuration option `xml.htmlElementSanitizer.forbidTags` in the `xwiki.properties` configuration file.

Weakness: CWE-79 (Improper Neutralization of Input During Web Page Generation), CWE-74 (Improper Neutralization of Special Elements in Output Used by a Downstream Component)

## Which versions are affected by CVE-2023-36471?

4 open source packages ship an affected version, including org.xwiki.commons:xwiki-commons-xml. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `org.xwiki.commons:xwiki-commons-xml` | Maven | From 14.6-rc-1 | 14.10.6 |
| `org.xwiki.commons:xwiki-commons-xml` | Maven | From 14.6-rc-1 | 14.10.6 |
| `org.xwiki.commons:xwiki-commons-xml` | Maven | From 15.0-rc-1 | 15.2-rc-1 |
| `org.xwiki.commons:xwiki-commons-xml` | Maven | From 15.0-rc-1 | 15.2-rc-1 |

Products: Xwiki Commons.

## How do I fix CVE-2023-36471?

Upgrade org.xwiki.commons:xwiki-commons-xml to a fixed version for your release line: 14.10.6 or 15.2-rc-1.

## Is CVE-2023-36471 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-36471 exists.

Public exploit code:

- https://github.com/shoucheng3/xwiki__xwiki-commons_CVE-2023-36471_14-10-5 (github_poc): https://github.com/shoucheng3/xwiki__xwiki-commons_CVE-2023-36471_14-10-5

## Other vulnerabilities in xwiki-commons

- [CVE-2023-26055](https://insights.sbomify.com/CVE-2023-26055/): XWiki Commons may allow privilege escalation to programming rights via user's first name (critical 10.0)
- [CVE-2023-29528](https://insights.sbomify.com/CVE-2023-29528/): Cross-site Scripting in org.xwiki.commons:xwiki-commons-xml (critical 9.1)
- [CVE-2022-24898](https://insights.sbomify.com/CVE-2022-24898/): Arbitrary file access through XML parsing in org.xwiki.commons:xwiki-commons-xml (medium 4.9)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-36471 and fix it if it is affected.

What it is: CVE-2023-36471 is a critical cross-site scripting vulnerability in xwiki-commons, published on 29 Jun 2023. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-36471 exists.

Affected packages and fixed versions:
- org.xwiki.commons:xwiki-commons-xml (Maven): affected from 14.6-rc-1; fixed in 14.10.6
- org.xwiki.commons:xwiki-commons-xml (Maven): affected from 14.6-rc-1; fixed in 14.10.6
- org.xwiki.commons:xwiki-commons-xml (Maven): affected from 15.0-rc-1; fixed in 15.2-rc-1
- org.xwiki.commons:xwiki-commons-xml (Maven): affected from 15.0-rc-1; fixed in 15.2-rc-1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-36471/ (Markdown: https://insights.sbomify.com/CVE-2023-36471/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-36471
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-36471
- OSV: https://osv.dev/vulnerability/CVE-2023-36471

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-36471/
Summaries are generated and may contain mistakes; the official description above is the record.
