]> git.kaiwu.me - nginx.git/commit
Upstream: disallow empty path in proxy_store and friends.
authorSergey Kandaurov <pluknet@nginx.com>
Thu, 21 Nov 2024 08:35:50 +0000 (12:35 +0400)
committerpluknet <pluknet@nginx.com>
Mon, 25 Nov 2024 13:37:11 +0000 (17:37 +0400)
commita448dd52ee27ec3a550cb7d03fd27153f4799f0c
tree760dc5862fe9b64f590b03cb7805c5bb6f7d6fd3
parent0864cca4d74e215acdcab20a68e025c6e3ee9efa
Upstream: disallow empty path in proxy_store and friends.

Renaming a temporary file to an empty path ("") returns NGX_ENOPATH
with a subsequent ngx_create_full_path() to create the full path.
This function skips initial bytes as part of path separator lookup,
which causes out of bounds access on short strings.

The fix is to avoid renaming a temporary file to an obviously invalid
path, as well as explicitly forbid such syntax for literal values.

Although Coverity reports about potential type underflow, it is not
actually possible because the terminating '\0' is always included.

Notably, the run-time check is sufficient enough for Win32 as well.
Other short invalid values result either in NGX_ENOENT or NGX_EEXIST
and "MoveFile() .. failed" critical log messages, which involves a
separate error handling.

Prodded by Coverity (CID 1605485).
src/http/modules/ngx_http_fastcgi_module.c
src/http/modules/ngx_http_proxy_module.c
src/http/modules/ngx_http_scgi_module.c
src/http/modules/ngx_http_uwsgi_module.c
src/http/ngx_http_upstream.c