How to fix: OpenAPI server URL leaks internal host
swagger.json often contains the internal / staging host in the 'servers' array.
Why it matters
Internal hostnames in public OpenAPI documents reveal network topology, staging infrastructure, and internal DNS naming conventions, information that aids targeted reconnaissance and phishing attacks against internal services.
swagger.json often contains the internal / staging host in the 'servers' array.
How to fix it
- 1Generate environment-specific OpenAPI documents; exclude internal hosts from the public document
- 2Use relative server URLs (/ or /api) in the public-facing document
- 3Strip servers[] from public docs using a build-time transform or swagger-combine
Code examples
OpenAPI 3.0: relative server URL (safe)
openapi: '3.0.3'
info:
title: My API
version: '1.0'
servers:
- url: /api/v1
description: Current deploymentNode.js: strip internal servers at runtime
import swaggerDoc from './openapi.json';
const publicDoc = {
...swaggerDoc,
servers: swaggerDoc.servers?.filter(
(s) => !s.url.includes('internal') && !s.url.includes('staging')
) ?? [{ url: '/api/v1' }],
};References
Detected automatically by VulnRadar. The check id is api-openapi-server-url-leak, 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
- LowCORS preflight result not cached
- HighBearer token in URL query string
- MediumJSONP callback parameter accepted
- InfoPUT method listed in Allow header
Questions
- How severe is OpenAPI server URL leaks internal host?
- 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-openapi-server-url-leak, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does OpenAPI server URL leaks internal host 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.