Hi,
I'm currently checking Drupal before using it. First, we're going to use it for user blogs, then we plan to move almost the whole features of the site.
The web servers (Apaches) of this site are located behing a reverse proxy (Squid in accel mode), so it's nice to see that now Drupal has implemented a method in core to capture the IP used by the user. Related issues: 142773 and 169263, I think.
So... we could enable the option that makes function ip_address() look at the X-Forwarded-For header and it seems it's ok like that, BUT...
...the site is reachable also from direct access to the web servers, bypassing Squid, hence opening the possibility for users to spoof their IP addresses.
So, if a site's behind a reverse proxy (actually 2 of them) but can also be reached directly (direct access to the Apaches for several reasons is alloed), the user IP address can still be spoofed. That's the reason I'm flagging this issue as a bug report, not sending it to the security team 'cause as far as I can tell, this affects only 6.x which is in beta stage.
The only solution to this I can think now is to patch the code so the X-Forwarded-For header is tructed only when the request really comes from the reverse proxy. Maybe adding config options to allow site admis enter the reverse proxy IPs.
In the meantime, we'll probably open the blog functionally before 6.x gets finished, so we've focussed on 5.x. Here I've implemented the same functionallity through a code snippet added to the settings.php script, which is executed on top of almost anything else. In this code snippet I'm trusting the X-Forwarded-For header ONLY if Remote-Addr is known, ie. it corresponds to the IP address of one of our proxies. Otherwise, it's a sign that the request reaches the web server from somewhere else, and that's the IP address that we need to look at as the user IP.
Comments
Comment #1
markus_petrux commentedIf that helps, the code snippet we will be using in settings.php looks like this:
Comment #2
markus_petrux commentedSomehow related issue:
http://drupal.org/node/173408
Comment #3
markus_petrux commentedProbably this issue can be marked as a dup of the obove mentioned one.