API documentation accessible only to authorized users
Why it matters
Publicly accessible API documentation — Swagger UI, Redoc, GraphQL Playground — hands attackers a complete, interactive map of your API surface. CWE-200 (Exposure of Sensitive Information) and OWASP API Security Top 10 2023 API8 (Security Misconfiguration) both target documentation exposure as a misconfiguration that eliminates reconnaissance effort. Schema docs reveal endpoint names, parameter types, authentication methods, and sometimes internal implementation details through field names and descriptions. Attackers use publicly available Swagger specs to auto-generate exploit code targeting specific endpoints. Intentionally public APIs (developer platforms, open standards) are a legitimate exception — but this must be a deliberate choice, not a default.
Severity rationale
Info severity because documentation exposure doesn't enable exploitation alone, but it reduces the effort of every subsequent attack by providing an interactive schema map.
Remediation
Gate API documentation behind authentication middleware or restrict it to internal IP ranges. Disable interactive exploration (GraphQL Playground, Swagger's 'Try it out') in production entirely.
// Express + Swagger UI
import swaggerUi from 'swagger-ui-express'
import spec from './openapi.json'
// Apply admin-only auth middleware before mounting the docs
app.use(
'/api/docs',
requireAuth,
requireRole('admin'),
swaggerUi.serve,
swaggerUi.setup(spec, {
swaggerOptions: { tryItOutEnabled: false } // disable interactive execution
})
)
// Or disable entirely in production and ship docs to a separate internal tool:
if (process.env.NODE_ENV !== 'production') {
app.use('/api/docs', swaggerUi.serve, swaggerUi.setup(spec))
}
If documentation must be public (developer platform), scrub internal endpoints and strip sensitive field descriptions before generating the public spec.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the API Security Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-200 — Exposure of Sensitive Information to an Unauthorized Actor
- owasp:2021 · A05 — Security Misconfiguration
- owasp:2023 · API8 — Security Misconfiguration
Taxons
History
- 2026-04-18·v1.0.0·Initial import from api-security·automated