You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OS: MacOS 13.4.1; Windows 11; Ubuntu 20.04
Zola version: 0.17.2
Expected Behavior
Application should only search & serve files within the webserver's root folder.
Current Behavior
Custom implementation of a web server, used for development purposes & available via zola serve command is vulnerable to a directory traversal. handle_request function performs insufficient checks over the user-supplied path in a HTTP request to the server
The application only checks for a trusted path prefix, but does not actually fully resolve the path. Since the webroot directory is prepended to each path, this check will always be bypassed:
let root_path = PathBuf::from("/trusted_prefix/../../some/arbitrary/path");
let trusted_prefix = "/trusted_prefix";
root_path.starts_with(trusted_prefix); <-- true
Thus is possible to utilize path control sequences (/, ..) to escape the webroot & read arbitrary files off the FS of the machines running zola serve command.
Step to reproduce (UNIX)
Install zola
Run zola init poc && cd poc
Run zola serve
Use curl > 7.42 to trigger the path traversal via the following command: curl --path-as-is "http://localhost:1111/../../../../../../../../../../etc/passwd" -vvv
Successful explotation should yield contents of the /etc/passwd file
The text was updated successfully, but these errors were encountered:
Bug Report
Environment
OS: MacOS 13.4.1; Windows 11; Ubuntu 20.04
Zola version: 0.17.2
Expected Behavior
Application should only search & serve files within the webserver's root folder.
Current Behavior
Custom implementation of a web server, used for development purposes & available via
zola serve
command is vulnerable to a directory traversal.handle_request
function performs insufficient checks over the user-supplied path in a HTTP request to the serverzola/src/cmd/serve.rs
Line 120 in 695c17d
The application only checks for a trusted path prefix, but does not actually fully resolve the path. Since the webroot directory is prepended to each path, this check will always be bypassed:
Thus is possible to utilize path control sequences (
/
,..
) to escape the webroot & read arbitrary files off the FS of the machines runningzola serve
command.Step to reproduce (UNIX)
zola init poc && cd poc
zola serve
curl --path-as-is "http://localhost:1111/../../../../../../../../../../etc/passwd" -vvv
Successful explotation should yield contents of the

/etc/passwd
fileThe text was updated successfully, but these errors were encountered: