From: Brian Wolff Date: Wed, 8 Jun 2016 02:35:15 +0000 (-0400) Subject: SECURITY: XSS in unclosed internal links X-Git-Tag: 1.31.0-rc.0~5948^2~1 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=e2a6fe571166160b9caed45f35910a7b9b50d2c0 SECURITY: XSS in unclosed internal links rawurldecode was being run on unclosed internal links which could allow an attacker to insert arbitrary html into the page. See also related: r13302 Bug: T137264 Change-Id: I4e112a9e918df9fe78b62c311939239b483a21f5 --- diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 4f579a93be..38eb621936 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2158,7 +2158,7 @@ class Parser { $might_be_img = true; $text = $m[2]; if ( strpos( $m[1], '%' ) !== false ) { - $m[1] = rawurldecode( $m[1] ); + $m[1] = str_replace( [ '<', '>' ], [ '<', '>' ], rawurldecode( $m[1] ) ); } $trail = ""; } else { # Invalid form; output directly diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index d6d2b29976..c7bbc62356 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -27140,3 +27140,12 @@ Thumbnail output !! end + +!! test +unclosed internal link XSS (T137264) +!! wikitext +[[#%3Cscript%3Ealert(1)%3C/script%3E| +!! html +

[[#<script>alert(1)</script>| +

+!! end