Skip to main content
LowAPIOWASP A05:2021CWE-200

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

  1. 1Generate environment-specific OpenAPI documents; exclude internal hosts from the public document
  2. 2Use relative server URLs (/ or /api) in the public-facing document
  3. 3Strip servers[] from public docs using a build-time transform or swagger-combine

Code examples

OpenAPI 3.0: relative server URL (safe)

YAML
openapi: '3.0.3'
info:
  title: My API
  version: '1.0'
servers:
  - url: /api/v1
    description: Current deployment

Node.js: strip internal servers at runtime

JavaScript
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.

See every api check

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.

Propose a checkHow a check is built

Scan your own site for openapi server url leaks internal host

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

OpenAPI server URL leaks internal host fix | VulnRadar