r81332 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81331‎ | r81332 | r81333 >
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_16/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_16/phase3/includes/Sanitizer.php (modified) (history)
  • /branches/REL1_16/phase3/includes/StringUtils.php (modified) (history)

Diff [purge]

Index: branches/REL1_16/phase3/includes/Sanitizer.php
@@ -739,6 +739,13 @@
740740 // Remove any comments; IE gets token splitting wrong
741741 $value = StringUtils::delimiterReplace( '/*', '*/', ' ', $value );
742742
 743+ // Remove anything after a comment-start token, to guard against
 744+ // incorrect client implementations.
 745+ $commentPos = strpos( $value, '/*' );
 746+ if ( $commentPos !== false ) {
 747+ $value = substr( $value, 0, $commentPos );
 748+ }
 749+
743750 // Decode escape sequences and line continuation
744751 // See the grammar in the CSS 2 spec, appendix D.
745752 static $decodeRegex, $reencodeTable;
Index: branches/REL1_16/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_16/phase3/RELEASE-NOTES
@@ -47,6 +47,7 @@
4848 * (bug 26642) Fixed incorrect translated namespace due to a regression in the
4949 language converter.
5050 * The interface translations were updated.
 51+* (bug 27093, CVE-2011-0047): Fixed CSS injection vulnerability.
5152
5253 == Changes since 1.16.0 ==
5354

Follow-up revisions

RevisionCommit summaryAuthorDate
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
r81331(bug 27093, CVE-2011-0047): Fixed CSS injection vulnerability. The StringUtil...tstarling22:37, 1 February 2011

Status & tagging log