Problem/Motivation

Referer, if present, MUST NOT be blank, according to RFC 2616, and so whatever reason this was put in for, it needs to be rewritten and/or removed. It interferes with Bad Behavior's check of the Referer value and offers absolutely no benefit to Drupal or anyone else, while inducing RFC-noncompliant behavior.

Proposed resolution

Remove code in drupal_environment_initialize()

Remaining tasks

Commit it

User interface changes

None

API changes

None

Original report by @jlea9378

Bad Behavior is blocking me (and lots of other people) from accessing my Drupal 7 site. I never had a problem when using Drupal 6. The reason given in the log is that the referrer is blank. I tried disabling all of my addons in firefox and also tried using Internet Explorer instead, but no matter what I get blocked. I must have deleted my cookie on accident because now I can't even get in using https instead of http. So I'm totally blocked now. I tried using a different computer also, and I get blocked there as well. It seems like Bad Behavior on Drupal 7 is extra-sensitive or something...?

Using the latest version of Bad Behavior and library as of 10/26/12: version 2.2.11
Drupal 7.16

My support key is: ac10-0019-6992-0ee5

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gregarios’s picture

Are you using a proxy server that isn't allowing referrer reports to get to your Drupal installation? It sounds like it may be a server-configuration problem to me, since most browsers and personal computers allow and send referrer reports by default.

jlea9378’s picture

Nope, no proxy server. Our web server is running behind a DMZ. When trying to browse to the site from my home computer or from my office computer I get that error. My office is on the other side of the DMZ on the protected side of the network. We don't use a proxy server at the office, and I don't use one at home either. At home I just have a typical home cable modem and router.

The link to the site is: http://web.clatsopcc.edu:8000/
That's the test copy of our site. I had it installed on the production site (which is on port 80 and hostname is www) but someone notified me that they couldn't access the site, so I turned it off.

gregarios’s picture

I am unable to get to the website you listed because of Bad Behavior kicking in as well. It sounds like you m,ay have an unique issue, as we have not received an influx of other users having this problem.

Are you sure the "Clatsop Community College" network doesn't have some kind of firewall preventing Bad Behavior from working? You should turn off any firewall temporarily for the purpose of troubleshooting your issue if possible.

Your best bet would be to disable all modules on the site except Bad Behavior and see if the issue still exists. There may be some incompatibility going on with your particular setup.

Any details would also be helpful in this:
Web Server Software:
Web Host:
Firewall settings if any:

jlea9378’s picture

We host the server ourselves. It's on a Red Hat EL5 server in our vmware virtual server environment:
mysql 5.0.95-log
php 5.3.5
Apache/2.2.3 (Red Hat)

Even browsing to the site on the Linux webserver itself causes Bad Behavior to kick in, so it doesn't appear to be a firewall problem.

I just tried disabling all modules, uninstalling the Bad Behavior module and reinstalling it, but that didn't help. I still get blocked, even when browsing to the site from the GUI on the webserver itself.

gregarios’s picture

It appears your site is working with the Bad Behavior module installed at this time. Would you mind reporting back to let us know what the problem was? It may help others in the future.

jlea9378’s picture

No, it's not working. I am still getting blocked every time from different computers.

gregarios’s picture

It is no longer blocking me. It was before.

This isn't really the issue forum to consult if you think it is the Bad Behavior logic, however, since it is a non-Drupal third-party script that handles all the blocking itself. You should go here to submit your problem and see if there is anything they can find out:

http://bad-behavior.ioerror.us/support/troubleshooting/

