RewriteRule of "^$" is broken
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Apache2 Web Server |
Unknown
|
Unknown
|
|||
apache2 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Trusty |
Won't Fix
|
Medium
|
Wesley Wiedenmeier |
Bug Description
[Test Case]
Setup
Apache 2.4.7
* mod_rewrite
* mod_ajp
* mod_dir
Tomcat
* Listening on Port 9001
Apache with a .htaccess in the example.net VirtualHost
RewriteEngine On
RewriteRule ^(.*)$ ajp://localhost
Expected:
Return from Tomcat
HTTP Status 404 - /
Reality:
Return from Tomcat
HTTP Status 404 - /index.html
Workaround for this particular setup was to either disable mod_dir or disable DirectoryIndex in .htaccess.
Or on VirtualHost context use ProxyPass.
ProxyPass / ajp://localhost
ProxyPassReverse / ajp://localhost
[Impact]
With DirectoryIndex disabled:
<pre>
[Thu Apr 30 13:55:18.761066 2015] [rewrite:trace3] [pid 31422] mod_rewrite.c(468): [client XXX.XXX.
[Thu Apr 30 13:55:18.761191 2015] [rewrite:trace3] [pid 31422] mod_rewrite.c(468): [client XXX.XXX.
[Thu Apr 30 13:55:18.761215 2015] [rewrite:trace2] [pid 31422] mod_rewrite.c(468): [client XXX.XXX.
[Thu Apr 30 13:55:18.761232 2015] [rewrite:trace2] [pid 31422] mod_rewrite.c(468): [client XXX.XXX.
[Thu Apr 30 13:55:18.761245 2015] [rewrite:trace2] [pid 31422] mod_rewrite.c(468): [client XXX.XXX.
[Thu Apr 30 13:55:18.761259 2015] [rewrite:trace1] [pid 31422] mod_rewrite.c(468): [client XXX.XXX.
</pre>
With DirectoryIndex enabled:
<pre>
[Thu Apr 30 13:58:37.954876 2015] [rewrite:trace3] [pid 31419] mod_rewrite.c(468): [client XXX.XXX.
[Thu Apr 30 13:58:37.954930 2015] [rewrite:trace3] [pid 31419] mod_rewrite.c(468): [client XXX.XXX.
[Thu Apr 30 13:58:37.954947 2015] [rewrite:trace2] [pid 31419] mod_rewrite.c(468): [client XXX.XXX.
[Thu Apr 30 13:58:37.954959 2015] [rewrite:trace2] [pid 31419] mod_rewrite.c(468): [client XXX.XXX.
[Thu Apr 30 13:58:37.954968 2015] [rewrite:trace2] [pid 31419] mod_rewrite.c(468): [client XXX.XXX.
[Thu Apr 30 13:58:37.954977 2015] [rewrite:trace1] [pid 31419] mod_rewrite.c(468): [client XXX.XXX.
[Thu Apr 30 13:58:37.955023 2015] [rewrite:trace3] [pid 31419] mod_rewrite.c(468): [client XXX.XXX.
[Thu Apr 30 13:58:37.955036 2015] [rewrite:trace3] [pid 31419] mod_rewrite.c(468): [client XXX.XXX.
[Thu Apr 30 13:58:37.955076 2015] [rewrite:trace2] [pid 31419] mod_rewrite.c(468): [client XXX.XXX.
[Thu Apr 30 13:58:37.955086 2015] [rewrite:trace2] [pid 31419] mod_rewrite.c(468): [client XXX.XXX.
[Thu Apr 30 13:58:37.955094 2015] [rewrite:trace2] [pid 31419] mod_rewrite.c(468): [client XXX.XXX.
[Thu Apr 30 13:58:37.955103 2015] [rewrite:trace1] [pid 31419] mod_rewrite.c(468): [client XXX.XXX.
</pre>
[Regression Potential]
As stated on the apache bugtracker https:/
"The behavior now seems to be consistent with 2.2, and a rewrite rule that conflicts with a DirectoryIndex gets applied."
The default value of the new configuration option does change behaviour so there is a chance that this could be undesirable for some users. However, this is a very small chance, as the current default behaviour is only present in apache versions between 2.4 and 2.4.8 when the fix was introduced upstream. Behaviour can be kept consistent with current behaviour by setting "DirectoryCheck
[Original Description]
Ubuntu 14.04LTS x86_64
In apache 2.4.7 there is a bug in mod_dir, in that it does not stop when the URL has just been rewritten by mod_rewrite.
If you have rewrite rules in .htaccess, ending in a [P] for an external URL, rule execution should stop and mod_proxy should go and fetch the given URL. Instead, mod_dir fires another round of rewrite rule checks as it looks for .../index.html, possibly giving completely different results (e.g. not fetching from remote site).
http://
...
*) mod_dir: Don't search for a DirectoryIndex or DirectorySlash on a
URL that was just rewritten by mod_rewrite. PR53929. [Eric Covener]
...
http://
Please backport the for PR53929
(or update apache package to 2.4.9)
CVE References
tags: | added: bitesize |
tags: | added: server-next |
Changed in apache2 (Ubuntu Trusty): | |
assignee: | nobody → Wesley Wiedenmeier (wesley-wiedenmeier) |
tags: | removed: server-next |
description: | updated |
tags: |
added: trusty verification-done removed: apache rewrite verification-needed |
As reported the problem was solved upstream by Apache.
This is the bugreport : /bz.apache. org/bugzilla/ show_bug. cgi?id= 53929
https:/
Please use the provided patch: /bz.apache. org/bugzilla/ attachment. cgi?bugid= 53929&action= viewall
https:/
As this bug is really impacting the way mod_rewrite works (works incorrectly) this fix would be very much appreciated.
After upgrading a couple of servers to use Ubuntu 14.04 / Apache 2.4.7, we now have a lot of mod_rewrite problems. (a lot as in many websites).