Join our Newsletter — 33% off our NHI Course
Home› Guides› How to find exposed OpenAPI and Swagger documentation…
Guide Web & API Security

How to find exposed OpenAPI and Swagger documentation for your APIs: discover, assess and close them

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 28 November 2026 11 min read
On this page

An OpenAPI description or Swagger UI page left reachable on a production or forgotten staging host hands anyone a complete map of your API, often including internal and admin operations, example values and a working "Try it out" console. The exposed document is rarely the vulnerability itself, but it shortens an attacker's reconnaissance and frequently reveals hosts and versions missing from your own inventory. This guide is a practical check: the default paths each common framework publishes, how to sweep your own estate for them, how to decide which exposures are acceptable, and how to lock down or remove the rest. It is for application security engineers, API platform owners and penetration testers working on authorised scopes. Securing the content of the specification is covered in the OpenAPI Specification Security Guide; this page is about finding where it is published.

Key takeaways

  • Frameworks publish docs at predictable paths. FastAPI serves /openapi.json, /docs and /redoc by default, springdoc serves /v3/api-docs and /swagger-ui.html, and ASP.NET Core uses /swagger/v1/swagger.json or /openapi/v1.json; a scan of those paths across every host finds most exposures.
  • Public docs are not automatically a finding. A partner or public API may publish its description on purpose; the problem is internal, admin or undocumented operations exposed on hosts nobody owns.
  • Hiding docs is not access control. FastAPI's own documentation warns that disabling the docs does not secure the endpoints behind them; fix authorisation first, then decide on visibility.
  • Each finding is an inventory gap. A Swagger page on a host your API inventory does not list is evidence of a shadow or zombie API, which is OWASP API9:2023 territory.
  • Make the check continuous. New services ship with defaults on, so add path checks to external attack surface scans and to the CI pipeline.

Why exposed documentation matters

OWASP's API9:2023 Improper Inventory Management describes a "documentation blindspot" where nobody can say which environment a host runs in, who should reach it or which version is live, and notes that search engines, DNS enumeration and specialised device search engines are enough to discover such hosts. An exposed description makes that discovery richer. Typical problems found on review:

  • Hidden operations disclosed: admin, debug, bulk export or internal-only paths appear alongside the public ones, along with their parameters and schemas.
  • Environment leakage: the servers list names internal hostnames, staging URLs or older API versions still running.
  • Sample secrets: example values, default parameter values or descriptions contain real API keys, tokens or internal credentials pasted during development.
  • A ready-made console: Swagger UI's "Try it out" lets anyone send requests from the browser, which turns weak authorisation into an easy proof of concept.
  • Unpatched UI bundles: old copies of documentation UIs keep running long after the API moved on; keep them updated with the vendor's security releases.

The OpenAPI Specification's own security considerations also note that Markdown in description fields can contain HTML including script, and that tooling must sanitise it, so a documentation UI rendering untrusted descriptions is a client-side risk in its own right.

Default paths to check

Framework or toolDescription documentInteractive UIHow to turn off or move
ASP.NET Core built-in OpenAPI (.NET 9 and later)/openapi/v1.json (pattern /openapi/{documentName}.json)None by default; a UI package is added separatelyMap with MapOpenApi() only in Development, or add .RequireAuthorization(...); Microsoft notes no authorisation checks by default
ASP.NET Core with Swashbuckle/swagger/v1/swagger.json/swaggerTemplate wraps UseSwagger() and UseSwaggerUI() in IsDevelopment(); check nobody removed the condition
FastAPI/openapi.json/docs (Swagger UI), /redoc (ReDoc)openapi_url=None disables the schema and both UIs; can be driven from an environment variable
Spring Boot with springdoc-openapi/v3/api-docs, /v3/api-docs.yaml/swagger-ui.htmlspringdoc.api-docs.enabled=false, springdoc.swagger-ui.enabled=false (both default true), set in the production profile
springdoc on the management port/actuator/openapi/actuator/swagger-uiOnly when springdoc.use-management-port=true; keep the management port off the internet
Older Swagger 2.0 stacks (for example springfox)/v2/api-docs, /swagger.json, /api-docs/swagger-ui.html, /swagger/index.htmlRemove or upgrade; these often survive on legacy services
Hand-published specsopenapi.json or openapi.yaml (the names the OpenAPI Specification recommends for the entry document)VariesReview web roots, object storage buckets and static sites

