r81331 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81330‎ | r81331 | r81332 >
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_17/phase3/includes/Sanitizer.php (modified) (history)
  • /branches/REL1_17/phase3/includes/StringUtils.php (modified) (history)

Diff [purge]

Index: branches/REL1_17/phase3/includes/Sanitizer.php
@@ -748,6 +748,13 @@
749749 // Remove any comments; IE gets token splitting wrong
750750 $value = StringUtils::delimiterReplace( '/*', '*/', ' ', $value );
751751
 752+ // Remove anything after a comment-start token, to guard against
 753+ // incorrect client implementations.
 754+ $commentPos = strpos( $value, '/*' );
 755+ if ( $commentPos !== false ) {
 756+ $value = substr( $value, 0, $commentPos );
 757+ }
 758+
752759 // Decode escape sequences and line continuation
753760 // See the grammar in the CSS 2 spec, appendix D.
754761 static $decodeRegex;
Index: branches/REL1_17/phase3/includes/StringUtils.php
@@ -81,16 +81,20 @@
8282 }
8383
8484 if ( $tokenType == 'start' ) {
85 - $inputPos = $tokenOffset + $tokenLength;
8685 # Only move the start position if we haven't already found a start
8786 # This means that START START END matches outer pair
8887 if ( !$foundStart ) {
8988 # Found start
 89+ $inputPos = $tokenOffset + $tokenLength;
9090 # Write out the non-matching section
9191 $output .= substr( $subject, $outputPos, $tokenOffset - $outputPos );
9292 $outputPos = $tokenOffset;
9393 $contentPos = $inputPos;
9494 $foundStart = true;
 95+ } else {
 96+ # Move the input position past the *first character* of START,
 97+ # to protect against missing END when it overlaps with START
 98+ $inputPos = $tokenOffset + 1;
9599 }
96100 } elseif ( $tokenType == 'end' ) {
97101 if ( $foundStart ) {

Follow-up revisions

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

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

Status & tagging log