Reverse Proxy Misconfigurations: Nginx
Off By Slash
Nginx matches incoming request URIs against the location blocks defined in your configuration.
location /app/matches requests to/app/,/app/foo,/app/bar/123, etc.location /app(no trailing slash) matches/app*(i.e.,/application,/appfile, etc.),
This means in Nginx, the presence or absence of a slash in a location block changes the matching logic.
server {
location /app/ {
# Handles /app/ and anything below, e.g., /app/foo
}
location /app {
# Handles only /app with nothing after OR routes like /application, /appzzz
}
}Example of a vulnerable configuration: An attacker requesting /styles../secret.txt resolves to /path/styles/../secret.txt
location /styles {
alias /path/css/;
}Missing Root Location
The root /etc/nginx; directive sets the server's root directory for static files.
The configuration doesn't have a root location /, it will be set globally set.
A request to /nginx.conf would resolve to /etc/nginx/nginx.conf.
server {
root /etc/nginx;
location /hello.txt {
try_files $uri $uri/ =404;
proxy_pass http://127.0.0.1:8080/;
}
}
Comments
No comments yet.