I have the following nginx configuration:
server
{
listen 80 default;
listen [::]:80 default_server ipv6only=on;
server_name _;
root /home/user/websites/$host;
index index.html;
}
This simplifies the configuration (for my needs), and if I want to serve a new domain or subdomain, I just create the folder /home/user/websites/sub.domain.tld/
.
My question is, with this kind of setup, is there any possible way that a malicious user could send an erroneous Host
header, and traverse the directory structure?
I have tried the following:
$ curl --header "Host: ../testing" ip.address
For which nginx returns 400 Bad Request
as expected. Are there any other ways this might be circumvented, or does nginx protect against this kind of attack?