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,/docsand/redocby default, springdoc serves/v3/api-docsand/swagger-ui.html, and ASP.NET Core uses/swagger/v1/swagger.jsonor/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
serverslist 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 tool | Description document | Interactive UI | How 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 separately | Map with MapOpenApi() only in Development, or add .RequireAuthorization(...); Microsoft notes no authorisation checks by default |
| ASP.NET Core with Swashbuckle | /swagger/v1/swagger.json | /swagger | Template 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.html | springdoc.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-ui | Only 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.html | Remove or upgrade; these often survive on legacy services |
| Hand-published specs | openapi.json or openapi.yaml (the names the OpenAPI Specification recommends for the entry document) | Varies | Review 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
- 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.
- Confirm authority: scan only assets you own or have written permission to test, and tell the operations team before probing production at volume.
- 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
openapiorswaggerversion field, and Swagger UI and ReDoc pages have recognisable titles. - 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.
- 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.
- Parse what you find: for each document, extract the
serverslist, every path and method, the declaredsecuritySchemesand operations with nosecurityrequirement, and scan example and default values for secrets with your normal secret scanner. - 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
| Finding | Typical verdict | Action |
|---|---|---|
| Public API, published on purpose, only public operations, no secrets | Acceptable | Record 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 anyone | Usually a finding | Move behind partner authentication or a developer portal login |
| Internal service docs reachable from the internet | Finding | Disable in production config or restrict at the gateway; ask why the service itself is internet-reachable |
| Admin, debug or management operations listed | High priority finding | Test their authorisation immediately, then remove them from the public description and network path |
| Real secret in an example or default value | Incident | Rotate the credential first, then remove it; follow the API Key Leak Response Playbook |
| Docs on a host with no owner or an old version | Finding (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
RequireAuthorizationexample 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
tryItOutEnabledat its default of false, setsupportedSubmitMethodsto an empty array to disable "Try it out" entirely on read-only docs, leavequeryConfigEnabledandpersistAuthorizationat their false defaults, and setvalidatorUrltononefor 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
- Baseline: run the sweep across all known hosts, triage, and record intended public docs as accepted.
- Schedule: add the path list to weekly external scans and alert on any new documentation endpoint not on the accepted list.
- Shift left: add a CI or deployment check that production configuration disables docs (for example, assert
springdoc.api-docs.enabled=falsein the production profile, or that the built image returns 404 on/openapi.json). - Gateway rule: deploy a default deny rule for documentation paths on external listeners, with exceptions for approved public APIs.
- 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
| Framework | Reference | How this guide applies it |
|---|---|---|
| OWASP API Security Top 10 2023 | API9:2023 Improper Inventory Management | Finding undocumented hosts and versions through their published docs |
| MITRE ATT&CK | T1594 Search Victim-Owned Websites; T1593.002 Search Engines; T1595.003 Wordlist Scanning | The reconnaissance an exposed spec makes easier |
| NIST SP 800-53 Rev 5 | CM-8 System Component Inventory; CM-7 Least Functionality; SC-7 Boundary Protection; RA-5 Vulnerability Monitoring and Scanning | Inventory, turning off unneeded features, edge restriction and recurring scans |
| NIST CSF 2.0 | ID.AM-02 | Inventories of software, services and systems |
| CIS Controls v8.1 | 4.8 Uninstall or Disable Unnecessary Services on Enterprise Assets and Software | Disabling docs endpoints that production does not need |
| ISO/IEC 27001:2022 | A.5.9 Inventory of information and other associated assets; A.8.9 Configuration management | Owned 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.htmlmisses/openapi.json,/v3/api-docsand 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
- OWASP: API9:2023 Improper Inventory Management
- OpenAPI Initiative: OpenAPI Specification v3.1.1
- IETF: RFC 9727 api-catalog, a well-known URI and link relation to help discovery of APIs
- OWASP: REST Security Cheat Sheet
- Swagger UI: Configuration
- FastAPI: Conditional OpenAPI
- springdoc-openapi: Documentation
- Microsoft Learn: Generate OpenAPI documents in ASP.NET Core
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