See:

Drupal 7 core is not vulnerable, but porting the fix in .htaccess/web.config files would mitigate the issue when using vulnerable libraries or vulnerable code.

Credit for the D8 version of this patch (the security release):

alexpott, Michael Dowling, mlhess, xjm, Pere Orga, dawehner, greggles, coltrane, pwolanin, larowlan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Pere Orga created an issue. See original summary.

Pere Orga’s picture

Quoting Kurt Seifried:

Please note that the "Proxy" header is not an official standard header, nor
is it in the provisional header registry. The "Proxy" header should not be
used by any standards compliant applications or clients.

Case in point:

http://www.iana.org/assignments/message-headers/message-headers.xhtml

You will note that the "Proxy" header is not there. It's a common
convention to support it, and as it turns out, a bad one (seriously, in
what use case do you want to let a client specify the proxy that a server
then uses to handle outgoing requests?). We also asked several large web
CDN firms to check their logs for the "Proxy" header, and none reported
seeing it used in the wild. Literally the only use case for this header now
is for attackers.

Patch attached. I'm unable to test IIS.

Pere Orga’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: 2768921-2.patch, failed testing.

Pere Orga’s picture

Status: Needs work » Needs review
David_Rothstein’s picture

I closed #2783239: Backport DRUPAL-SA-CORE-2016-003 hardening as a duplicate, but it pointed out via the linked issue that the IIS code that went into Drupal 8 may have problems - so this issue likely needs work for that too.

jfhovinne’s picture

Comment added to web.config.

izmeez’s picture

The addition of a comment line in the patch introduced in #8 is helpful.

And further to comment #7, for clarity, the issue regarding problems with IIS is #2783079: DRUPAL-SA-CORE-2016-003 Completely broke IIS drupal deployments

izmeez’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #8 is favoured because it includes an additional comment line explaining the purpose of the code changes. It looks good and we have been using it for some time without problems.

mcdruid’s picture

Status: Reviewed & tested by the community » Needs work

IIUC if we committed this to D7 there's a risk we'd break IIS deployments in the way outlined by #2783079: DRUPAL-SA-CORE-2016-003 Completely broke IIS drupal deployments (per #7).

So I'd want to see the patch in that issue backported rather than adding the web.config lines which apparently caused problems in IIS.

izmeez’s picture

@mcdruid, Thanks, good catch.

izmeez’s picture

izmeez’s picture

I wonder if a change record will be required for existing sites to alert them that a deployment change may be required for earlier versions of php.

This will not bother users with PHP >= 7 (where the issue does not exist) and will allow users with PHP < 7 to notice that they need to change some deployment setting instead of just breaking their sites.

and

The PHP version thing is just probably reflecting which builds you tested with the latest PHP release... 5.6.23 and 5.5.37 both HTTP poxy fixes ... so does 7.0.8... but all the previous versions are vulnerable.

mcdruid’s picture

I think a CR makes sense for this, yep.

We'll need to call out the changes to .htaccess and web.config in release notes.

I'm not crazy about the formatting / indentation here:

  // Warning for httpoxy on IIS with affected PHP versions                          
  // @see https://www.drupal.org/node/2783079                                       
  if (strpos($software, 'Microsoft-IIS') !== FALSE                                  
    && (                                                                            
    version_compare(PHP_VERSION, '5.5.38', '<')                                     
    || (version_compare(PHP_VERSION, '5.6.0', '>=') && version_compare(PHP_VERSION, '5.6.24', '<'))
    || (version_compare(PHP_VERSION, '7.0.0', '>=') && version_compare(PHP_VERSION, '7.0.9', '<'))
    )) { 

...but it looks like the only thing CodeSniffer complains about is the absence of any punctuation at the end of the comment (first line in snippet above):

523 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses

That could be fixed on commit.

It looks like this should be harmless as the addition to web.config is commented out, but it'd be good to have confirmation of a manual test on IIS. Even better if someone could check the status report when running a vulnerable PHP version, but just a "it doesn't break everything" would be sufficient. I've added a tag accordingly, and will try to find a tester in slack next week if necessary.

mcdruid’s picture

I did a quick manual test in IIS running in an old VM. Confirmed that the (commented out) changes to web.config don't break anything.. which is as we'd expect.

I also checked the status report warning (I cheated and changed the condition so that my PHP version triggered it) and found a couple of small issues; I hadn't spotted that there's a short array syntax copy-paste in the description (perhaps the PHP 5.3 test I've just kicked off will pick that up?). Plus the :variable syntax being used for the link doesn't work in D7 so we get some malformed HTML.

So this patch fixes those minor glitches, and adds the full stop after the comment that I mentioned previously.

I've also tweaked the layout of the long conditional a little; this may just be subjective but I prefer it spanning fewer lines.

izmeez’s picture

@mcdruid Thanks. The patch looks good and the formatting does improve it. Sorry for missing the short arrays on back port from D8. Patch also applies without difficulty on my tests.

izmeez’s picture

I have created a draft change record, https://www.drupal.org/node/3215527

mcdruid’s picture

Thanks for starting the CR.

The changes will not affect sites with PHP >= 7 (where the issue does not exist)

...doesn't match https://www.drupal.org/project/drupal/issues/2783079#comment-11509375 and the logic that we're adding to the requirements check.

If we want to be really helpful, let's show (or link to) the exact changes being made to .htaccess and web.config to make it easier for those to be manually applied to any customised versions of those files.

mcdruid’s picture

Status: Needs review » Reviewed & tested by the community

Taking #19 as RTBC :)

mcdruid’s picture

Issue tags: +Pending Drupal 7 commit
izmeez’s picture

I've modified the change record and decided to show the changes made to .htaccess and web.config rather than the extra step of a link. It's still a draft and open for improvements.

Fabianx’s picture

RTBC + 1, patch looks good and security hardening is a good idea

mcdruid credited alexpott.

mcdruid credited coltrane.

mcdruid credited dawehner.

mcdruid credited greggles.

mcdruid credited larowlan.

mcdruid credited mlhess.

mcdruid credited pwolanin.

mcdruid credited xjm.

mcdruid’s picture

mcdruid credited catch.

mcdruid’s picture

  • mcdruid committed 1402310 on 7.x
    Issue #2768921 by izmeez, mcdruid, Pere Orga, jfhovinne, alexpott,...
mcdruid’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs change record, -Pending Drupal 7 commit

Thank you everybody!

Status: Fixed » Closed (fixed)

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