r94489 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94488‎ | r94489 | r94490 >
Date:05:25, 15 August 2011
Author:skizzerz
Status:ok
Tags:
Comment:
* Revert r94487 and r19889 to an extent -- ONLY check for the X-Forwarded-For header when we are behind a proxy, as mostly every properly configured proxy software sets it, and attempting to support those that do not opens up the ability to spoof IP addresses by setting arbitrary headers.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/ProxyTools.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -36,8 +36,6 @@
3737 * Most presentational html attributes like valign are now converted to inline
3838 css style rules. These attributes were removed from html5 and so we clean them up
3939 when $wgHtml5 is enabled. This can be disabled using $wgCleanupPresentationalAttributes.
40 -* When MediaWiki is being run behind a proxy, the X-Real-IP header is now also checked
41 - to determine the client's actual IP address.
4240
4341 === Bug fixes in 1.19 ===
4442 * $wgUploadNavigationUrl should be used for file redlinks if
@@ -80,6 +78,8 @@
8179 * jquery.mwPrototypes module was renamed to jquery.mwExtension.
8280 * The maintenance script populateSha1.php was renamed to the more concise
8381 populateImageSha1.php
 82+* The Client-IP header is no longer checked for when trying to resolve a client's
 83+ real IP address.
8484
8585 == Compatibility ==
8686
Index: trunk/phase3/includes/ProxyTools.php
@@ -7,7 +7,6 @@
88
99 /**
1010 * Extracts the XFF string from the request header
11 - * Checks first for "X-Forwarded-For", then "Client-ip", then "X-Real-IP"
1211 * Note: headers are spoofable
1312 * @return string
1413 */
@@ -20,23 +19,15 @@
2120 $set[ strtoupper( $tempName ) ] = $tempValue;
2221 }
2322 $index = strtoupper ( 'X-Forwarded-For' );
24 - $index2 = strtoupper ( 'Client-ip' );
25 - $index3 = strtoupper ( 'X-Real-IP' );
2623 } else {
2724 // Subject to spoofing with headers like X_Forwarded_For
2825 $set = $_SERVER;
2926 $index = 'HTTP_X_FORWARDED_FOR';
30 - $index2 = 'CLIENT-IP';
31 - $index3 = 'HTTP_X_REAL_IP';
3227 }
3328
34 - #Try a couple of headers
 29+ #Try to see if XFF is set
3530 if( isset( $set[$index] ) ) {
3631 return $set[$index];
37 - } elseif( isset( $set[$index2] ) ) {
38 - return $set[$index2];
39 - } elseif( isset( $set[$index3] ) ) {
40 - return $set[$index3];
4132 } else {
4233 return null;
4334 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r19889* Added useragent and an xff function and headeraaron01:02, 12 February 2007
r94487When MediaWiki is being run behind a proxy, also check the X-Real-IP header t...skizzerz04:50, 15 August 2011

Status & tagging log