r85845 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85844‎ | r85845 | r85846 >
Date:01:07, 12 April 2011
Author:tstarling
Status:ok
Tags:
Comment:
MFT r85844, fix for bug 28235 (IE6 looks for the file extension in the query string)
Modified paths:
  • /branches/REL1_16/phase3/api.php (modified) (history)
  • /branches/REL1_16/phase3/images/.htaccess (added) (history)
  • /branches/REL1_16/phase3/img_auth.php (modified) (history)
  • /branches/REL1_16/phase3/includes/RawPage.php (modified) (history)
  • /branches/REL1_16/phase3/includes/WebRequest.php (modified) (history)
  • /branches/REL1_16/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: branches/REL1_16/phase3/images/.htaccess
@@ -0,0 +1,6 @@
 2+# Protect against bug 28235
 3+<IfModule rewrite_module>
 4+ RewriteEngine On
 5+ RewriteCond %{QUERY_STRING} \.[a-z]{1,4}$ [nocase]
 6+ RewriteRule . - [forbidden]
 7+</IfModule>
Property changes on: branches/REL1_16/phase3/images/.htaccess
___________________________________________________________________
Added: svn:mergeinfo
18 Merged /branches/REL1_15/phase3/images/.htaccess:r51646
29 Merged /branches/sqlite/images/.htaccess:r58211-58321
310 Merged /branches/new-installer/phase3/images/.htaccess:r43664-66004
Added: svn:eol-style
411 + native
Index: branches/REL1_16/phase3/includes/WebRequest.php
@@ -688,10 +688,27 @@
689689 * but only by prefixing it with the script name and maybe some other stuff,
690690 * the extension is not mangled. So this should be a reasonably portable
691691 * way to perform this security check.
 692+ *
 693+ * Also checks for anything that looks like a file extension at the end of
 694+ * QUERY_STRING, since IE 6 and earlier will use this to get the file type
 695+ * if there was no dot before the question mark (bug 28235).
692696 */
693697 public function isPathInfoBad() {
694698 global $wgScriptExtension;
695699
 700+ if ( isset( $_SERVER['QUERY_STRING'] )
 701+ && preg_match( '/\.[a-z]{1,4}$/i', $_SERVER['QUERY_STRING'] ) )
 702+ {
 703+ // Bug 28235
 704+ // Block only Internet Explorer 6, and requests with missing UA
 705+ // headers that could be IE users behind a privacy proxy.
 706+ if ( !isset( $_SERVER['HTTP_USER_AGENT'] )
 707+ || preg_match( '/; *MSIE 6/', $_SERVER['HTTP_USER_AGENT'] ) )
 708+ {
 709+ return true;
 710+ }
 711+ }
 712+
696713 if ( !isset( $_SERVER['PATH_INFO'] ) ) {
697714 return false;
698715 }
Property changes on: branches/REL1_16/phase3/includes/WebRequest.php
___________________________________________________________________
Modified: svn:mergeinfo
699716 Merged /trunk/phase3/includes/WebRequest.php:r85844
Index: branches/REL1_16/phase3/includes/RawPage.php
@@ -125,7 +125,7 @@
126126 #
127127 # Just return a 403 Forbidden and get it over with.
128128 wfHttpError( 403, 'Forbidden',
129 - 'Invalid file extension found in PATH_INFO. ' .
 129+ 'Invalid file extension found in PATH_INFO or QUERY_STRING. ' .
130130 'Raw pages must be accessed through the primary script entry point.' );
131131 return;
132132 }
Index: branches/REL1_16/phase3/img_auth.php
@@ -37,6 +37,13 @@
3838 wfForbidden('img-auth-accessdenied','img-auth-public');
3939 }
4040
 41+// Check for bug 28235: QUERY_STRING overriding the correct extension
 42+if ( isset( $_SERVER['QUERY_STRING'] )
 43+ && preg_match( '/\.[a-z]{1,4}$/i', $_SERVER['QUERY_STRING'] ) )
 44+{
 45+ wfForbidden( 'img-auth-accessdenied', 'img-auth-bad-query-string' );
 46+}
 47+
4148 // Extract path and image information
4249 if( !isset( $_SERVER['PATH_INFO'] ) )
4350 wfForbidden('img-auth-accessdenied','img-auth-nopathinfo');
Index: branches/REL1_16/phase3/api.php
@@ -52,8 +52,7 @@
5353 //
5454 if ( $wgRequest->isPathInfoBad() ) {
5555 wfHttpError( 403, 'Forbidden',
56 - 'Invalid file extension found in PATH_INFO. ' .
57 - 'The API must be accessed through the primary script entry point.' );
 56+ 'Invalid file extension found in PATH_INFO or QUERY_STRING.' );
5857 return;
5958 }
6059
Property changes on: branches/REL1_16/phase3/api.php
___________________________________________________________________
Added: svn:mergeinfo
6160 Merged /trunk/phase3/api.php:r63545-63546,63549,63643,63764,63897-63901,64876,76664,79561,85844
Index: branches/REL1_16/phase3/languages/messages/MessagesEn.php
@@ -2155,6 +2155,7 @@
21562156 This wiki is configured as a public wiki.
21572157 For optimal security, img_auth.php is disabled.',
21582158 'img-auth-noread' => 'User does not have access to read "$1".',
 2159+'img-auth-bad-query-string' => 'The URL has an invalid query string.',
21592160
21602161 # HTTP errors
21612162 'http-invalid-url' => 'Invalid URL: $1',
Property changes on: branches/REL1_16/phase3/languages/messages/MessagesEn.php
___________________________________________________________________
Modified: svn:mergeinfo
21622163 Merged /trunk/phase3/languages/messages/MessagesEn.php:r85844

Follow-up revisions

RevisionCommit summaryAuthorDate
r85846MFT r85844, fix for bug 28235 (IE6 looks for the file extension in the query ...tstarling01:15, 12 April 2011
r85875MFT r85871 as follow-up to r85845raymond12:41, 12 April 2011
r86027(bug 28507) Fix for r85844: that revision was not actually sufficient to fix ...tstarling07:10, 14 April 2011
r89397(bug 28840) If the query string hits bug 28235, redirect to a safer URL inste...tstarling05:32, 3 June 2011
r89558* Added a REQUEST_URI check to the bug 28235 handling....tstarling11:59, 6 June 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85844Fix for bug 28235: IE6 looks for the file extension in the query stringtstarling00:55, 12 April 2011

Status & tagging log