]> git.kaiwu.me - nginx.git/commit
Dav: destination validation for COPY and MOVE with "alias".
authorMaxim Dounin <mdounin@mdounin.ru>
Fri, 11 Sep 2026 15:18:36 +0000 (08:18 -0700)
committerVadimZhestikov <108960056+VadimZhestikov@users.noreply.github.com>
Tue, 15 Sep 2026 23:31:12 +0000 (16:31 -0700)
commit3dbce28821179082f27daaa13bf0d5ada548fd20
tree3cdef8708a957bb6fb56ee14e9c489ce4fd18171
parent0a5db852e18d1c22c62a5ede1412ac3f416111a0
Dav: destination validation for COPY and MOVE with "alias".

If COPY or MOVE methods are enabled, the DAV module assumes that it is
configured for the whole server, and does not try validate that the
destination URI is within the particular location.  This, however, does
not work well if it is in fact configured in a non-root location, and
this location uses the "alias" directive, such as in the following
configuration:

    location /prefix/ {
        dav_methods COPY;
        alias /foo/;
    }

In particular, if the destination URI is shorter than the aliased
location prefix, calling ngx_http_map_uri_to_path() with such
destination URI used to result in segmentation faults (9739e755b).  And
if the destination URI is longer than the aliased location prefix, but
does not match it, calling ngx_http_map_uri_to_path() resulted in
unexpected path values, including ones above the "alias" directory
specified.

The fix is to check destination URI prefix if "alias" is used, similarly
to what we do with "try_files".  Additionally, the
ngx_http_map_uri_to_path() function was updated with additional sanity
checking to prevent similar issues.

This change is a modified version of a patch by Maxim Dounin.  The
modifications include skipping the prefix check if the URI was
rewritten, which preserves the "alias" diagnostics of
ngx_http_map_uri_to_path().

Signed-off-by: Vadim Zhestikov <v.zhestikov@f5.com>
Origin: <https://freenginx.org/hg/nginx/rev/aae28b083279>
src/http/modules/ngx_http_dav_module.c
src/http/ngx_http_core_module.c