r81333 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81332‎ | r81333 | r81334 >
Date:22:37, 1 February 2011
Author:tstarling
Status:ok
Tags:
Comment:
(bug 27093, CVE-2011-0047): Fixed CSS injection vulnerability. The StringUtils.php patch is by Roan, the Sanitizer.php patch is by me.
Modified paths:
  • /branches/REL1_15/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_15/phase3/includes/Sanitizer.php (modified) (history)
  • /branches/REL1_15/phase3/includes/StringUtils.php (modified) (history)

Diff [purge]

Index: branches/REL1_15/phase3/includes/Sanitizer.php
@@ -659,6 +659,13 @@
660660 // Remove any comments; IE gets token splitting wrong
661661 $value = StringUtils::delimiterReplace( '/*', '*/', ' ', $value );
662662
 663+ // Remove anything after a comment-start token, to guard against
 664+ // incorrect client implementations.
 665+ $commentPos = strpos( $value, '/*' );
 666+ if ( $commentPos !== false ) {
 667+ $value = substr( $value, 0, $commentPos );
 668+ }
 669+
663670 // Decode escape sequences and line continuation
664671 // See the grammar in the CSS 2 spec, appendix D.
665672 static $decodeRegex, $reencodeTable;
Index: branches/REL1_15/phase3/includes/StringUtils.php
@@ -77,16 +77,20 @@
7878 }
7979
8080 if ( $tokenType == 'start' ) {
81 - $inputPos = $tokenOffset + $tokenLength;
8281 # Only move the start position if we haven't already found a start
8382 # This means that START START END matches outer pair
8483 if ( !$foundStart ) {
8584 # Found start
 85+ $inputPos = $tokenOffset + $tokenLength;
8686 # Write out the non-matching section
8787 $output .= substr( $subject, $outputPos, $tokenOffset - $outputPos );
8888 $outputPos = $tokenOffset;
8989 $contentPos = $inputPos;
9090 $foundStart = true;
 91+ } else {
 92+ # Move the input position past the *first character* of START,
 93+ # to protect against missing END when it overlaps with START
 94+ $inputPos = $tokenOffset + 1;
9195 }
9296 } elseif ( $tokenType == 'end' ) {
9397 if ( $foundStart ) {
Index: branches/REL1_15/phase3/RELEASE-NOTES
@@ -9,6 +9,7 @@
1010 * (bug 24740) limit=max still causing problems on 1.15.5 (backport r70078,
1111 bug 24564)
1212 * Fixed $wgLicenseTerms register globals.
 13+* (bug 27093, CVE-2011-0047): Fixed CSS injection vulnerability.
1314
1415 == MediaWiki 1.15.5 ==
1516

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81330(bug 27093, CVE-2011-0047): Fixed CSS injection vulnerability. The StringUtil...tstarling22:36, 1 February 2011
r81331(bug 27093, CVE-2011-0047): Fixed CSS injection vulnerability. The StringUtil...tstarling22:37, 1 February 2011
r81332(bug 27093, CVE-2011-0047): Fixed CSS injection vulnerability. The StringUtil...tstarling22:37, 1 February 2011

Status & tagging log