How to fix: WWW-Authenticate realm leaks internal detail
The WWW-Authenticate challenge carries a realm string that describes internal infrastructure. The value contains a filesystem path, an IP address, or an internal hostname suffix.
Why it matters
The realm is shown to anyone who requests the resource, including in the browser's own credential prompt. A realm like "/var/www/internal-admin" or "backup-01.corp" hands over the server's directory layout or an internal hostname before any credential is supplied, and it tells an attacker which part of the estate they have reached.
Realms usually pick up these values because the web server defaults to the protected directory path, or because someone used the machine name as a label. The realm has exactly one functional job: it lets a client group credentials that work in the same protection space. A short, opaque, stable label does that job without describing the infrastructure.
How to fix it
- 1Replace the realm with a short opaque label that names the service, not the path or the host.
- 2Keep the value stable, since clients cache credentials against it.
- 3Check the web server's default: Apache and Nginx templates often interpolate the directory being protected.
Code examples
Nginx: opaque realm
location /admin/ {
auth_basic "restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
}Express: opaque realm on the challenge
res.set('WWW-Authenticate', 'Bearer realm="api", error="invalid_token"');
res.status(401).end();References
Detected automatically by VulnRadar. The check id is api-www-authenticate-realm-internal-detail, stable across every scan so you can filter or diff on it.
More api checks
- LowTRACE method referenced in API response body
- InfoREST endpoint allows DELETE
- LowGraphQL introspection field suggestions
- MediumGraphQL endpoint has no rate-limit headers
- LowOpenAPI server URL leaks internal host
- LowCORS preflight result not cached
- HighBearer token in URL query string
- MediumJSONP callback parameter accepted
Questions
- How severe is WWW-Authenticate realm leaks internal detail?
- VulnRadar rates this low severity in the api 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 api-www-authenticate-realm-internal-detail, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does WWW-Authenticate realm leaks internal detail 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.