-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Cannot get REQUEST_FILENAME with %3f (encoded ?) in url path #2705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Current source codes. size_t pos_query = m_uri_decoded.find("?");
/* ... skip multi lines ... */
std::string path_info;
if (pos_query == std::string::npos) {
path_info = std::string(m_uri_decoded, 0);
} else {
path_info = std::string(m_uri_decoded, 0, pos_query);
}
if (var_size == std::string::npos) {
var_size = uri_s.size();
} |
It has been a longstanding practice to do some automatic url decoding of REQUEST_FILENAME. One of the reasons that REQUEST_URI_RAW exists is so that an entirely undecoded string is available for those (expected to be very rare) occasions when that is needed. Because of the availability of an alternative, the long history of decoding, as well as basic matching of web server behaviour, it probably wouldn't be a good idea for us to consider changing this functionality to never automatically perform url of REQUEST_FILENAME. That said, the current v3 behaviour does result in two anomalies. The first of these is what has been highlighted by the OP in this ticket: that if the path portion of the uri contains a literal '?' character (encoded in the request as %3b) then ModSecurity will truncate the REQUEST_FILENAME. This would qualify as a bug, but presumably one that would occur so rarely as to be almost never. A second sub-issue is perhaps less of a true bug, but at least a notable difference from ModSecurity v2 behaviour. In that version, the REQUEST_FILENAME variable is indeed decoded if accessed in a phase:2 rule, but it is undecoded in a phase:1 rule. |
I get the same bug (I've been loosing a lot of time on that) when the query string value contains |
Hi @nitriques,
Which version do you use? It was fixed in libmodsecurity3 version 3.0.12 with PR #3048. |
Sorry, but I do not know how to find that. I run a whm/cpanel server. Do you have a quick way to get it ? I can ssh/run command as root. Thanks !!! |
I have this:
Looks like cpanel is still distributing v2... |
I have a reverse-proxy in front of the Apache webserver, and I was able to replace all I writting this for people coming in from google like I did a couple of days ago ;) |
Don't you have an entry in the error log? |
@marcstern
Wow, which I knew about that sooner. Is it available in v2 ? |
UnsafeAllow3F is a new parameter for RewriteRule (mod_rewrite) |
@marcstern Oh I see! Thanks for the info, might look into it. |
Describe the bug
If the url path contains %3f, cannot get real
REQUEST_FILENAME
.Logs and dumps
To Reproduce
Test for path:
/path1%3fpath2?query=%3f
Expected behavior
Return urldecoded or original filename.
Server (please complete the following information):
Rule Set (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: