How to fix: nginx version disclosed in 404 / error pages
Default nginx error pages and the Server response header expose the exact nginx version (e.g., 'nginx/X.Y.Z'). Knowing the version lets attackers search CVE databases for targeted exploits without any active scanning.
Why it matters
An attacker who knows the exact nginx version can immediately search CVE databases for matching vulnerabilities and known exploits. Version disclosure eliminates the reconnaissance phase and allows a targeted attack without additional probing.
By default, nginx includes its version number in both the Server header and the body of built-in error pages. A single 404 request to a non-existent path reveals the running version. The fix is a single config directive.
How to fix it
- 1Add 'server_tokens off;' to the http block in nginx.conf to suppress the version in headers and error pages.
- 2Optionally strip the Server header entirely at the reverse proxy level.
- 3Use a custom error_page directive for 4xx and 5xx codes to serve a generic error page.
- 4Keep nginx updated regardless of whether the version is disclosed.
Code examples
Nginx (nginx.conf)
http {
# Suppress version from Server header and default error pages
server_tokens off;
server {
listen 443 ssl;
# Custom generic error pages
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /404.html { root /usr/share/nginx/html; internal; }
location = /50x.html { root /usr/share/nginx/html; internal; }
}
}References
Detected automatically by VulnRadar. The check id is nginx-version-404-disclosure, stable across every scan so you can filter or diff on it.
More info disclosure checks
- MediumRails Session Cookie Missing HttpOnly Flag
- InfoServer header truncated
- InfoPHP session cookie naming exposes runtime
- Infoconfig.js / settings.js referenced (verify contents)
- Infoenv.js / environment.js referenced (verify contents)
- InfoSitemap.xml publicly accessible
- InfoOpenAPI schema version exposed in URL
- LowCORS exposes internal CDN hostname
Questions
- How severe is nginx version disclosed in 404 / error pages?
- VulnRadar rates this low severity in the info disclosure category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id nginx-version-404-disclosure, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does nginx version disclosed in 404 / error pages map to?
- It maps to CWE-200. In the OWASP Top 10 it falls under A05:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.