Page MenuHomePhabricator

CommentParser::doWikiLinks should be able to operate safely on safe HTML
Open, MediumPublicSecurity

Description

Filing as a security task since none of the three other tasks are public yet.

CommentParser::doWikiLinks currently uses a regex pattern to find and replace wikilink syntax with HTML links. Because of this, it is/was possible to perform XSS in three cases by getting CommentParser::doSectionLinks to return HTML that would be safe on its own, but is not safe for usage in doWikiLinks:

In the last two cases, the "unsafe" HTML was produced by the MW parser. As a developer without knowledge of the internal working of CommentParser, I would probably expect parsed HTML to be safe for usage in any HTML sink, but $comment in the FormatAutocomments hook (or specifically doWikiLinks) is not a safe HTML sink.
To reduce the likelihood of similar vulnerabilities being introduced in the future, I think that CommentParser::doWikiLinks should be hardened so it can operate on any safe HTML string without allowing for XSS. This would have prevented all three aforementioned vulnerabilities.

Details

Risk Rating
Medium
Author Affiliation
Wikimedia Communities

Event Timeline

sbassett subscribed.

With the three issues mentioned above being fixed, individually, leaving this to Content-Transform-Team et al as a future code-hardening effort.

All three vulnerabilities are now publicly fixed and only the core task isn't public yet. @sbassett could this one be made public?

sbassett triaged this task as Medium priority.
sbassett changed Author Affiliation from N/A to Wikimedia Communities.
sbassett changed the visibility from "Custom Policy" to "Public (No Login Required)".
sbassett changed the edit policy from "Custom Policy" to "All Users".
sbassett changed Risk Rating from N/A to Medium.

(reopening since this is a code hardening task and not resolved yet)