Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
base system
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Sep 2007 at 00:17 UTC
Updated:
10 Feb 2008 at 01:30 UTC
Jump to comment: Most recent file
Comments
Comment #1
markus_petrux commentedA possible alternative would to move the option to settings.php, but then it would have to be asked at install time, maybe.
PS: Another issue that's somehow related: 185302 (trust only known proxy IPs).
Comment #2
markus_petrux commentedHi again,
hmm... if D6 is going to have to code to offer support of the XFF header, then I guess it needs a bit more attention. Flagging as critical, then you decide ;)
The fact is that if you use Squid in accellerator mode, then you know that Remote-Addr must match a known IP address, so you shouldn't trust the XFF header if that doesn't match. Please, see 185302 which I think is related to this issue, affects the same code, so I marked that one as a dup of this.
This is of course besides what's been mentioned by killes above.
Cheers
Comment #3
chx commentedSo, what you will want to do is to move the stuff into the install configure form, so it can be written into settings.php.
Comment #4
gerhard killesreiter commentedNot sure about this. Drupal.org moved to squid after being operational for over 6 years. That means that a field in the configure form wouldn't have helped us.
Comment #5
chx commentedWell, that means a message on the settings form then stating "please update your settings.php". Not ideal. But this is a very advanced setting, if you can set up squid, you surely are advanced enough.
Comment #6
markus_petrux commentedMaybe you could add an advanced settings section to the install form and then write settings.php accordingly. You need to provide two options: $reverse_proxy and (maybe) $reverse_proxy_ips which would be a comma separated list of your proxy server IPs.
You could simply add these variables with default values in a new section in settings.php with enough documentation on it, so an installation based on proxy server has the possibility to set these values and Drupal does the rest, within ip_address(), which is somehow "incomplete" now.
Comment #7
gábor hojtsyThis issue does not break how Drupal works, so I don't think why it is critical. I tried to understand this comment where markus_petrux decided this is critical, but I cannot:
if D6 is going to have to code to offer support of the XFF header, then I guess it needs a bit more attention. Flagging as critical, then you decide ;)Drupal 6 writes code itself? :)
Comment #8
gerhard killesreiter commentedWell, we offering it as a feature, but it does not work. We should not ship D6 without either fixing it or removing the feature. So, yes, I think it is indeed critical.
Comment #9
gábor hojtsyAcknowledged. So it seems as nobody provides a fix, we should remove this feature.
Comment #10
markus_petrux commentedWell, the problem now (in current HEAD) I think, is that ip_address() has been "extended" with an incomplete solution, and that may allow spoofing the client address, if the web server can be reached directly. This should be removed or fixed.
If feature is removed, then one can simply parse/fix the $_SERVER array in settings.php, where these PHP globals have already been sanitized, and almost before than anything else.
If feature is fixed for D6+, then one possible approach could be to move the options used inside ip_address() to settings.php, then all you need to provide is a bit of doc for those that use a proxy/web server environments. In the future, this could be somehow included in install script or whatever...
Comment #11
gábor hojtsyCan you help with providing a patch of what should be removed? (It does not seem like there are workable suggestions for improvements above, so I am looking at removing the bugos functionality).
Comment #12
markus_petrux commentedNot in patch form, 'cause I don't have the environment for that at this moment, but I can help you by checking current code in D6 and posting 2 options: 1) removing the feature, 2) moving the reverse proxy settings to settings.php, which I think can solve the issue.
Then you decide how to proceed.
...be back later, downloading D6 and checking...
Comment #13
markus_petrux commentedHi, here's the changes to remove the feature:
Step 1: Edit file
modules/system/system.admin.incand remove the following lines:Step 2: Edit file
includes/bootstrap.incand remove the following lines from functionip_address():I believe that's it. Now, I'll post option 2, which would be "fixing" the feature.
Comment #14
markus_petrux commentedHere's option 2. Well, this is just a possible way to do it.
Step 1: Edit file
modules/system/system.admin.incand remove the following lines:Step 2: Edit file
includes/bootstrap.incand change the code in functionip_address()like this:Step 3: Edit file
sites/default/default.settings.phpand the reverse proxy settings there. A possible way to do it could be coding the default $conf values that are commented like this:More or less, I believe that's it. I hope that heps, at least to see the "problem".
Cheers
Comment #15
gábor hojtsyWell, seems like we can fix this with settings in settings.php, and we can expect advance people (who set up proxies) to be able to edit the settings there, so option B seems to be workable. Anybody up for doing that in patch form?
Comment #16
add1sun commentedI just went ahead and created a patch for markus_petrux's option 2 listed above. I myself don't know anything about actually using it or testing it, just wanted to help with the grunt work of patch creation.
Comment #17
gábor hojtsyadd1sun: Thanks!
Patch looks good, but it obviously needs some testing. Gerhard?
Comment #18
gerhard killesreiter commentedI've applied the patch on scratch and configured the site accordingly. Testing indicates that the correct IP gets found.
Comment #19
gábor hojtsyGreat, thanks, committed.
Comment #20
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #21
mohanjith commentedThere are more issues when caching is enabled, see http://drupal.org/node/219825