GHSA-wphc-5f2j-jhvg: Unauthenticated DOM Based XSS in YesWiki
Unauthenticated DOM Based XSS in YesWiki <= 4.4.5SummaryIt is possible for any end-user to craft a DOM based XSS on all of YesWiki's pages which will be triggered when a user clicks on a malicious link.This Proof of Concept has been performed using the followings:YesWiki v4.4.5 (`doryphore-dev` branch, latest)Docker environnment (`docker/docker-compose.yml`)Docker v27.5.0Default installationDetailsThe vulnerability makes use of the search by tag feature. When a tag doesn't exist, the tag is reflected on the page and isn't properly sanitized on the server side which allows a malicious user to generate a link that will trigger an XSS on the client's side when clicked.This part of the code is managed by `tools/tags/handlers/page/listpages.php`, and **[this piece of code](https://github.com/YesWiki/yeswiki/blob/doryphore-dev/tools/tags/handlers/page/listpages.php#L84)** is responsible for the vulnerability:The tag names aren't properly sanitized when adding them to the page's response, thus when a tag name is user controlled, it allows client side code execution. This case describes a case where the tag name doesn't exist, but if an admin creates a malicious tag, it will also end up in XSS when rendered.PoC1. Simple XSSAbusing the `tags` parameter, we can successfully obtain client side javascript execution:![poc1](https://github.com/user-attachments/assets/cfd59dd6-ebda-4587-b903-d2777fc7d780)2. Full account takeover scenarioBy changing the payload of the XSS it was possible to establish a full acount takeover through a weak password recovery mechanism abuse ([CWE-460](https://cwe.mitre.org/data/definitions/640.html)). The following exploitation script allows an attacker to extract the password reset link of every logged in user that is triggered by the XSS:Hosting this script on a listener, when an admin is tricked into clicking on a maliciously crafted link, we can then reset its password and takeover their account.![poc2](https://github.com/user-attachments/assets/02884697-f0a5-43df-8bab-d83f8c9a102d)
![poc3](https://github.com/user-attachments/assets/ef5b44f1-97bb-4cf1-a32b-471f8c672ebd)
![poc4](https://github.com/user-attachments/assets/6a0193a2-1a01-4c65-bd97-f7c900f7f174)ImpactThis vulnerability allows any user to generate a malicious link that will trigger an account takeover when clicked, therefore allowing a user to steal other accounts, modify pages, comments, permissions, extract user data (emails), thus impacting the integrity, availabilty and confidentiality of a YesWiki instance.Suggestion of possible corrective measuresSanitize properly the tag names when created [here](https://github.com/YesWiki/yeswiki/blob/doryphore-dev/tools/tags/services/TagsManager.php#L60)Sanitize the tag names when looked for [here](https://github.com/YesWiki/yeswiki/blob/doryphore-dev/tools/tags/handlers/page/listpages.php#L15)Implement a stronger password reset mechanism through:Not showing a password reset link to an already logged-in user.Generating a password reset link when a reset is requested by a user, and only send it by mail.Add an expiration/due date to the tokenImplement a strong Content Security Policy to mitigate other XSS sinks (preferably using a random nonce)The latter idea is expensive to develop/implement, but given the number of likely sinks allowing Cross Site Scripting in the YesWiki source code, it seems necessary and easier than seeking for any improperly sanitized user input.
CVSS v3.1: 7.6