Description
MODSEC-385: (Same behavior which was written in https://www.modsecurity.org/tracker/browse/MODSEC-183.)
Basically the problem is that, although the right status code returns to the client, the appropriate ErrorDocument doesn't appear in a browser. Furthermore, there are no indication in strace that apache even tried to open any ErrorDocument page.
Setup:
Apache config has ErrorDocument 403 /error/403.html
Basic modsecurity configuration, two more line added:
SecRule REQUEST_URI attack "id:'1',phase:1,log,deny,status:403"
SecRule RESPONSE_STATUS "@eq 500" "phase:4,deny,status:403,id:1111"
Response to the first:
http://s18.postimage.org/hmr0y4sax/custom403working.png
Text form:
"http://192.168.110.139/attack
403
This is my custom error message page, every 403 should be end up with this. "
Response to the second:
http://s18.postimage.org/l530uit6x/custom403notworking.png
Text form:
"http://192.168.110.139/test.php
Forbidden
You don't have permission to access /test.php on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.22 (Ubuntu) Server at 192.168.110.139 Port 80"
Test.php (this triggers an Error 500):
It seems, in Phase 4 (as a matter of fact Phase 3 produces the same) response rewrite can't end on a custom ErrorDocument page for some reason. Even funnier, if I modify the line for the sake of testing as below:
SecRule RESPONSE_STATUS "@eq 500" "phase:4,deny,status:200,id:1111"
Response:
OK
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 200 OK error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.22 (Ubuntu) Server at 192.168.110.139 Port 80
If you need any more information please let me know.