Bug 49131

Summary: Very long URLs cause 404 or 403 errors with SetAction, RewriteRule, RedirectMatch...
Product: Apache httpd-2 Reporter: Alain Knaff <apache>
Component: CoreAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: RESOLVED LATER    
Severity: normal CC: rylach, zwoop
Priority: P2 Keywords: MassUpdate
Version: 2.2.11   
Target Milestone: ---   
Hardware: PC   
OS: Linux   

Description Alain Knaff 2010-04-15 17:50:36 UTC
We've got a virtual host set up where all requests are redirected to a cgi script using SetAction

<Virtualhost *:80>
        ServerName mytest
        DocumentRoot /var/www/mytest

        Options +ExecCGI
        Action all /index.cgi virtual
        <Location /index.cgi>
                SetHandler cgi-script
        </Location>
        SetHandler all
</Virtualhost>

... where index.cgi is just a small example that prints the environment
#!/bin/sh

echo Content-Type: text/plain
echo
printenv


This works ok for small URLs such as

http://mytest/abc.html

However, for very long URLs, weird stuff happens. Often we get a 404, and sometimes a 403.

http://mytest/01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789

It really looks like some kind of buffer overrun...

Same thing with RewriteRule:

<Virtualhost *:80>
        ServerName mytest
        DocumentRoot /var/www/mytest

        RewriteEngine on
        RewriteRule /.* /index.cgi [L]
</Virtualhost>

and:

<Virtualhost *:80>
        ServerName mytest
        DocumentRoot /var/www/mytest

        RedirectMatch /............* /index.cgi
</Virtualhost>
Comment 1 zwoop 2010-07-01 17:13:42 UTC
When I try this, I see a similar problem, but always a 403. My error log says

[Thu Jul 01 14:59:23.126222 2010] [error] [pid 2065:tid 139906479290128] [client ::1:35270] (36)File name too long: access to /aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaassssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssaaaaaaaaaaaabcdefghijklm failed


So, it seems to me that something is "stat"ing names that really aren't files. Do you see a similar error in your logs?
Comment 2 Alain Knaff 2010-07-11 17:26:43 UTC
I do indeed get something similar:

[Sun Jul 11 23:18:11 2010] [error] [client 127.0.0.3] (36)File name too long: access to /01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 failed
Comment 3 William A. Rowe Jr. 2018-11-07 21:10:04 UTC
Please help us to refine our list of open and current defects; this is a mass update of old and inactive Bugzilla reports which reflect user error, already resolved defects, and still-existing defects in httpd.

As repeatedly announced, the Apache HTTP Server Project has discontinued all development and patch review of the 2.2.x series of releases. The final release 2.2.34 was published in July 2017, and no further evaluation of bug reports or security risks will be considered or published for 2.2.x releases. All reports older than 2.4.x have been updated to status RESOLVED/LATER; no further action is expected unless the report still applies to a current version of httpd.

If your report represented a question or confusion about how to use an httpd feature, an unexpected server behavior, problems building or installing httpd, or working with an external component (a third party module, browser etc.) we ask you to start by bringing your question to the User Support and Discussion mailing list, see [https://httpd.apache.org/lists.html#http-users] for details. Include a link to this Bugzilla report for completeness with your question.

If your report was clearly a defect in httpd or a feature request, we ask that you retest using a modern httpd release (2.4.33 or later) released in the past year. If it can be reproduced, please reopen this bug and change the Version field above to the httpd version you have reconfirmed with.

Your help in identifying defects or enhancements still applicable to the current httpd server software release is greatly appreciated.