Skip to content

Fix SMW query injection and XSS in ResourceDirectory templates#3

Open
tosfos wants to merge 1 commit intomasterfrom
fix-resource-directory-smw-injection-and-xss
Open

Fix SMW query injection and XSS in ResourceDirectory templates#3
tosfos wants to merge 1 commit intomasterfrom
fix-resource-directory-smw-injection-and-xss

Conversation

@tosfos
Copy link

@tosfos tosfos commented Feb 15, 2026

Summary

Addresses two security issues found during repo audit:

  1. SMW query injection – In Template/Resource filter.mediawiki and Template/Resource query.mediawiki, filter form values (Resource author, Resource type, Resource name, Resource category, Resource keyword, and custom list fields) are used in #ask conditions as [[prop::{{{@@@|}}}]] with only semicolon replacement (Resource filter) or no sanitization (Resource query). A value like x]] [[Category:Resources]] can break or manipulate the query. Fix: Strip ] [ | from all values when used inside SMW property conditions; escape link text and query params in sidebar/arrayprint blocks.

  2. XSS in link text and raw output – Multiple templates output user- or store-controlled data as link text or raw (Resource description, Authors, Resource author info, Resource type, Resource name, category/keyword links). Malicious content can execute script. Fix: Escape < and > to &lt; and &gt; in all link text and in raw output (description, author info, Authors); sanitize query params for ] [ | where used in queryformlink.

Dependency: ParserFunctions with $wgPFEnableStringFunctions = true added to requiredExtensions and README.

GitHub issues can be filed separately for each finding. Jira SLOP task(s) to be created and linked when Jira is available.

Audit: Repo audit workflow; work performed by AI / Cursor Agent.

- Resource filter & Resource query: sanitize filter form values (strip ], [, |) when used in #ask [[prop::value]] to prevent query injection; escape link text and query params for categories/keywords/custom lists
- Resource query result row: escape Resource type, Resource name, Resource description, and author link text for XSS; sanitize query params
- Resource & Resource authors: escape Authors, Resource description, Resource author, Resource author info and link text; sanitize query params in queryformlink
- Add ParserFunctions to requiredExtensions and README ($wgPFEnableStringFunctions = true)

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant