Skip to main content
MediumAPIOWASP A02:2021CWE-319

How to fix: OpenAPI document publishes a cleartext base URL

The served API description publishes a public base URL over plain http rather than https. That is either an OpenAPI 3 servers entry, or a Swagger 2.0 schemes list containing http and not https.

Why it matters

Every SDK, mock server, and gateway generated from this document targets the cleartext URL by default. Requests built that way carry the API key or bearer token in plaintext over the network, and an on-path attacker can read the credential and rewrite the response before the client sees it.

This is specifically about a publicly routable http:// base URL. Localhost, RFC1918 and staging or internal hostnames are excluded here because those are reported separately as an internal-server-URL leak. A redirect from :80 to :443 does not make this safe: the first request, with its Authorization header, has already been sent in the clear.

How to fix it

  1. 1Change every servers[].url in the document to https://.
  2. 2For Swagger 2.0, set schemes: [https] and remove http.
  3. 3Regenerate and republish any SDKs built from the old document, since the base URL is usually baked into the generated client.

Code examples

OpenAPI 3: https base URLs only

YAML
servers:
  - url: https://api.example.com/v1
    description: Production
  - url: https://sandbox.example.com/v1
    description: Sandbox

Swagger 2.0: drop the http scheme

YAML
swagger: '2.0'
host: api.example.com
basePath: /v1
schemes:
  - https

References

Detected automatically by VulnRadar. The check id is api-openapi-server-url-plain-http, stable across every scan so you can filter or diff on it.

See every api check

Questions

How severe is OpenAPI document publishes a cleartext base URL?
VulnRadar rates this medium 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-plain-http, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does OpenAPI document publishes a cleartext base URL map to?
It maps to CWE-319. In the OWASP Top 10 it falls under A02: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 document publishes a cleartext base url

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 document publishes a cleartext base URL | VulnRadar