As a matter of fact, if you are getting the Bad Behavior "blocked" message, then the Drupal module is, in fact, working correctly. (Even if the Bad Behavior library isn't)

jlea9378’s picture

I contacted the Bad Behavior team and got a response. Here is what Michael Hampton said:

There's definitely something strange in your environment. I went to the URL you gave, and I saw Bad Behavior's error page, which was replaced a second later with the actual site.

Inspecting the HTTP headers of the response, I see something strange:

HTTP/1.1 400 Bad Behavior
Date: Mon, 05 Nov 2012 19:51:18 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.3.5
X-Drupal-Cache: HIT
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

If this is to be believed, the response is not being served by Bad Behavior, but by Drupal's cache. I'm not really familiar with how Drupal does caching, but in general, to solve this sort of problem you will want to configure the cache to not do any sort of negative caching, i.e. it should not cache error responses.

Hopefully this gives you something to go on.

Michael

As an experiment, on the webserver GUI, I logged in to the site via Firefox and completely disabled the caching in Drupal on the test website (I had to rename the bad-behavior library to even get back in because it kept blocking me). I cleared the cache to make sure it was clean, logged out, changed the name of the library back to the correct name, and closed the browser. Then I launched the browser again and navigated back to the test site. Once again I was blocked. If it helps, the key is: ac10-0a11-6992-0ee5. Note that all other Drupal modules, aside from Drupal Core modules and the Bad Behavior module, are disabled. So it doesn’t seem to be a Drupal caching problem. Especially since I can’t get back into the site unless I rename the Bad Behavior library folder…
Explicitly putting the address in of https://web.clatsopcc.edu:8443/user/login doesn’t even allow me to get back in unless the Bad Behavior library is missing.

gregarios’s picture

Since you disabled Drupal's internal caches, and still had to rename the library to get back in... that suggests that you may have some kind of Apache or PHP caching that is causing this behavior. You may want to look at this and add the Bad Behavior library to "exempted" files to those caches if possible. (Could be settings in caches such as MemCache, APC, mod_cache, etc...)

Also completely disable any browser caching that may interfere. Make sure, when running Bad Behavior, that you do not ever use "external" or "aggressive" caching in the Drupal settings.

jlea9378’s picture

Yes we use APC in our LAMP stack. I see there is a way to exclude certain files from APC using this php.ini directive: apc.filters
I'm not sure what I should put for the regex though. What files should I be excluding? Everything in the bad-behavior module and library folders?

gregarios’s picture

If you're using APC then a simple restart of Apache may be all that is needed to make sure the newest PHP documents are all brought into cache whenever new modules or libraries are added/modified. Also, make sure you have the following settings stated in the APC section of your php.ini file:

apc.stat = 1
apc.include_once_override = 0
jlea9378’s picture

Done. I also added bad-behavior and badbehavior to the filter list and verified that they are excluded via the web interface to APC. However none of those changes have helped. Bad Behavior is still blocking me relentlessly, even after a fresh reboot of Apache and PHP-FPM.

carsonw’s picture

I've been having the same issue as jlea9378, and so I'm disabling this module until I can figure out what the heck is going on.

Kutakizukari’s picture

I'm having the same issue with http://vegan5technique.com. I'm logged in as admin with firefox and can view fine but if I use Google Chrome or Internet Exploroer I get:

Error 400

We're sorry, but we could not fulfill your request for / on this server.

An invalid request was received from your browser. This may be caused by a malfunctioning proxy server or browser privacy software.

Your technical support key is: 46c1-0338-6992-0ee5

You can use this key to fix this problem yourself.

If you are unable to fix the problem yourself, please contact vegan5technique at gmail.com and be sure to provide the technical support key shown above.

and can't view the site.

I also have no proxy's running and did not have this problem with the Drupal 6 version.

Kutakizukari’s picture

I did not have caching enabled when I installed BB and it still blocks Internet Explorer and Chrome but not Fire Fox though I installed when logged into the admin and have not logged out of fear of not getting back in.

jlea9378’s picture

Priority: Major » Critical

Yah I didn't have any problems until I upgraded to Drupal 7 -- it worked great under Drupal 6. If you get locked out, just rename the Bad Behavior library directory to something else, like bad-behavior-foo. I've been locked out several times now...

Kutakizukari’s picture

@carsonw: I also have disabled the module because it was blocking everyone who came to my site.

gregarios’s picture

Status: Active » Postponed (maintainer needs more info)

It would appear the Bad Behavior Drupal module is working correctly. If you are having specific blocking issues, you will need to contact the Library maintainer at: http://bad-behavior.ioerror.us/support/troubleshooting/

If it is found that there is a problem with the Drupal module, I will look into this further.

error’s picture

I cannot reproduce this issue on a freshly installed Drupal 7 test site. So it doesn't seem to be an issue with the core Bad Behavior code. I'll keep poking at it, but I don't really expect to get too far. It might help if those of you running into this issue can provide a LOT of detail about your server environment, other Drupal modules in use, etc.

Kutakizukari’s picture

@error when I get a change I'll install another live site and go through each module to see if one keeps it from working like it is on my currect site.

One module right off the bat that might keep it from running correctly is the PHPIDS module: http://drupal.org/project/phpids.

Using the 7.x-1.x-dev version on a live site, when I get a change I'll check that one out.

Kutakizukari’s picture

Just tried disabling the PHPIDS module: http://drupal.org/project/phpids and it still blocks me from chrome and IE but not FireFox since I'm login as admin.

@jlea9378 Would comparing modules help narrow down the culprit?

Kutakizukari’s picture

FileSize
572.61 KB

Here is a screenshot of the modules I have installed and available. Hope this helps.

jlea9378’s picture

Status: Postponed (maintainer needs more info) » Active

I get blocked even when I have all non-core modules disabled, aside from Bad Behavior.

rahim123’s picture

Hi, I have this same issue. Bad Behavior works great on Drupal 6 on the same server.

URI /favicon.ico
PROTOCOL HTTP/1.0
USER AGENT Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11
HEADERS GET /favicon.ico HTTP/1.0 Host: libretechtips.com X-Forwarded-Host: libretechtips.com X-Forwarded-Server: libretechtips.com X-Forwarded-For: 190.152.33.194 Forwarded-Request-Uri: /favicon.ico Http-X-Forwarded-Proto: http Https: off X-Forwarded-Proto: http X-Forwarded-Ssl: off Connection: close Accept: */* User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 Referer:
REQUEST ENTITY
DENIED REASON Header 'Referer' present but blank
EXPLANATION An invalid request was received from your browser. This may be caused by a malfunctioning proxy server or browser privacy software.
RESPONSE 400

Kutakizukari’s picture

@jlea9378 Confirmed, just installed @ http://8bitplatyp.us/drupal/, after that:

$ drush dl badbehavior
$ drush en badbehavior

Went to visit with Chrome and I get:

Error 400

We're sorry, but we could not fulfill your request for /drupal/ on this server.

An invalid request was received from your browser. This may be caused by a malfunctioning proxy server or browser privacy software.

Your technical support key is: 46c1-0a58-6992-0ee5

You can use this key to fix this problem yourself.

If you are unable to fix the problem yourself, please contact email and be sure to provide the technical support key shown above.

error’s picture

I just checked http://8bitplatyp.us/drupal/ and Bad Behavior seems to be working fine. Please let us all know what the secret to fixing this was!

error’s picture

Assigned: Unassigned » error

I'm pretty well convinced at this point that there's some other code or configuration issue going on. I've now built two completely different test machines and been unable to reproduce the issue, with only the core extensions/themes and Bad Behavior installed.

I'd still like to track this down, obviously, so if you're having this issue, please send the following information:

  • Web server software and version (e.g. Apache 2.2.23, IIS 7, nginx 1.0.15)
  • PHP version (e.g. 5.3.19), SAPI (e.g. mod_php, fastcgi, fpm) and installation method (e.g. RPM/apt and which repository, binary download and where you got it, source code)
  • The exact configuration directives from your server by which your web server talks to PHP (don't link to an Internet guide; you probably deviated from it anyway)
  • The list of Drupal modules you have, which you can find with drush pm-list

Hopefully we can get to the bottom of this soon.

gregarios’s picture

That's interesting... when I visit http://8bitplatyp.us/drupal/ in Safari I get this:

Error 400

We're sorry, but we could not fulfill your request for /drupal/ on this server.

An invalid request was received from your browser. This may be caused by a malfunctioning proxy server or browser privacy software.

Your technical support key is: 4540-ec47-6992-0ee5

You can use this key to fix this problem yourself.

If you are unable to fix the problem yourself, please contact 8bitplatypus at gmail.com and be sure to provide the technical support key shown above.

But I get to a Drupal login if I visit in Firefox on the same machine.

I'm running OSX 10.8.2, Safari Version 6.0.2 (8536.26.17), and Firefox 17.0.1.

Kutakizukari’s picture

@gregarios Using Firefox 16.0.2 & 17.0.1 I get the login page with no content which has not been created yet but Drupal usaly has some things to do for the start page.

Using Chrome Version 23.0.1271.95 m & Internet Explorer 9 64-bit I get the error.

@error Going to start gathering the information for you.

jlea9378’s picture

mysql 5.0.95-log
php 5.3.5
APC: 3.1.6
Apache/2.2.3 (Red Hat)
Server API: FPM/FastCGI
Built from mod_fastcgi-2.4.6 source
The LAMP stack was configured mostly per: http://voidweb.com/2010/07/the-perfect-lamp-stack-apache2-fastcgi-php-fp...
However I likely deviated from the guide, so below are the relevant parts of my Apache config.

In /etc/httpd/conf.d:
php-fastcgi.conf

LoadModule fastcgi_module modules/mod_fastcgi.so

<IfModule mod_fastcgi.c>
    # Define a new handler
    AddHandler php-fastcgi .php

    # Define the MIME-Type for ".php" files
    AddType application/x-httpd-php .php
 
    # Add an action binding the new handler to an alias (see below)
    #Action php-fastcgi /fcgi-bin/php-cgi
 
    # Define alias "/fcgi-bin/" used by the action above.
    # Allows you to run a different command by overriding alias in vhosts
    Alias /fcgi-bin/ /var/www/cgi-bin/
 
    # Turn on the script handler for all files within the alias "/fcgi-bin/"
    <Location /fcgi-bin/>
        SetHandler php-fastcgi
        Options +ExecCGI +FollowSymLinks
    </Location>
</IfModule>

httpd.conf:

#
# Virtual hosts
#
FastCgiConfig -idle-timeout 60
Include conf/httpd-vhosts.conf

httpd-vhosts.conf:

<VirtualHost web.clatsopcc.edu:8000>
DocumentRoot "/var/www/html/drupal_test"
ServerSignature email
ServerName web.clatsopcc.edu:8000
DirectoryIndex index.php index.html index.htm index.shtml
LogLevel warn
HostNameLookups off
ServerAdmin web@clatsopcc.edu
RewriteEngine on
<Directory "/var/www/html/drupal_test">
Options Indexes FollowSymLinks
AllowOverride All
Allow from all
Order allow,deny

# For friendly URLs
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>

<Directory "/var/www/icons">
Options Indexes MultiViews
AllowOverride None
Allow from all
Order allow,deny
</Directory>

<Directory "/var/www/cgi-bin">
Options FollowSymLinks ExecCGI
AllowOverride None
Allow from all
Order allow,deny
</Directory>

<IfModule mod_fastcgi.c>
    Action php-fastcgi /fcgi-bin/drupal_test-php-cgi

    FastCGIExternalServer /var/www/cgi-bin/drupal_test-php-cgi -host 127.0.0.1:9000 -pass-header Authorization -idle-timeout 60
</IfModule>
</VirtualHost>

While troubleshooting, I had all non-core modules, except Bad Behavior, disabled. If you still want the list of non-core modules anyways (despite being disabled), let me know.

Note that currently I have Bad Behavior turned off and all other modules turned on so that I can continue working.

vinoth.3v’s picture

here I am getting 'Header 'Referer' present but blank'
is disabling BB is the only way?
:(
Drupal 7, Nginx, APC, within proxy.

rahim123’s picture

I'm using a Webfaction host, which also uses Nginx on the frontend to forward requests to Apache. Could this have something to do with it?

Kutakizukari’s picture

Webhost is http://bluehost.com shared environment. They did not know what I was talking about for the rest of the information you requested but I did dig up this:

Apache: 2.2.20
PHP: 5.3.18
MySQL: 5.5.28-log
Architechture: x86_64
OS: Linux
Kernel version: 2.6.32-20120131.55.1.b

The list of Drupal modules you have, which you can find with drush pm-list Attached

How I installed Drupal and Babbehavior

$ wget http://ftp.drupal.org/files/projects/drupal-7.17.tar.gz

$ tar –zxvf drupal-7.17.tar.gz

Went to http://8bitplayp.us/drupal with Firefox 17 and went through the install.

Then:

$ drush dl badbehavior

$drush en badbehavior

Went to http://8bitplayp.us/drupal with Chrome and get the error page.

Have the newer browsers been ruled out?

vinoth.3v’s picture

@sb56637
I am also using webfaction,
BB is working great on Drupal 6 site. I am having trouble only on drupal 7 site.

Luen Warneke’s picture

same problem.

Error 400

We're sorry, but we could not fulfill your request for / on this server.

An invalid request was received from your browser. This may be caused by a malfunctioning proxy server or browser privacy software.

Your technical support key is: 76d0-abf2-6992-0ee5

You can use this key to fix this problem yourself.

If you are unable to fix the problem yourself, please contact contact at example.com and be sure to provide the technical support key shown above.

error’s picture

@Luen, Please post the information requested (see comment 27).

gregarios’s picture

Will some of you try the complete zipped badbehavior module attached and report back? Make sure it isn't blocking you, and is still blocking spammers in the log. Thank you.

Kutakizukari’s picture

@gregarios

I removed the babehavior directory and the libraries directory and uninstalled from the modules section.

I unzipped and and transfered using SFTP and recreated the libraries directory with the newley transfered bad-behavior from the site.

Same results, still blocking me from Chrome and IE @ http://8bitplatyp.us/drupal

rahim123’s picture

@ vinoth.3v (#34)
Ah, yes, I should have mentioned that I also run a Drupal 6 site on Webfaction with BadBehavior and it works fine. It's only the D7 site that has this error. But even so, I wonder if the Nginx passoff to Apache somehow affects the Drupal 7 implementation.

rahim123’s picture

@ gregarios (#37)
I tried badbehavior7_mod_20121205a.zip, and it still gives me the same error. Thanks very much for looking into this error!

vinoth.3v’s picture

@ sb56637 (#39)
I have a separate nginx install on my account that handles both Drupal 6 & 7 sites. So I hope, it is not a issue of nginx/apache.

jlea9378’s picture

FYI, I do not use nginx.

Luen Warneke’s picture

PHP Version 5.3.13
Server API CGI/FastCGI

that's all I can tell you.

mmtahir’s picture

I have the same error #14, #28..

I am uninstalling it untill some fix is found

uno’s picture

Same here, works perfectly (AFAIK) on d6, blocks me (and others) on d7 - same environment.

On d7, when BB enabled, if I am logged in I can access site, but when log out - error 400 (logged http://example.com - access, new tab http://www.example.com - no access.

error’s picture

Status: Active » Postponed (maintainer needs more info)

Your comments are 100% useless unless you read and follow the directions in comment #27. If you fail to do so, I will not be able to help you.

jstuckle’s picture

I don't use this module, but I've seen similar behavior before. I believe the problem is the assumption the referer, if present, will contain a value. That is not true; it is perfectly valid for the referer field to be empty (yet still sent), i.e. when the URL is typed into the browser location field or a bookmark is used. When the page is accessed by clicking on a link from another page, the referer field will contain a value.

I tested this hypothesis. First I entered http://8bitplayp.us/drupal into the location field (FF 17) and got the above noted error. However, when I came back here and clicked on the link in post #38 above, I got to the login page. Looking at the headers, the first did not send any content in the referer header; the second one did.

error’s picture

@jstuckle According to RFC 2616 it is not valid for Referer: to be blank. If present, it must be either an absoluteURI or a relativeURI as defined in RFC 2396. It is valid for the header to be omitted entirely. If you've found that the _browser_ is sending a blank Referer: field, then it's a browser bug, and should be dealt with through that channel. But since this is only affecting Drupal 7, and not Drupal 6 or any other platform on which Bad Behavior runs, I suspect that is not the case.

Kutakizukari’s picture

@error

But since this is only affecting Drupal 7, and not Drupal 6 or any other platform on which Bad Behavior runs, I suspect that is not the case.

When it did work on drupal 6, at the time I was using an older browser.

Has anyone confirmed that the newer browsers have this problem with drupal 6 also?

vinoth.3v’s picture

I can confirm this. I have both D6 and D7 sites running on nginx server behind proxy.
D6 site is working great. But D7 didn't.

I am using latest BB core and tested with FF 17.0.1 and Cromium 22 (Ubuntu 12.10)

jlea9378’s picture

I'm being blocked on another one of my Drupal 7 sites which is hosted on a completely different server by Web Enabled. The site is a Drupal Commons 7 site (uses the latest dev release).
Drupal 7.18
Install profile Commons (commons-7.x-3.0-beta1+12-dev)
Bad Behavior 2.2.13
Database system version 5.1.41-gm2
PHP 5.3.6
Looks like it is a Red Hat EL5 server: 2.6.18-194.26.1.el5.028stab079.1.owl2
Running Apache. I think it is Apache 2.2.15-gm0
Server API CGI/FastCGI

I don't know how Apache and PHP were set up since this is a WebEnabled VPS, but I have root access so I can look in the config files if there is something specific you need me to check.

There are a dozen or so modules installed beyond what comes included in Commons 7, but they shouldn't be relevant based on my experiments with the other site (I was blocked even when using the default Garland theme with all modules disabled). However if you really want a list I can print my Available Updates pages to PDF or something. I don't have access to Drush.

Kutakizukari’s picture

@jlea9378 you can disable the module via drush to get back into the site:

drush dis badbehavior
jlea9378’s picture

Status: Postponed (maintainer needs more info) » Active

I don't have Drush. I used phpMyAdmin to disable badbehavior in the System table but that didn't stop me from being blocked. The only thing that stopped me from being blocked was to rename the library.

@error and @gregarios, I've provided information from two different environments that are having this problem, and some other people have responded with information as well. Any hope of getting this resolved soon?

From what I've seen, it seems to only be an issue on Drupal 7. It worked perfectly (as far as I know) on Drupal6. And it doesn't appear to be anything on the client end (people get blocked no matter what computer or browser they are using, even blocked when using Firefox on the web server's GUI.). It also doesn't appear to be related to other modules present since I still got blocked when using Garland with no modules enabled except BB. I haven't tried it on a FRESH install of Drupal 7 though.

Please let me know if you need more information from me or would like me to try something.

gregarios’s picture

Title: Being blocked by Bad Behavior » Being blocked by Bad Behavior in Drupal 7
Version: 7.x-2.2211 » 7.x-2.x-dev

I'd gladly fix it if I knew the cause.

Unfortunately, I didn't do the port to D7 and don't have any D7 installations to test it on.

If anyone out there can examine the version 7.x-2.x-dev Bad Behavior Drupal module code and come to a conclusion what is causing this, I'll patch it.

vinoth.3v’s picture

Any update on this?

vinoth.3v’s picture

Sorry unable to findout why. Bad behavior :)

kduryee’s picture

Well, I have the same problem as everyone else on a site that's hosted at GoDaddy, (sigh). While I don't have anything really earth shaking to tell anyone, I did find that you can set up a whitelist of IP addresses in sites/all/libraries/bad-behavior. I haven't seen any mention of this handy back door; if you find yourself locked out of your own site and have access to files on the server, you can enter your IP address into the whitelist.ini and regain access to your site.

There is a file contained in the sites/all/libraries/bad-behavior directory called whitelist-sample.ini - change the name to whitelist.ini and then enter your IP address under the digg IP addresses here - I've replaced my own server IP's with x's here:

[ip]
; Digg whitelisted as of 2.0.12
ip[] = "64.191.203.0/24"
ip[] = "208.67.217.130"
; RFC 1918 addresses
ip[] = "10.0.0.0/8"
ip[] = "172.16.0.0/12"
ip[] = "192.168.0.0/16"
; Server IP for running cron.php:
ip[] = "xxx.xxx.xxx.xxx"
; Home computer for testing
 ip[] = "xxx.xxx.xxx.xxx"

Hopefully this issue gets resolved.

vinoth.3v’s picture

The error on my end was, there was a empty Referer in http header!

Nginx + php-fpm

error’s picture

The error on my end was, there was a empty Referer in http header!

That is indeed the immediate cause. The real question is, where is the empty Referer header coming from? I have still not been able to reproduce this, nor did a quick grep of the Drupal source reveal any place that this header might be accidentally set.

Routh’s picture

Well I'm chiming in here with the exact same issue being caused by blank headers in D7.

Drupal: 7.19
NGINX: 1.2.7-0ubuntu0ppa1~precise
PHP-FPM: 5.4
Macached: 1.4.13-0ubuntu2
PHP5-APC: 3.1.7-1

No proxies are in place on my server. Drupal Caching is active. NGINX uses a UNIX socket for communication with PHP-FPM. I have also noted that GoogleBOT and TwitterFeed are being blocked for the same reason, so it's not just users.

Drupal 7 Module list:

cache_bootstrap(bootstrap_modules) was not cleared. APC cli uses a different memory storage then   [warning]
the webserver. For more info see: http://drupal.org/node/1278232
cache_bootstrap(system_list) was not cleared. APC cli uses a different memory storage then the     [warning]
webserver. For more info see: http://drupal.org/node/1278232
cache_bootstrap(bootstrap_modules) was not cleared. APC cli uses a different memory storage then   [warning]
the webserver. For more info see: http://drupal.org/node/1278232
cache_bootstrap(system_list) was not cleared. APC cli uses a different memory storage then the     [warning]
webserver. For more info see: http://drupal.org/node/1278232
 Package             Name                                             Type    Status         Version          
 Access control      ACL (acl)                                        Module  Enabled        7.x-1.0.4-dev    
 Access control      Book access (book_access)                        Module  Not installed  7.x-2.0-rc1      
 Access control      Book access UI (book_access_ui)                  Module  Enabled        7.x-2.0-rc1      
 Access control      Forum Access (forum_access)                      Module  Enabled        7.x-1.2.3-dev    
 Administration      Actions permissions (VBO) (actions_permissions)  Module  Not installed  7.x-3.1.1-dev    
 Administration      Administration Development tools (admin_devel)   Module  Not installed  7.x-3.0-rc4      
 Administration      Administration menu (admin_menu)                 Module  Disabled       7.x-3.0-rc4      
 Administration      Administration menu Toolbar style                Module  Disabled       7.x-3.0-rc4      
                     (admin_menu_toolbar)                                                                     
 Administration      Fasttoggle (fasttoggle)                          Module  Enabled        7.x-1.x-dev      
 Administration      Fasttoggle Comment (fasttogglecomment)           Module  Enabled        7.x-1.x-dev      
 Administration      Fasttoggle Field (fasttogglefield)               Module  Enabled        7.x-1.x-dev      
 Administration      Fasttoggle Node (fasttogglenode)                 Module  Enabled        7.x-1.x-dev      
 Administration      Fasttoggle User (fasttoggleuser)                 Module  Enabled        7.x-1.x-dev      
 Administration      Module filter (module_filter)                    Module  Enabled        7.x-2.x-dev      
 Caching             Varnish (varnish)                                Module  Disabled       7.x-1.0-beta1.3- 
                                                                                             dev              
 Chaos tool suite    Bulk Export (bulk_export)                        Module  Enabled        7.x-1.2.31-dev   
 Chaos tool suite    Chaos tools (ctools)                             Module  Enabled        7.x-1.2.31-dev   
 Chaos tool suite    Chaos Tools (CTools) AJAX Example                Module  Not installed  7.x-1.2.31-dev   
                     (ctools_ajax_sample)                                                                     
 Chaos tool suite    Chaos Tools (CTools) Plugin Example              Module  Not installed  7.x-1.2.31-dev   
                     (ctools_plugin_example)                                                                  
 Chaos tool suite    Custom content panes (ctools_custom_content)     Module  Enabled        7.x-1.2.31-dev   
 Chaos tool suite    Custom rulesets (ctools_access_ruleset)          Module  Enabled        7.x-1.2.31-dev   
 Chaos tool suite    Page manager (page_manager)                      Module  Enabled        7.x-1.2.31-dev   
 Chaos tool suite    Stylizer (stylizer)                              Module  Enabled        7.x-1.2.31-dev   
 Chaos tool suite    Views content panes (views_content)              Module  Enabled        7.x-1.2.31-dev   
 Core                Aggregator (aggregator)                          Module  Enabled        7.19             
 Core                Block (block)                                    Module  Enabled        7.19             
 Core                Blog (blog)                                      Module  Enabled        7.19             
 Core                Book (book)                                      Module  Enabled        7.19             
 Core                Color (color)                                    Module  Enabled        7.19             
 Core                Comment (comment)                                Module  Enabled        7.19             
 Core                Contact (contact)                                Module  Not installed  7.19             
 Core                Content translation (translation)                Module  Enabled        7.19             
 Core                Contextual links (contextual)                    Module  Enabled        7.19             
 Core                Dashboard (dashboard)                            Module  Enabled        7.19             
 Core                Database logging (dblog)                         Module  Enabled        7.19             
 Core                Field (field)                                    Module  Enabled        7.19             
 Core                Field SQL storage (field_sql_storage)            Module  Enabled        7.19             
 Core                Field UI (field_ui)                              Module  Enabled        7.19             
 Core                File (file)                                      Module  Enabled        7.19             
 Core                Filter (filter)                                  Module  Enabled        7.19             
 Core                Forum (forum)                                    Module  Enabled        7.19             
 Core                Help (help)                                      Module  Enabled        7.19             
 Core                Image (image)                                    Module  Enabled        7.19             
 Core                List (list)                                      Module  Enabled        7.19             
 Core                Locale (locale)                                  Module  Enabled        7.19             
 Core                Menu (menu)                                      Module  Enabled        7.19             
 Core                Node (node)                                      Module  Enabled        7.19             
 Core                Number (number)                                  Module  Not installed  7.19             
 Core                OpenID (openid)                                  Module  Enabled        7.19             
 Core                Options (options)                                Module  Enabled        7.19             
 Core                Overlay (overlay)                                Module  Enabled        7.19             
 Core                Path (path)                                      Module  Enabled        7.19             
 Core                PHP filter (php)                                 Module  Enabled        7.19             
 Core                Poll (poll)                                      Module  Enabled        7.19             
 Core                RDF (rdf)                                        Module  Enabled        7.19             
 Core                Search (search)                                  Module  Enabled        7.19             
 Core                Shortcut (shortcut)                              Module  Not installed  7.19             
 Core                Statistics (statistics)                          Module  Enabled        7.19             
 Core                Syslog (syslog)                                  Module  Enabled        7.19             
 Core                System (system)                                  Module  Enabled        7.19             
 Core                Taxonomy (taxonomy)                              Module  Enabled        7.19             
 Core                Testing (simpletest)                             Module  Not installed  7.19             
 Core                Text (text)                                      Module  Enabled        7.19             
 Core                Toolbar (toolbar)                                Module  Enabled        7.19             
 Core                Tracker (tracker)                                Module  Enabled        7.19             
 Core                Trigger (trigger)                                Module  Enabled        7.19             
 Core                Update manager (update)                          Module  Not installed  7.19             
 Core                User (user)                                      Module  Enabled        7.19             
 Date/Time           Date (date)                                      Module  Enabled        7.x-2.6.2-dev    
 Date/Time           Date All Day (date_all_day)                      Module  Not installed  7.x-2.6.2-dev    
 Date/Time           Date API (date_api)                              Module  Enabled        7.x-2.6.2-dev    
 Date/Time           Date Context (date_context)                      Module  Not installed  7.x-2.6.2-dev    
 Date/Time           Date Migration (date_migrate)                    Module  Not installed  7.x-2.6.2-dev    
 Date/Time           Date Popup (date_popup)                          Module  Enabled        7.x-2.6.2-dev    
 Date/Time           Date Repeat API (date_repeat)                    Module  Enabled        7.x-2.6.2-dev    
 Date/Time           Date Repeat Field (date_repeat_field)            Module  Not installed  7.x-2.6.2-dev    
 Date/Time           Date Tools (date_tools)                          Module  Enabled        7.x-2.6.2-dev    
 Date/Time           Date Views (date_views)                          Module  Enabled        7.x-2.6.2-dev    
 Example modules     Variable example (variable_example)              Module  Not installed  7.x-2.2          
 Features            Date Migration Example (date_migrate_example)    Module  Not installed  7.x-2.0          
 Features            Features (features)                              Module  Enabled        7.x-2.0-beta1.5- 
                                                                                             dev              
 Fields              Entity Reference (entityreference)               Module  Enabled        7.x-1.0.4-dev    
 Fields              Entity Reference Behavior Example                Module  Not installed  7.x-1.0.4-dev    
                     (entityreference_behavior_example)                                                       
 Fields              Node Reference (node_reference)                  Module  Enabled        7.x-2.0.9-dev    
 Fields              Node Reference URL Widget (nodereference_url)    Module  Enabled        7.x-1.12         
 Fields              References (references)                          Module  Enabled        7.x-2.0.9-dev    
 Fields              User Reference (user_reference)                  Module  Enabled        7.x-2.0.9-dev    
 Flags               Flag (flag)                                      Module  Enabled        7.x-3.0-alpha4.6 
                                                                                             0-dev            
 Flags               Flag actions (flag_actions)                      Module  Enabled        7.x-3.0-alpha4.6 
                                                                                             0-dev            
 Flags               Flag Bookmark (flag_bookmark)                    Module  Enabled        7.x-3.0-alpha4.6 
                                                                                             0-dev            
 Form Elements       Hierarchical Select (hierarchical_select)        Module  Enabled        7.x-3.0-alpha5.9 
                                                                                             -dev             
 Form Elements       Hierarchical Select Flat List (hs_flatlist)      Module  Enabled        7.x-3.0-alpha5.9 
                                                                                             -dev             
 Form Elements       Hierarchical Select Menu (hs_menu)               Module  Not installed  7.x-3.0-alpha5.9 
                                                                                             -dev             
 Form Elements       Hierarchical Select Small Hierarchy              Module  Enabled        7.x-3.0-alpha5.9 
                     (hs_smallhierarchy)                                                     -dev             
 Form Elements       Hierarchical Select Taxonomy (hs_taxonomy)       Module  Enabled        7.x-3.0-alpha5.9 
                                                                                             -dev             
 Form Elements       Hierarchical Select Taxonomy Views               Module  Not installed  7.x-3.0-alpha5.9 
                     (hs_taxonomy_views)                                                     -dev             
 Input filters       Pathologic (pathologic)                          Module  Enabled        7.x-1.x-dev      
 Mail                Block user messages (pm_block_user)              Module  Enabled        7.x-2.x-dev      
 Mail                HTML Mail (htmlmail)                             Module  Enabled        7.x-2.65.1-dev   
 Mail                Mail MIME (mailmime)                             Module  Enabled        7.x-2.17         
 Mail                Mail System (mailsystem)                         Module  Enabled        7.x-3.0-alpha1   
 Mail                Private messages (privatemsg)                    Module  Enabled        7.x-2.x-dev      
 Mail                Privatemsg Email Notification (pm_email_notify)  Module  Enabled        7.x-2.x-dev      
 Mail                Privatemsg filter (privatemsg_filter)            Module  Enabled        7.x-2.x-dev      
 Mail                Privatemsg Groups (privatemsg_groups)            Module  Not installed  7.x-2.x-dev      
 Mail                Privatemsg Limits (privatemsg_limits)            Module  Enabled        7.x-2.x-dev      
 Mail                Privatemsg Realname Integration                  Module  Not installed  7.x-2.x-dev      
                     (privatemsg_realname)                                                                    
 Mail                Privatemsg roles (privatemsg_roles)              Module  Enabled        7.x-2.x-dev      
 Mail                Privatemsg Rules Integrations                    Module  Enabled        7.x-2.x-dev      
                     (privatemsg_rules)                                                                       
 Mail                SMTP Authentication Support (smtp)               Module  Enabled        7.x-1.0-beta2.7- 
                                                                                             dev              
 Media               File entity (file_entity)                        Module  Enabled        7.x-2.x-dev      
 Media               IMCE (imce)                                      Module  Enabled        7.x-1.7.1-dev    
 Media               Media (media)                                    Module  Enabled        7.x-2.0-unstable 
                                                                                             7.22-dev         
 Media               Media Field (mediafield)                         Module  Not installed  7.x-2.0-unstable 
                                                                                             7.22-dev         
 Media               Media Internet Sources (media_internet)          Module  Enabled        7.x-2.0-unstable 
                                                                                             7.22-dev         
 Multilanguage       Translation helpers (translation_helpers)        Module  Enabled        7.x-1.0          
 Multilingual        Localization client (l10n_client)                Module  Enabled        7.x-1.1          
 Multilingual        Localization update (l10n_update)                Module  Enabled        7.x-1.0-beta3.4- 
                                                                                             dev              
 Multilingual -      Entity Translation (entity_translation)          Module  Enabled        7.x-1.0-beta2.18 
 Entity Translation                                                                          -dev             
 Multilingual -      Entity Translation Menu                          Module  Enabled        7.x-1.0-beta2.18 
 Entity Translation  (entity_translation_i18n_menu)                                          -dev             
 Multilingual -      Entity Translation Upgrade                       Module  Enabled        7.x-1.0-beta2.18 
 Entity Translation  (entity_translation_upgrade)                                            -dev             
 Multilingual -      Block languages (i18n_block)                     Module  Enabled        7.x-1.8.2-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      Contact translation (i18n_contact)               Module  Not installed  7.x-1.8.2-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      Field translation (i18n_field)                   Module  Enabled        7.x-1.8.2-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      Internationalization (i18n)                      Module  Enabled        7.x-1.8.2-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      Menu translation (i18n_menu)                     Module  Enabled        7.x-1.8.2-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      Multilingual content (i18n_node)                 Module  Enabled        7.x-1.8.2-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      Multilingual forum (i18n_forum)                  Module  Enabled        7.x-1.8.2-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      Multilingual select (i18n_select)                Module  Enabled        7.x-1.8.2-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      Path translation (i18n_path)                     Module  Enabled        7.x-1.8.2-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      Rules translation (rules_i18n)                   Module  Enabled        7.x-2.2.5-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      String translation (i18n_string)                 Module  Enabled        7.x-1.8.2-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      Synchronize translations (i18n_sync)             Module  Enabled        7.x-1.8.2-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      Taxonomy translation (i18n_taxonomy)             Module  Enabled        7.x-1.8.2-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      Translation redirect (i18n_redirect)             Module  Enabled        7.x-1.8.2-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      Translation sets (i18n_translation)              Module  Enabled        7.x-1.8.2-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      User mail translation (i18n_user)                Module  Enabled        7.x-1.8.2-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      Variable translation (i18n_variable)             Module  Enabled        7.x-1.8.2-dev    
 Internationalizati                                                                                           
 on                                                                                                           
 Multilingual -      Views translation (i18nviews)                    Module  Enabled        7.x-3.x-dev      
 Internationalizati                                                                                           
 on                                                                                                           
 Other               Advanced Forum (advanced_forum)                  Module  Enabled        7.x-2.x-dev      
 Other               AntiSpam (antispam)                              Module  Enabled        7.x-1.5.9-dev    
 Other               Chain Menu Access API (chain_menu_access)        Module  Enabled        7.x-2.0          
 Other               Code Filter (codefilter)                         Module  Enabled        7.x-1.0.13-dev   
 Other               Echo (echo)                                      Module  Enabled        7.x-1.9          
 Other               Entity API (entity)                              Module  Enabled        7.x-1.0.2-dev    
 Other               Entity tokens (entity_token)                     Module  Enabled        7.x-1.0.2-dev    
 Other               Flat comments (flatcomments)                     Module  Enabled        7.x-2.0.1-dev    
 Other               Follow (follow)                                  Module  Enabled        7.x-2.x-dev      
 Other               Git Deploy (git_deploy)                          Module  Enabled        7.x-2.2.3-dev    
 Other               Gravatar (gravatar)                              Module  Enabled        7.x-1.1.5-dev    
 Other               Imagecache Profile Pictures                      Module  Enabled        7.x-1.0.1-dev    
                     (imagecache_profiles)                                                                    
 Other               Insert (insert)                                  Module  Enabled        7.x-1.2          
 Other               IP address manager (ip)                          Module  Enabled        7.x-1.4          
 Other               Libraries (libraries)                            Module  Enabled        7.x-3.x-dev      
 Other               Mail Editor (mail_edit)                          Module  Enabled        7.x-1.0.7-dev    
 Other               No Current Password (nocurrent_pass)             Module  Enabled        7.x-1.0          
 Other               Node Convert (node_convert)                      Module  Enabled        7.x-1.1.7-dev    
 Other               Pathauto (pathauto)                              Module  Enabled        7.x-1.2.6-dev    
 Other               Qwebirc IRC (qwebirc)                            Module  Enabled        7.x-1.4          
 Other               Redirect (redirect)                              Module  Enabled        7.x-1.0-rc1.3-de 
                                                                                             v                
 Other               Smart Paging (smart_paging)                      Module  Enabled        7.x-1.7.1-dev    
 Other               Social Buttons (social_buttons)                  Module  Enabled        7.x-1.2.2-dev    
 Other               Token (token)                                    Module  Enabled        7.x-1.4.5-dev    
 Other               User Relationships Test module                   Module  Not installed  7.x-1.0-alpha5   
                     (user_relationships_test)                                                                
 Other               User restrictions (user_restrictions)            Module  Enabled        7.x-1.0-beta9    
 Other               User restrictions UI (user_restrictions_ui)      Module  Enabled        7.x-1.0-beta9    
 Other               Variable API (vars)                              Module  Enabled        7.x-2.0-alpha10  
 Performance and     Alternative PHP Cache (apc)                      Module  Enabled        7.19             
 scalability                                                                                                  
 Performance and     HTTP Parallel Request Library (httprl)           Module  Not installed  7.x-1.10         
 scalability                                                                                                  
 Performance and     Memcache (memcache)                              Module  Enabled        7.x-1.0.5-dev    
 scalability                                                                                                  
 Performance and     Memcache Admin (memcache_admin)                  Module  Enabled        7.x-1.0.5-dev    
 scalability                                                                                                  
 Rules               Rules (rules)                                    Module  Enabled        7.x-2.2.5-dev    
 Rules               Rules Scheduler (rules_scheduler)                Module  Enabled        7.x-2.2.5-dev    
 Rules               Rules UI (rules_admin)                           Module  Enabled        7.x-2.2.5-dev    
 Search Toolkit      Apache Solr Access (apachesolr_access)           Module  Enabled        7.x-1.1.34-dev   
 Search Toolkit      Apache Solr autocomplete                         Module  Enabled        7.x-1.3          
                     (apachesolr_autocomplete)                                                                
 Search Toolkit      Apache Solr framework (apachesolr)               Module  Enabled        7.x-1.1.34-dev   
 Search Toolkit      Apache Solr Indexer for Taxonomy                 Module  Enabled        7.x-1.x-dev      
                     (apachesolr_term)                                                                        
 Search Toolkit      Apache Solr Multilingual                         Module  Enabled        7.x-1.0-alpha2.2 
                     (apachesolr_multilingual)                                               7-dev            
 Search Toolkit      Apache Solr Multilingual Config Generator        Module  Not installed  7.x-1.0-alpha2.2 
                     (apachesolr_multilingual_confgen)                                       7-dev            
 Search Toolkit      Apache Solr search (apachesolr_search)           Module  Enabled        7.x-1.1.34-dev   
 Search Toolkit      Apache Solr Users (apachesolr_user)              Module  Enabled        7.x-1.x-dev      
 Search Toolkit      Apachesolr sort (apachesolr_sort)                Module  Enabled        7.x-1.x-dev      
 Search Toolkit      Current Search Blocks (current_search)           Module  Enabled        7.x-1.2          
 Search Toolkit      Facet API (facetapi)                             Module  Enabled        7.x-1.2          
 Spam control        Bad Behavior (badbehavior)                       Module  Enabled        7.x-2.2213       
 Spam control        CAPTCHA (captcha)                                Module  Enabled        7.x-1.0-beta2.15 
                                                                                             -dev             
 Spam control        Image CAPTCHA (image_captcha)                    Module  Enabled        7.x-1.0-beta2.15 
                                                                                             -dev             
 Spam control        reCAPTCHA (recaptcha)                            Module  Enabled        7.x-1.9-rc1      
 Spam control        reCAPTCHA Mailhide (recaptcha_mailhide)          Module  Enabled        7.x-1.9-rc1      
 Statistics          Google Analytics (googleanalytics)               Module  Enabled        7.x-1.2          
 User interface      AJAX Poll (ajax_poll)                            Module  Enabled        7.x-1.1.2-dev    
 User interface      jQuery Update (jquery_update)                    Module  Enabled        7.x-2.3-alpha1   
 User interface      Superfish (superfish)                            Module  Enabled        7.x-1.9-beta5.1- 
                                                                                             dev              
 User interface      User Details (user_details)                      Module  Enabled        7.x-3.1          
 User interface      Wysiwyg (wysiwyg)                                Module  Enabled        7.x-2.2.8-dev    
 User Relationships  User Relationships (user_relationships)          Module  Not installed  7.x-1.0-alpha5   
 User Relationships  User Relationships Blocks                        Module  Not installed  7.x-1.0-alpha5   
                     (user_relationship_blocks)                                                               
 User Relationships  User Relationships Defaults                      Module  Not installed  7.x-1.0-alpha5   
                     (user_relationship_defaults)                                                             
 User Relationships  User Relationships Elaborations                  Module  Not installed  7.x-1.0-alpha5   
                     (user_relationship_elaborations)                                                         
 User Relationships  User Relationships Implications                  Module  Not installed  7.x-1.0-alpha5   
                     (user_relationship_implications)                                                         
 User Relationships  User Relationships Invites                       Module  Not installed  7.x-1.0-alpha5   
                     (user_relationship_invites)                                                              
 User Relationships  User Relationships Mailer                        Module  Not installed  7.x-1.0-alpha5   
                     (user_relationship_mailer)                                                               
 User Relationships  User Relationships Node Access                   Module  Not installed  7.x-1.0-alpha5   
                     (user_relationship_node_access)                                                          
 User Relationships  User Relationships Panels Visibility             Module  Not installed  7.x-1.0-alpha5   
                     (user_relationships_panels_visibility)                                                   
 User Relationships  User Relationships Private Message               Module  Not installed  7.x-1.0-alpha5   
                     (user_relationship_privatemsg)                                                           
 User Relationships  User Relationships Rules                         Module  Not installed  7.x-1.0-alpha5   
                     (user_relationships_rules)                                                               
 User Relationships  User Relationships Services                      Module  Not installed  7.x-1.0-alpha5   
                     (user_relationship_service)                                                              
 User Relationships  User Relationships UI (user_relationships_ui)    Module  Not installed  7.x-1.0-alpha5   
 User Relationships  User Relationships Views                         Module  Not installed  7.x-1.0-alpha5   
                     (user_relationship_views)                                                                
 Variable            Variable (variable)                              Module  Enabled        7.x-2.2          
 Variable            Variable admin (variable_admin)                  Module  Enabled        7.x-2.2          
 Variable            Variable advanced (variable_advanced)            Module  Not installed  7.x-2.2          
 Variable            Variable realm (variable_realm)                  Module  Enabled        7.x-2.x          
 Variable            Variable store (variable_store)                  Module  Enabled        7.x-2.x          
 Variable            Variable views (variable_views)                  Module  Enabled        7.x-2.2          
 Views               Views (views)                                    Module  Enabled        7.x-3.5.37-dev   
 Views               Views Bulk Operations (views_bulk_operations)    Module  Enabled        7.x-3.1.1-dev    
 Views               Views Data Export (views_data_export)            Module  Enabled        7.x-3.0-beta6.25 
                                                                                             -dev             
 Views               Views RSS (views_rss)                            Module  Enabled        7.x-2.0-rc3.3-de 
                                                                                             v                
 Views               Views RSS: Core Elements (views_rss_core)        Module  Enabled        7.x-2.0-rc3.3-de 
                                                                                             v                
 Views               Views RSS: DC Elements (views_rss_dc)            Module  Enabled        7.x-2.0-rc3.3-de 
                                                                                             v                
 Views               Views UI (views_ui)                              Module  Enabled        7.x-3.5.37-dev   
 Voting              Plus 1 (plus1)                                   Module  Enabled        7.x-1.0-alpha1.1 
                                                                                             1-dev            
 Voting              Voting API (votingapi)                           Module  Enabled        7.x-2.10         
 XML sitemap         XML sitemap (xmlsitemap)                         Module  Enabled        7.x-2.0-rc2      
 XML sitemap         XML sitemap custom (xmlsitemap_custom)           Module  Enabled        7.x-2.0-rc2      
 XML sitemap         XML sitemap engines (xmlsitemap_engines)         Module  Enabled        7.x-2.0-rc2      
 XML sitemap         XML sitemap internationalization                 Module  Not installed  7.x-2.0-rc2      
                     (xmlsitemap_i18n)                                                                        
 XML sitemap         XML sitemap menu (xmlsitemap_menu)               Module  Enabled        7.x-2.0-rc2      
 XML sitemap         XML sitemap node (xmlsitemap_node)               Module  Enabled        7.x-2.0-rc2      
 XML sitemap         XML sitemap taxonomy (xmlsitemap_taxonomy)       Module  Enabled        7.x-2.0-rc2      
 XML sitemap         XML sitemap user (xmlsitemap_user)               Module  Enabled        7.x-2.0-rc2      
 Core                Bartik (bartik)                                  Theme   Disabled       7.19             
 Core                Garland (garland)                                Theme   Disabled       7.19             
 Core                Seven (seven)                                    Theme   Enabled        7.19             
 Core                Stark (stark)                                    Theme   Disabled       7.19             
 Other               brightstars (brightstars)                        Theme   Enabled        1.1 
error’s picture

Project: Bad Behavior » Drupal core
Version: 7.x-2.x-dev » 7.22
Component: Code » base system
Assigned: error » Unassigned
Category: support » bug
Priority: Critical » Normal

I finally found the problem. There is actually a bug in the Drupal 7 core.

In function drupal_environment_initialize() in includes/bootstrap.inc, the first three lines are:

if (!isset($_SERVER['HTTP_REFERER'])) {
$_SERVER['HTTP_REFERER'] = '';
}

Referer, if present, MUST NOT be blank, according to RFC 2616, and so whatever reason this was put in for, it needs to be rewritten and/or removed. It interferes with Bad Behavior's check of the Referer value and offers absolutely no benefit to Drupal or anyone else, while inducing RFC-noncompliant behavior.

I presume this was added for Drupal's log entry, below in the same file, but there it is handled correctly, making this particular three lines of code redundant, useless and of course problematic. In fact the correct handling seems to be everywhere but modules/dblog/dblog.test which might fail in mysterious ways after this bug is fixed.

Those of you affected should try removing these erroneous lines of code to see if it causes any other issues.

Reassigning this to Drupal as it is a core issue and not a Bad Behavior module issue.

Luen Warneke’s picture

Yes, this works for me. I have not noticed any issues cause by this change in the drupal core code yet.
Thank you error.

rumblewand’s picture

Commenting line 637 in bootstrap.inc worked for me as indicated in post #61. Should we update the title to reflect the bug?? "HTTP_REFERER" should not be blank" or something?

gregarios’s picture

What is the HTTP_REFERER variable before it gets assigned as "blank" in this case? Null?

error’s picture

Title: Being blocked by Bad Behavior in Drupal 7 » Drupal 7 sets $_SERVER['HTTP_REFERER'] to the empty string when no Referer: header was sent
Issue tags: +Quick fix, +Regression

Before this code sets it to the empty string, the key doesn't exist in $_SERVER. It's not meant to, since the HTTP server never sent it in the first place. And that's because in the case where it doesn't exist, the browser never sent it.

There's a significant semantic difference between the header not being sent, and the header being sent with an empty value. (Specifically, RFC 2616 bans the latter.) This may not be important to Drupal's log, which treats them both the same, but modules such as this one may rely on being able to detect the difference.

As suggested, I've changed the issue title and tags. (Regression, as this behavior was not present in Drupal 6, and Quick fix, since fixing it is a three line change that doesn't appear to break any functionality.)

jlea9378’s picture

Thanks for your diligence and effort in hunting down this bug, error!

phreadom’s picture

Has anyone reported this to drupal core so that we don't have to hack core? (since hacking core is the ultimate no-no in drupal development)

This did indeed fix the problem for me, but I'd really rather not have to change any of my core files.

Hancock Glen’s picture

Ran into the same issue.

If I did a search and found my site via link then I could get to it without being blocked. If I did a direct access, then I was blocked.

Not a programmer but I am behind cloud flare. I do get the IP addresses, I also am getting some visitors while badbehavior is on.

Not sure if that helps or not.

Anonymous’s picture

Version: 7.22 » 7.x-dev
Status: Active » Needs review
FileSize
706 bytes
595 bytes

#61 solves the problem!

Drupal core doesn't use HTTP_REFERER except in three places:

#1 bootstrap.inc function watchdog()
'referer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',

#2 statistics.module
'url' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',

#3 simpletest actions_loop_test.module, function watchdog_skip_semaphore()
'referer' => $_SERVER['HTTP_REFERER'],

Case #1 and #2 are OK, because they use isset() and default to ''.

However, notice how case 3# is a problem! It shoud also do isset()

Attaching 2 patches. One patch for bootstrap.inc, another for simpletest. Does this need a review? Correct me if I'm wrong.

Anonymous’s picture

Indeed the first patch failed, exactly on the HTTP_REFERER in the simpletest.
Attached both in 1 patch.

Damien Tournoud’s picture

Title: Drupal 7 sets $_SERVER['HTTP_REFERER'] to the empty string when no Referer: header was sent » Drupal sets $_SERVER['HTTP_REFERER'] to the empty string when no Referer: header was sent
Version: 7.x-dev » 8.x-dev
Status: Needs review » Patch (to be ported)

The same code exists in Drupal 8. Please port the patch there first.

Anonymous’s picture

Status: Patch (to be ported) » Needs review
FileSize
2.58 KB

Thanks. Attached the D8 devx patch.

Anonymous’s picture

Attached also the final Drupal 7 improved patch (includes dblog.test fixes)

Status: Needs review » Needs work

The last submitted patch, 1824360-73-bootstrap-http-referer-rfc2616-d7.patch, failed testing.

Anonymous’s picture

Status: Needs work » Needs review
FileSize
2.58 KB

Back to D8 for test. Sorry, not used to this.

Status: Needs review » Needs work
Issue tags: -Quick fix, -Regression

The last submitted patch, 1824360-72-bootstrap-http-referer-rfc2616-d8.patch, failed testing.

Anonymous’s picture

Status: Needs work » Needs review
Issue tags: +Quick fix, +Regression
WiredEscape’s picture

Any further progress on this issue? I miss using Bad-behavior...

FSheFF’s picture

The last submitted patch, 73: 1824360-73-bootstrap-http-referer-rfc2616-d7.patch, failed testing.

jollysolutions’s picture

can someone please fix this for drupal 7?

jlea9378’s picture

Please commit to D7. =(

coreyp_1’s picture

Issue summary: View changes

Just wanting to report that #73 worked just fine for my D7 site, although the patch had an offset for Hunk #1 of 4 lines (which may be why it is listed as "failed testing").

For those needing a quick fix, #73 is completely safe.

ParisLiakos’s picture

Status: Needs review » Needs work

The last submitted patch, 75: 1824360-72-bootstrap-http-referer-rfc2616-d8.patch, failed testing.

JieXiannn’s picture

Hi, I'm a D7 user facing the same errors. Which patch should I apply? Is there a secure one?

Thank you.

jlea9378’s picture

The patch in comment #73 should work fine.

JieXiannn’s picture

Sorry if i missed something but didn't #73 fail the test?

The last submitted patch, 73: 1824360-73-bootstrap-http-referer-rfc2616-d7.patch, failed testing.

jlea9378’s picture

I think it failed because the issue is set to Drupal 8, and that patch was for Drupal 7.

Mixologic’s picture

Here's a rerolled d8 patch.

ParisLiakos’s picture

Status: Needs work » Needs review
Mixologic’s picture

Hiding files

ParisLiakos’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

bot agrees, this is good to go

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

  • Commit f6f7472 on 8.x by catch:
    Issue #1824360 by morningtime, Mixologic: Drupal sets $_SERVER['...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

coreyp_1’s picture

Version: 8.x-dev » 7.x-dev
Status: Closed (fixed) » Reviewed & tested by the community

This was patched in 8.x (which, btw, was then removed entirely in the great kernel migration.

Unfortunately, it never made it into 7.x, where it is needed.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 91: 1824360-91-bootstrap-http-referer-rfc2616-d8.patch, failed testing.

dcam’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
2.33 KB

I'm re-uploading #73 so Testbot won't continually re-test the 8.x patch in #91 when I set the issue to RTBC. I am not the author and the patch should not be attributed to me.

The changes are the same as what went into 8.x, with an additional change to another test. Once the patch is applied the code in bootstrap.inc is removed and all instances of $_SERVER['HTTP_REFERER'] in 7.x are checked with isset().

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 100: 1824360-73-bootstrap-http-referer-rfc2616-d7.patch, failed testing.

Status: Needs work » Needs review
dcam’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 100: 1824360-73-bootstrap-http-referer-rfc2616-d7.patch, failed testing.

Status: Needs work » Needs review
dcam’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 100: 1824360-73-bootstrap-http-referer-rfc2616-d7.patch, failed testing.

Status: Needs work » Needs review
dcam’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 100: 1824360-73-bootstrap-http-referer-rfc2616-d7.patch, failed testing.

Status: Needs work » Needs review
dcam’s picture

Status: Needs review » Reviewed & tested by the community
David_Rothstein’s picture

Status: Reviewed & tested by the community » Needs review

This will lead to PHP notices in various contrib modules that expect $_SERVER['HTTP_REFERER'] to be present.

Question: If the patch were changed to do $_SERVER['HTTP_REFERER'] = NULL rather than $_SERVER['HTTP_REFERER'] = '' would that still solve the bug?

BrettSh’s picture

I tried changing this line:
$_SERVER['HTTP_REFERER'] = '';

to this:
$_SERVER['HTTP_REFERER'] = NULL;

Unfortunately, that change didn't fix the problem.

I'm running
- Drupal 7.35
- Bad Behavior module 7.x-2.2216
- Bad Behavior library 2.2.15.

So, pretty recent versions of everything. However, the only thing I found that fixes the problem is patch #73.

BrettSh’s picture

Just out of curiosity, which contrib modules will generate the PHP notice when patched?

Also, what is the notice message?

xiaomo’s picture

Could not apply the patch with git for the latest version of Drupal 7.x . Keep getting directory error. I can confirm patch is in the same directory as the file, weird.

izmeez’s picture

@xiaomo for patches to drupal core the patch must be where your drupal core resides, the same folder as index.php

xiaomo’s picture

Oh, that might've been why. I just manually did it. Thank you for the info.

jollysolutions’s picture

Status: Needs review » Reviewed & tested by the community
David_Rothstein’s picture

Status: Reviewed & tested by the community » Needs review

Just out of curiosity, which contrib modules will generate the PHP notice when patched?

I took a look through a couple codebases and found these possible examples:
http://cgit.drupalcode.org/twitter/tree/twitter_signin/twitter_signin.mo...
http://cgit.drupalcode.org/print/tree/print.pages.inc?h=7.x-2.0#n78
http://cgit.drupalcode.org/print/tree/print_mail/print_mail.inc?h=7.x-2....

I haven't tested those manually, but I assume there are others also.

I'm sympathetic to doing some kind of core fix here since it seems like it should not be an empty string, but setting it explicitly to NULL is a legitimate way in PHP of saying "the value does not exist" so it seems like that should be sufficient.

I took a look at the Bad Behavior library and it seems like the only reason that won't work is that it uses array_key_exists() rather than isset() in a couple places, for example common_tests.inc.php:

if (array_key_exists('Referer', $package['headers_mixed'])) {
	// Referer, if it exists, must not be blank
	if (empty($package['headers_mixed']['Referer'])) {
		return "69920ee5";
	}

and post.inc.php:

// If Referer exists, it should refer to a page on our site
if (!$settings['offsite_forms'] && array_key_exists('Referer', $package['headers_mixed'])) {
	$url = parse_url($package['headers_mixed']['Referer']);

I don't know if there's a good reason they need to use array_key_exists() over isset(), but if not then proposing an upstream patch to change that would help solve this.

Or if that's not feasible, it seems like the Drupal Bad Behavior module could deal with it just by unsetting an empty/NULL $_SERVER['HTTP_REFERER'] before calling into the Bad Behavior library (in fact, it could even do that with or without this core patch)?

error’s picture

@David_Rothstein, please see comments #48, #61 and #65.

David_Rothstein’s picture

@error, yup, but see what I wrote above:

I'm sympathetic to doing some kind of core fix here since it seems like it should not be an empty string, but setting it explicitly to NULL is a legitimate way in PHP of saying "the value does not exist" so it seems like that should be sufficient.

If Drupal 7 weren't released yet it would be one thing, but a lot of code out there does seem to rely on this array key always existing and Drupal 7 has guaranteed that it exists for a long, long time...

  • catch committed f6f7472 on 8.3.x
    Issue #1824360 by morningtime, Mixologic: Drupal sets $_SERVER['...

  • catch committed f6f7472 on 8.3.x
    Issue #1824360 by morningtime, Mixologic: Drupal sets $_SERVER['...
jollysolutions’s picture

Status: Needs review » Reviewed & tested by the community

  • catch committed f6f7472 on 8.4.x
    Issue #1824360 by morningtime, Mixologic: Drupal sets $_SERVER['...

  • catch committed f6f7472 on 8.4.x
    Issue #1824360 by morningtime, Mixologic: Drupal sets $_SERVER['...
David_Rothstein’s picture

Status: Reviewed & tested by the community » Needs work

#120 and #122 still apply. No answers to those, so I'm moving this back to "needs work".