mirror of
https://github.com/nginx/nginx.git
synced 2026-06-27 12:21:57 +00:00
Detect more unsafe URIs in ngx_http_parse_unsafe_uri().
The following URIs were considered safe: "..", "../foo", and "/foo/..".
This commit is contained in:
parent
3f36c684a1
commit
336bcb22d1
1 changed files with 7 additions and 3 deletions
|
|
@ -1790,7 +1790,9 @@ ngx_http_parse_unsafe_uri(ngx_http_request_t *r, ngx_str_t *uri,
|
|||
goto unsafe;
|
||||
}
|
||||
|
||||
if (p[0] == '.' && len == 3 && p[1] == '.' && (ngx_path_separator(p[2]))) {
|
||||
if (p[0] == '.' && len > 1 && p[1] == '.'
|
||||
&& (len == 2 || ngx_path_separator(p[2])))
|
||||
{
|
||||
goto unsafe;
|
||||
}
|
||||
|
||||
|
|
@ -1816,9 +1818,11 @@ ngx_http_parse_unsafe_uri(ngx_http_request_t *r, ngx_str_t *uri,
|
|||
|
||||
if (ngx_path_separator(ch) && len > 2) {
|
||||
|
||||
/* detect "/../" */
|
||||
/* detect "/../" and "/.." */
|
||||
|
||||
if (p[0] == '.' && p[1] == '.' && ngx_path_separator(p[2])) {
|
||||
if (p[0] == '.' && p[1] == '.'
|
||||
&& (len == 3 || ngx_path_separator(p[2])))
|
||||
{
|
||||
goto unsafe;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue