Fix SMW query injection and XSS in ResourceDirectory templates#3
Open
Fix SMW query injection and XSS in ResourceDirectory templates#3
Conversation
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses two security issues found during repo audit:
SMW query injection – In
Template/Resource filter.mediawikiandTemplate/Resource query.mediawiki, filter form values (Resource author, Resource type, Resource name, Resource category, Resource keyword, and custom list fields) are used in#askconditions as[[prop::{{{@@@|}}}]]with only semicolon replacement (Resource filter) or no sanitization (Resource query). A value likex]] [[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.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<and>in all link text and in raw output (description, author info, Authors); sanitize query params for ] [ | where used in queryformlink.Dependency: ParserFunctions with
$wgPFEnableStringFunctions = trueadded 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.