CVE-2025-61682: Semantic MediaWiki vulnerable to stored XSS through wikitext via improper use of non-reserved data attributes
Summary The SemanticMediaWiki extension inserts the unsanitized value of a data attribute into the DOM as HTML, allowing for stored XSS through wikitext.
Details
In ext.smw.js, the data-subtab attribute of all elements with the smw-subtab class is parsed as JSON and appended to the innerHTML of the element: https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/62f1fa765b626e21d88999b97a3e8029db9fd385/res/smw/ext.smw.js#L37-L42 However, most data attributes (except for reserved ones) like data-subtab can be used in wikitext. Therefore, it is possible to insert arbitrary HTML and JS through wikitext. The decoded (" will turn to ", but it will be decoded when it is retrieved through .dataset) value of the data-subtab attribute in the payload is "<img src='' onerror=alert(1)>". This is valid JSON and returns a string with <img src='' onerror=alert(1)> when being decoded.
PoC
1. Create a page with the following contents: html {{#tag:div| |class=smw-subtab |data-subtab=""<img src='' onerror=alert(1)>"" }} 2. Visit the page
<img width="991" height="465" alt="image" src="https://github.com/user-attachments/assets/5d28d852-72d6-41dc-a59a-faac1610015f" /> <img width="497" height="69" alt="image" src="https://github.com/user-attachments/assets/02309390-0b40-46d9-b690-de8cd25dba59" />
Impact
Arbitrary HTML can be inserted into the DOM by any user with the edit right, allowing for JavaScript to be executed.
Other sources
Semantic MediaWiki is a free, open-source extension to MediaWiki that lets users store and query data within the wiki's pages. Versions starting in 3.1.0 and prior to 7.0.0 insert the unsanitized value of a data attribute into the DOM as HTML, allowing for stored XSS through wikitext. Version 7.0.0 patches the issue.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
composer/mediawiki/semantic-media-wikito a version that resolves this vulnerability.Fixed in 7.0.0 - Upgrade
Upgrade
Semantic MediaWikito a version that resolves this vulnerability.Fixed in 7.0.0
Event History
Frequently Asked Questions
What access does an attacker need to exploit this issue?
An attacker needs the ability to place wikitext on a page using an element with the smw-subtab class and a data-subtab attribute. The attribute value can contain JSON that decodes to attacker-controlled HTML and JavaScript.
Who is exposed when malicious content is present?
Users who visit a page containing the crafted wikitext may be exposed to stored cross-site scripting. The vulnerable client-side code parses data-subtab and appends its decoded value to the element’s innerHTML.
How can I look for potentially malicious content?
Review wiki pages and templates for elements using class="smw-subtab" together with a data-subtab attribute, particularly where the attribute contains encoded quotes, HTML tags, or JSON string values. The demonstrated payload uses the #tag parser function to create a div with these attributes.