Treat this as a starting list. Teams change paths with settings such as springdoc.api-docs.path or FastAPI's docs_url, put prefixes such as /api/ in front, or serve docs from a separate developer portal host. The community-maintained Nuclei template "Public Swagger API - Detect" checks dozens of common variants and classifies the result as informational (CWE-200), which is a sensible severity for the raw detection before you assess content.

How to sweep your estate

  1. Build the host list: start from DNS zones, cloud load balancer and API gateway listings, ingress controllers, certificate transparency logs for your domains, and your external attack surface management tool. Include staging, test and partner subdomains. See the Attack Surface Management Guide.
  2. Confirm authority: scan only assets you own or have written permission to test, and tell the operations team before probing production at volume.
  3. Probe the default paths: request each path in the table on every host and port that serves HTTP, at a low request rate. Record status code, content type and the first bytes of the response: an OpenAPI document starts with an openapi or swagger version field, and Swagger UI and ReDoc pages have recognisable titles.
  4. Check from both sides: run once from the internet and once from inside the network. Docs reachable only internally may be acceptable; the same docs reachable from outside usually are not.
  5. Look outward too: search engines and public code hosting sometimes index specs, and public API collection platforms can hold copies. Secrets in shared workspaces are covered in How to find secrets in Postman workspaces.
  6. Parse what you find: for each document, extract the servers list, every path and method, the declared securitySchemes and operations with no security requirement, and scan example and default values for secrets with your normal secret scanner.
  7. Match against inventory: compare hosts, versions and paths with the API inventory. Anything missing is a new inventory entry with an owner, or a decommissioning ticket. The API Inventory Template has the fields to capture.

Triage: what is acceptable

FindingTypical verdictAction
Public API, published on purpose, only public operations, no secretsAcceptableRecord as intended; confirm the UI is current and "Try it out" points only at a sandbox if it is enabled
Partner API docs reachable by anyoneUsually a findingMove behind partner authentication or a developer portal login
Internal service docs reachable from the internetFindingDisable in production config or restrict at the gateway; ask why the service itself is internet-reachable
Admin, debug or management operations listedHigh priority findingTest their authorisation immediately, then remove them from the public description and network path
Real secret in an example or default valueIncidentRotate the credential first, then remove it; follow the API Key Leak Response Playbook
Docs on a host with no owner or an old versionFinding (zombie or shadow API)Find the owner or decommission; see Shadow APIs vs Zombie APIs

Decision guidance: a public developer API benefits from good public documentation, and removing it only pushes integrators to reverse engineer the API. For internal and partner APIs, the better default is docs available in development and through an authenticated portal, off in production. Small teams can rely on framework settings in a production profile; larger organisations usually publish all descriptions to a central, authenticated developer portal or API catalogue and switch them off on the services themselves. If you publish a catalogue at /.well-known/api-catalog (RFC 9727, June 2025), the RFC says to audit it so APIs intended only for internal use are not listed by mistake.

