r85846 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85845‎ | r85846 | r85847 >
Date:01:15, 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_17/phase3/api.php (modified) (history)
  • /branches/REL1_17/phase3/images/.htaccess (added) (history)
  • /branches/REL1_17/phase3/img_auth.php (modified) (history)
  • /branches/REL1_17/phase3/includes/RawPage.php (modified) (history)
  • /branches/REL1_17/phase3/includes/WebRequest.php (modified) (history)
  • /branches/REL1_17/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /branches/REL1_17/phase3/load.php (modified) (history)

Diff [purge]

Index: branches/REL1_17/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_17/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_17/phase3/includes/WebRequest.php
@@ -746,10 +746,27 @@
747747 * but only by prefixing it with the script name and maybe some other stuff,
748748 * the extension is not mangled. So this should be a reasonably portable
749749 * way to perform this security check.
 750+ *
 751+ * Also checks for anything that looks like a file extension at the end of
 752+ * QUERY_STRING, since IE 6 and earlier will use this to get the file type
 753+ * if there was no dot before the question mark (bug 28235).
750754 */
751755 public function isPathInfoBad() {
752756 global $wgScriptExtension;
753757
 758+ if ( isset( $_SERVER['QUERY_STRING'] )
 759+ && preg_match( '/\.[a-z]{1,4}$/i', $_SERVER['QUERY_STRING'] ) )
 760+ {
 761+ // Bug 28235
 762+ // Block only Internet Explorer 6, and requests with missing UA
 763+ // headers that could be IE users behind a privacy proxy.
 764+ if ( !isset( $_SERVER['HTTP_USER_AGENT'] )
 765+ || preg_match( '/; *MSIE 6/', $_SERVER['HTTP_USER_AGENT'] ) )
 766+ {
 767+ return true;
 768+ }
 769+ }
 770+
754771 if ( !isset( $_SERVER['PATH_INFO'] ) ) {
755772 return false;
756773 }
Property changes on: branches/REL1_17/phase3/includes/WebRequest.php
___________________________________________________________________
Added: svn:mergeinfo
757774 Merged /branches/REL1_15/phase3/includes/WebRequest.php:r51646
758775 Merged /branches/sqlite/includes/WebRequest.php:r58211-58321
759776 Merged /trunk/phase3/includes/WebRequest.php:r82845,82847-82848,85844
760777 Merged /branches/new-installer/phase3/includes/WebRequest.php:r43664-66004
761778 Merged /branches/wmf-deployment/includes/WebRequest.php:r53381
Index: branches/REL1_17/phase3/includes/RawPage.php
@@ -132,7 +132,7 @@
133133 #
134134 # Just return a 403 Forbidden and get it over with.
135135 wfHttpError( 403, 'Forbidden',
136 - 'Invalid file extension found in PATH_INFO. ' .
 136+ 'Invalid file extension found in PATH_INFO or QUERY_STRING. ' .
137137 'Raw pages must be accessed through the primary script entry point.' );
138138 return;
139139 }
Property changes on: branches/REL1_17/phase3/includes/RawPage.php
___________________________________________________________________
Added: svn:mergeinfo
140140 Merged /branches/REL1_15/phase3/includes/RawPage.php:r51646
141141 Merged /branches/sqlite/includes/RawPage.php:r58211-58321
142142 Merged /trunk/phase3/includes/RawPage.php:r82845,82847-82848,85844
143143 Merged /branches/new-installer/phase3/includes/RawPage.php:r43664-66004
144144 Merged /branches/wmf-deployment/includes/RawPage.php:r53381
Index: branches/REL1_17/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 $path = $wgRequest->getText( 'path' );
Property changes on: branches/REL1_17/phase3/img_auth.php
___________________________________________________________________
Modified: svn:mergeinfo
4451 Merged /branches/REL1_16/phase3/img_auth.php:r85845
Index: branches/REL1_17/phase3/api.php
@@ -55,8 +55,7 @@
5656 //
5757 if ( $wgRequest->isPathInfoBad() ) {
5858 wfHttpError( 403, 'Forbidden',
59 - 'Invalid file extension found in PATH_INFO. ' .
60 - 'The API must be accessed through the primary script entry point.' );
 59+ 'Invalid file extension found in PATH_INFO or QUERY_STRING.' );
6160 return;
6261 }
6362
Property changes on: branches/REL1_17/phase3/api.php
___________________________________________________________________
Added: svn:mergeinfo
6463 Merged /branches/sqlite/api.php:r58211-58321
6564 Merged /trunk/phase3/api.php:r79828,79830,79848,79853,79950-79951,79954,79989,80006-80007,80013,80016,80080,80083,80124,80128,80238,81657,81833,82845,82847-82849,85844
6665 Merged /branches/new-installer/phase3/api.php:r43664-66004
6766 Merged /branches/REL1_15/phase3/api.php:r51646
Index: branches/REL1_17/phase3/load.php
@@ -37,11 +37,8 @@
3838 //
3939 if ( $wgRequest->isPathInfoBad() ) {
4040 wfHttpError( 403, 'Forbidden',
41 - 'Invalid file extension found in PATH_INFO. ' .
42 - 'The resource loader must be accessed through the primary script entry point.' );
 41+ 'Invalid file extension found in PATH_INFO or QUERY_STRING.' );
4342 return;
44 - // FIXME: Doesn't this execute the rest of the request anyway?
45 - // Was taken from api.php so I guess it's maybe OK but it doesn't look good.
4643 }
4744
4845 // Respond to resource loading request
Property changes on: branches/REL1_17/phase3/load.php
___________________________________________________________________
Added: svn:mergeinfo
4946 Merged /branches/new-installer/phase3/load.php:r43664-66004
5047 Merged /branches/REL1_15/phase3/load.php:r51646
5148 Merged /branches/sqlite/load.php:r58211-58321
5249 Merged /trunk/phase3/load.php:r79828,79830,79848,79853,79950-79951,79954,79989,80006-80007,80013,80016,80080,80083,80124,80128,80238,81657,81833,82845,82847-82849,85844
Index: branches/REL1_17/phase3/languages/messages/MessagesEn.php
@@ -2202,6 +2202,7 @@
22032203 This wiki is configured as a public wiki.
22042204 For optimal security, img_auth.php is disabled.',
22052205 'img-auth-noread' => 'User does not have access to read "$1".',
 2206+'img-auth-bad-query-string' => 'The URL has an invalid query string.',
22062207
22072208 # HTTP errors
22082209 'http-invalid-url' => 'Invalid URL: $1',
Property changes on: branches/REL1_17/phase3/languages/messages/MessagesEn.php
___________________________________________________________________
Added: svn:mergeinfo
22092210 Merged /branches/sqlite/languages/messages/MessagesEn.php:r58211-58321
22102211 Merged /trunk/phase3/languages/messages/MessagesEn.php:r79828,79830,79848,79853,79950-79951,79954,79989,80006-80007,80013,80016,80080,80083,80124,80128,80238,81657,81833,82845,82847-82849,85844
22112212 Merged /branches/new-installer/phase3/languages/messages/MessagesEn.php:r43664-66004
22122213 Merged /branches/REL1_15/phase3/languages/messages/MessagesEn.php:r51646

Follow-up revisions

RevisionCommit summaryAuthorDate
r85874MFT r85871 as follow-up to r85846raymond12:26, 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
r85845MFT r85844, fix for bug 28235 (IE6 looks for the file extension in the query ...tstarling01:07, 12 April 2011

Status & tagging log