Problem/Motivation

Over in #2599326: Autocomplete function fails when index.html exists - After upgrading to Drupal 7.39 and chaos tools 1.8 there was a commit (#2551236) which attempted to deal with autocomplete not working on servers which weren't configured to automatically recognize index.php; however this change has now broken autocomplete for server configurations which ensure Drupal only receives clean URLs (i.e. requests prefixed with index.php are blocked).

A popular config that behaves this way is perusio's Nginx config for Drupal.

It would of course be possible to update the server config to not block these requests; however this is not the desired behaviour for many system admins, be it for security concerns, information leakage, unclean log files/Google Analytics data, or some other reason that I haven't contemplated thus far.

Also I'm putting this as a feature request rather than a bug report (regression) because David_Rothstein indicated that although blocking index.php has always worked through the life of D7 until now this technically isn't a supported way of doing it.

Proposed resolution

Either:
1) Update the 7.39 security fix so that this prefixing is not necessary (for some reason regular ajax requests don't need to be prefixed so in theory it should be possible somehow).
or
2) Make this behaviour optional by way of allowing a site admin to toggle it on or off.

Regarding (1) it would appear that no-one with the skills and knowledge (security team) has the time or motivation to do this, so (2) would seem to be a logical compromise.

Remaining tasks

  • Write patch
  • Review and test
  • Update documentation

User interface changes

None

API changes

None

Data model changes

None

Comments

MustangGB created an issue. See original summary.

mustanggb’s picture

Issue summary: View changes
StatusFileSize
new2.35 KB

Re-uploading pounard's patch from #2599326-80: Autocomplete function fails when index.html exists - After upgrading to Drupal 7.39 and chaos tools 1.8 , although I can already see it needs work due to spelling and code formatting.

mustanggb’s picture

Status: Active » Needs work

And of course I said it, but forgot the change the status.

pounard’s picture

Thank you for opening the issue, as I stated in the original issue, this security fix actually breaks lots of sites, where we don't want to expose index.php and fully disable and disallow clean URL.

jweowu’s picture

Issue summary: View changes
pacproduct’s picture

Status: Needs work » Needs review
StatusFileSize
new2.36 KB

Re-rolling the patch with minor fixes: variable name + else identation.

Status: Needs review » Needs work

The last submitted patch, 7: autocomplete-security-optional-2749007-7.patch, failed testing.

pacproduct’s picture

Status: Needs work » Needs review
StatusFileSize
new2.37 KB
mustanggb’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

The last submitted patch, 2: autocomplete-security-optional-2599326-80.patch, failed testing.

socialnicheguru’s picture

thank you for this.
I am using Varnish.
none of the autocomplete functionality would work.
this patch and the accompanying addition to settings.php has solved the problem

David_Rothstein’s picture

Status: Reviewed & tested by the community » Needs review

If we're really going to allow people to undo a security feature by setting a variable, this needs some clear documentation of the specific security risks involved.

And we also need to be clear about why we're providing that option. I'm still not 100% clear on it myself, and the issue summary here seems to be intertwining a couple unrelated things. To summarize how I see it:

  1. If the problem is because your server blocks index.php, then you don't need the patch in this issue:
    • You can use https://www.drupal.org/node/2599326#comment-10876408 instead (and someone could easily move that to a contrib module if they wanted) which is a way better solution because it preserves the security fix.
    • Or, you could just stop blocking index.php!... I still haven't seen anyone give a good reason why a server that expects to have PHP web applications running on it should want to block index.php from being accessed. Some of the reasons mentioned in the issue summary here (e.g. "unclean log files/Google Analytics data") should be solved by redirecting index.php requests to strip the "index.php" part out, not blocking them. That's a totally different thing altogether and completely reasonable, and Drupal should already work fine with that.
  2. If the problem is because your server blocks unclean URLs (i.e. prevents requests that look like example.com/?q=some/path from coming to Drupal) then that's a bit of a different story and your problem dates back to the original security release itself. My question would still be similar as above: why not redirect rather than block? (see also #2554203: Security fix in Drupal 7.39 may cause inefficient autocomplete when used with Global Redirect) You probably lose part of the security protection if you redirect (just like if you block), but it's more of a secondary security protection anyway, and then you don't have the problem with autocomplete plus will avoid other potential problems as well.

    I can see more of an argument for the patch in this issue based on people in this situation, but it still sounds like a highly unusual configuration and it would be preferable not to complicate the core code for that. If you really need to block those ?q= requests entirely, any reason not to deal with the autocomplete problem via custom/contrib code too (it should be possible to use hook_element_info_alter() to add another process function that runs after form_process_autocomplete() and switches the URL then)?

David_Rothstein’s picture

Issue tags: +Drupal 7.60 target
joseph.olstad’s picture

Issue tags: -Drupal 7.60 target +Drupal 7.70 target

Bumping to 7.70. This didn't make it into 7.60.

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.