Locking down what must stay

  • Require authentication: put the description and UI behind the same identity provider as the developer portal, or apply an authorisation policy to the endpoint (ASP.NET Core's RequireAuthorization example restricts the document to a role).
  • Restrict at the edge: block documentation paths at the API gateway, WAF or ingress for external listeners while allowing them on internal ones. OWASP's REST Security Cheat Sheet makes the same point for management endpoints: avoid exposing them to the internet, and use separate ports or hosts with firewall rules.
  • Tame Swagger UI: keep tryItOutEnabled at its default of false, set supportedSubmitMethods to an empty array to disable "Try it out" entirely on read-only docs, leave queryConfigEnabled and persistAuthorization at their false defaults, and set validatorUrl to none for internal docs, because by default Swagger UI tries to validate specs against swagger.io's online validator.
  • Publish a filtered document: generate a separate public description that excludes internal and admin operations, rather than exposing the full internal one.
  • Keep secrets out of specs: use obvious placeholders in examples and run secret scanning on generated specs in CI.

Where identity fits

Exposed docs often reveal the machine identities behind an API: which security schemes it accepts, which OAuth scopes exist, whether a static API key header is still allowed, and sometimes a real key in an example. Use each finding to check that the service accounts and keys named in the description are inventoried, scoped and rotated. See the API Key Management Guide.

Making it continuous

  1. Baseline: run the sweep across all known hosts, triage, and record intended public docs as accepted.
  2. Schedule: add the path list to weekly external scans and alert on any new documentation endpoint not on the accepted list.
  3. Shift left: add a CI or deployment check that production configuration disables docs (for example, assert springdoc.api-docs.enabled=false in the production profile, or that the built image returns 404 on /openapi.json).
  4. Gateway rule: deploy a default deny rule for documentation paths on external listeners, with exceptions for approved public APIs.
  5. Rollback: if disabling docs breaks a consumer, restore access through the authenticated portal rather than reopening the public path.

Detection and measurement

  • Exposed documentation endpoints: count of internet-reachable docs not on the accepted list; target zero.
  • Inventory match rate: share of discovered documented hosts already present in the API inventory.
  • Time to close: median days from detection to removal or restriction.
  • Secrets in specs: number of real credentials found in published descriptions, and time to rotation.
  • Access logs: requests to documentation paths from outside your organisation, which show reconnaissance against hosts you thought were hidden.

Framework mapping

FrameworkReferenceHow this guide applies it
OWASP API Security Top 10 2023API9:2023 Improper Inventory ManagementFinding undocumented hosts and versions through their published docs
MITRE ATT&CKT1594 Search Victim-Owned Websites; T1593.002 Search Engines; T1595.003 Wordlist ScanningThe reconnaissance an exposed spec makes easier
NIST SP 800-53 Rev 5CM-8 System Component Inventory; CM-7 Least Functionality; SC-7 Boundary Protection; RA-5 Vulnerability Monitoring and ScanningInventory, turning off unneeded features, edge restriction and recurring scans
NIST CSF 2.0ID.AM-02Inventories of software, services and systems
CIS Controls v8.14.8 Uninstall or Disable Unnecessary Services on Enterprise Assets and SoftwareDisabling docs endpoints that production does not need
ISO/IEC 27001:2022A.5.9 Inventory of information and other associated assets; A.8.9 Configuration managementOwned inventory and secure production configuration

Common failure patterns

  • Development condition removed: someone deletes the IsDevelopment() check to debug production and it never comes back.
  • Staging forgotten: production is clean, but a staging host on a public subdomain serves the full spec and points at shared data. OWASP's API9 scenario describes a beta host missing the rate limiting that production had.
  • Disabling docs instead of fixing authorisation: the spec disappears but the unauthenticated admin operation it revealed is still live.
  • Only scanning one path: a check for /swagger-ui.html misses /openapi.json, /v3/api-docs and custom prefixes.
  • Secrets removed but not rotated: a key deleted from the example is still valid and may already be cached by search engines or scanners.

Practitioner checklist

  • Build a complete host list including staging, partner and legacy subdomains.
  • Probe every host for the default description and UI paths of each framework you use.
  • Test from the internet and from inside the network, with written authority.
  • Parse each document for servers, unauthenticated operations, admin paths and secrets.
  • Rotate any real credential found before removing it from the spec.
  • Disable docs in production profiles and enforce it with a CI or deployment check.
  • Block documentation paths at the external gateway except for approved public APIs.
  • Add every newly found host or version to the API inventory with an owner.
  • Repeat the sweep on a schedule and alert on new documentation endpoints.

Standards and references

Related NHI Mgmt Group resources: OpenAPI Specification Security Guide · OWASP API Top 10 API9 Improper Inventory Management Guide · API Security Guide · Attack Surface Management Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.