How to fix: OpenAPI schema version exposed in URL
The OpenAPI or Swagger schema version is exposed in the URL or response body. Pinning a specific schema version in the URL or body makes it easy for attackers to identify whether the API is running a release with known vulnerabilities.
Why it matters
Exposing the exact API schema version helps attackers identify whether the running version has known vulnerabilities. Older pinned Swagger/OpenAPI versions may have documented parser or injection vulnerabilities, and the version string itself confirms which generation of the API is active.
OpenAPI and Swagger UI bundle version numbers in URLs like /openapi-v2.json or in the schema's info.version field. While API versioning is necessary, exposing it in a way that maps directly to a library or tooling release aids targeted reconnaissance.
How to fix it
- 1Use path-based API versioning (/api/v1/, /api/v2/) rather than embedding the OpenAPI schema version in the URL.
- 2Restrict access to the raw schema endpoint to authenticated users or internal networks only.
- 3Serve a generic URL like /api/schema rather than /openapi-v3.1.0.json.
- 4Keep Swagger UI and OpenAPI tooling up to date regardless of version exposure.
Code examples
Express.js (restrict schema access)
// Only expose the schema to authenticated users or internal IPs
app.get('/api/schema', requireAuth, (req, res) => {
res.sendFile(path.join(__dirname, 'openapi.json'));
});
// Use path versioning, not schema versioning in URL
// Good: /api/v2/users
// Avoid: /openapi-v2.1.jsonNginx (block public schema access)
location ~* /(?:openapi|swagger)[^/]*\.json$ {
# Allow only internal networks
allow 10.0.0.0/8;
allow 172.16.0.0/12;
allow 192.168.0.0/16;
deny all;
}References
Detected automatically by VulnRadar. The check id is open-api-schema-version-leak, stable across every scan so you can filter or diff on it.
More info disclosure checks
- MediumRails Session Cookie Missing HttpOnly Flag
- InfoServer header truncated
- InfoPHP session cookie naming exposes runtime
- Infoconfig.js / settings.js referenced (verify contents)
- Infoenv.js / environment.js referenced (verify contents)
- InfoSitemap.xml publicly accessible
- LowCORS exposes internal CDN hostname
- InforeCAPTCHA site key exposure
Questions
- How severe is OpenAPI schema version exposed in URL?
- VulnRadar rates this info severity in the info disclosure 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 open-api-schema-version-leak, which stays the same between runs so you can filter, diff, or gate CI on it.
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.