Summary
Semantic MediaWiki contains a stored cross-site scripting vulnerability caused by inserting an unsanitized data attribute into the page DOM as HTML. An attacker who can place crafted wikitext in a wiki page may cause malicious script content to execute when other users view the affected page.
Affected context
The issue affects Semantic MediaWiki deployments using versions in the affected release range where data attributes from wikitext are rendered as HTML without adequate output encoding. Risk depends on whether an attacker can create or modify relevant wiki content and whether other users, including privileged administrators, view the resulting page.
Exploit preconditions
- Attack surface: Wiki page rendering and DOM insertion
- Required access: Permission to create or edit content containing the relevant data attribute
- Trigger point: A victim views the stored page through the affected rendering path
- Why exploitation is possible: User-controlled attribute content is inserted into the DOM as HTML without sufficient context-aware sanitization or encoding
Why this happens
The vulnerability results from treating user-controlled wikitext data as trusted HTML during page rendering. When an unsanitized attribute value is inserted into the DOM, markup or script-bearing content can be interpreted by the browser rather than displayed as inert text. This maps to CWE-79: Improper Neutralization of Input During Web Page Generation, commonly known as cross-site scripting.
Potential impact
- Malicious script may execute in a victim's browser under the wiki's origin
- An attacker could access page content available to the victim
- User actions could be performed through the victim's authenticated session
- Privileged users could be targeted for administrative or content-integrity impact
- Wiki pages or stored data could be altered or abused for phishing
General mitigation guidance
Mitigation generally focuses on ensuring that user-controlled values remain data throughout rendering.
Common defensive patterns include:
- Applying context-aware output encoding before inserting values into HTML or the DOM
- Using safe DOM text APIs instead of HTML interpretation APIs when markup is not required
- Restricting and validating data attributes against an explicit schema and allowed-value set
- Applying narrowly scoped HTML sanitization when trusted markup is an actual requirement
- Enforcing a restrictive Content Security Policy as a defense-in-depth control
- Limiting page-editing privileges and using least-privilege access policies
- Including security regression tests for stored content and privileged-user viewing paths
How teams detect issues like this
Detection can combine source review, automated analysis, and runtime testing:
- Search for user-controlled wikitext or attribute values passed to HTML construction or DOM HTML insertion APIs
- Review template, parser, and renderer code for missing context-aware encoding
- Use static analysis rules that flag direct interpolation into HTML and unsafe DOM sinks
- Test stored-content flows with benign markup and script-context markers in isolated environments
- Monitor content changes and rendered responses for unexpected HTML or script-bearing elements
- Enforce code-review and CI policies requiring approved encoding and sanitization utilities

