Steps to reproduce:
- Install MediaWiki
- Install Extension:CSS
- Save the following into the page CSS/Path traversal/styles.css:
.purple {
width: 500px;
height: 500px;
background-color: purple;
}- Save the following into the page CSS/Path traversal:
{{#css: /..\index.php?title=CSS/Path traversal/styles.css&action=raw&ctype=text/css}}<!--
--><div class="purple"></div>Expected behavior:
The HTML output to the browser would be <!-- Invalid/malicious path -->
Actual behavior:
The HTML sent includes the URL, which loads CSS from the /styles.css page.
Versions:
Miscellaneous information:
Screenshot:
The extension attempts to check if the URL is on the correct path, and uses wfExpandUrl to normalize the URL (CSS.class.php line 47). Compliant URL parsers would treat the backslash alone, but in practice, browsers would silently convert backslashes into slashes.
![Screenshot 2024-07-08 at 18-24-02 CSS_Path traversal - [...].png (1×3 px, 311 KB)](https://phab.wmfusercontent.org/file/data/jqfyrrmmo4jmmaw3mgpp/PHID-FILE-nvi2vqstufjtjh3mc553/preview-Screenshot_2024-07-08_at_18-24-02_CSS_Path_traversal_-_%5B...%5D.png)