Difficulty: Beginner
Why should you hide version information such as the 'Server: nginx/1.14.0' header, and what else counts as information disclosure?
Information disclosure is when an application reveals details that help an attacker without being a breach on its own. A header like Server: nginx/1.14.0 or X-Powered-By: PHP/7.2.1 tells an attacker your exact software versions, so they can look up known CVEs and go straight to a working exploit instead of probing blindly. Hiding it does not make you secure, but it removes a free hint and raises the effort required.
Attackers and automated scanners fingerprint a target first, then match versions to public vulnerability databases. If your banner says the exact version, a scanner can instantly flag every known flaw for that build. This is reconnaissance, the first stage of almost every attack. Removing the banner is cheap defence in depth: it will not stop a determined attacker who can fingerprint behaviour anyway, but it slows casual scanning and mass exploitation.
server_tokens off; hides the version (nginx cannot fully remove the Server word without a module, but it drops the version).ServerTokens Prod and ServerSignature Off.app.disable('x-powered-by') or use Helmet.Version banners are the mildest form. More serious leaks include:
| Leak | Why it is dangerous |
|---|---|
| Stack traces and debug pages | Reveal file paths, library versions, SQL and internal logic |
| Verbose errors | 'User not found' vs 'wrong password' enables username enumeration |
| Directory listing enabled | Exposes backup files, .git folders, config |
| Secrets in client code or source maps | API keys and endpoints shipped to the browser |
| Detailed timing differences | Can leak whether a record exists |
| Comments and metadata | Internal hostnames, developer notes, TODOs in HTML or docs |
Some of these are far worse than a banner. A leaked .env file or an exposed .git directory can hand over database credentials or the full source code.
.git and .env.DEBUG=True on in production, which turns every error into a detailed report..env or leaving .git web-accessible.| Aspect | Leaky | Hardened | |
|---|---|---|---|
| Server header | nginx/1.14.0 | nginx (no version) | |
| Error page | Full stack trace | Generic error, detail logged | |
| Login failure | User not found | Invalid credentials | |
| Directory listing | Enabled | Disabled | |
| Dotfiles | .git and .env reachable | Blocked at the edge |
# nginx.conf: hide the nginx version in the Server header and errors
http {
server_tokens off;
}
# block access to hidden files like .git, .env, .htaccess
location ~ /\.(?!well-known) {
deny all;
return 404;
}
server_tokens off removes the version from the Server header and error pages, and the location block stops the web server from serving dotfiles such as .git and .env.
Information Disclosure, Attack Surface, Server Hardening, Fingerprinting