Exposed API documentation and debug endpoints
| Class | Security misconfiguration |
|---|---|
| Also known as | Leftover debug code, active debug code |
| CWE | CWE-489: Active Debug Code |
| OWASP Top 10 | A02:2025 Security Misconfiguration |
| MITRE ATT&CK | T1594 Search Victim-Owned Websites |
| Typical severity | Low for an API description; Critical for a debug console |
| Affects | FastAPI and other frameworks that generate API documentation, GraphQL servers, Spring Boot Actuator, and Django, Laravel and Werkzeug apps deployed with debug mode on |
Exposed API documentation and debug endpoints are development features that remain reachable on a production site: machine-readable descriptions of an API, schema queries on a GraphQL server, detailed error pages, status endpoints and interactive debug consoles. The risk ranges from low for a published API description to critical for a console that runs code on the server.
Description
Debug code left active in released software is a recognised weakness,1 and unnecessary pages, testing frameworks and error handling that reveals stack traces count as misconfiguration.2
Two kinds of feature fall under this name. The first describes the API. FastAPI, for example, generates an OpenAPI document at /openapi.json and serves documentation pages at /docs and /redoc unless they are turned off.3 GraphQL servers answer introspection queries, which return the whole schema: types, mutations, deprecated fields and sometimes fields meant to stay private. Introspection and the GraphiQL explorer are often on by default and need no sign-in.4
The second kind exposes the running application. When a request raises an error in debug mode, Django shows a detailed traceback that lists the current settings, leaving out those with sensitive names such as SECRET_KEY.5 Spring Boot Actuator publishes monitoring endpoints under /actuator/, such as env and heapdump.6 The Werkzeug debugger adds a console in the browser that runs Python code on the server.7
Attackers find both kinds by searching the target's own website for hidden files, directories and functions, by hand or with wordlist scanning.8
Mechanism
A FastAPI backend at api.example.com serves a mobile app. The app calls three routes, but the server has twelve, including routes written for an internal admin tool. A request to https://api.example.com/openapi.json returns all twelve with their parameters. The attacker now tests each route for missing authorization checks without having to guess any of them.
A debug endpoint gives more. Current Spring Boot versions expose only the health endpoint over HTTP and restrict access to heapdump by default. On a service where a developer has exposed every endpoint with management.endpoints.web.exposure.include=* and also opened access to heapdump, a request to /actuator/heapdump downloads a heap dump: a file of the application's memory.6
Impact
An API description or schema reveals the attack surface and speeds up attacks on routes that already have flaws. It grants no access by itself, and hiding it does not secure the routes it lists.3 Stack traces and other detailed error messages can reveal component versions, which an attacker matches against known CVEs.2 Laravel's debug mode in production risks exposing sensitive configuration values.9
Interactive debug features can lead to full compromise. In the worst case, which is also a frequent one, debug code gives an attacker complete control of the application and the server.1 The Werkzeug documentation calls its debugger a major security risk because it executes arbitrary code; the PIN that guards the console makes an attack harder but is not designed to stop one.7
Notable incidents
CVE-2021-3129, published on 12 January 2021, affects Ignition, a package used in Laravel. Before version 2.5.2, it let an attacker with no account run code on the server, on sites running Laravel before 8.4.2 with debug mode on. NVD scores it 9.8 (Critical) under CVSS 3.1, and CISA added it to the Known Exploited Vulnerabilities catalog on 18 September 2023.10
Detection
Request the documentation and debug paths of the framework in use on the production address: /openapi.json, /docs and /redoc for FastAPI, /actuator for Spring Boot, and /console, the default path of the Werkzeug console. On a GraphQL endpoint, send an introspection query. Cause an error, for example with a malformed ID, and check whether the answer contains a stack trace or framework details. A DAST scanner sends requests of this kind to a running site.
Prevention
A production platform should carry no unnecessary features, documentation or samples,2 and API documentation belongs only in front of people allowed to use the API.11 Production settings per framework:
| Framework | Production setting |
|---|---|
| Django | DEBUG = False (the default) |
| Laravel | APP_DEBUG=false in .env, read by env('APP_DEBUG', false) in config/app.php |
| Werkzeug | No DebuggedApplication wrapper and no use_debugger=True |
| Spring Boot | management.endpoints.web.exposure.include=health (the default), with Spring Security in front of any other endpoint |
| FastAPI | openapi_url read from a setting and set to an empty string |
In FastAPI the documentation can be turned off through a setting. With the environment variable OPENAPI_URL set to an empty string, /openapi.json, /docs and /redoc answer 404:3
from fastapi import FastAPI
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
openapi_url: str = "/openapi.json"
settings = Settings()
app = FastAPI(openapi_url=settings.openapi_url)A GraphQL server in a production or public environment needs introspection and GraphiQL turned off, or limited to signed-in users when the API is public. Field names can still be guessed by brute force, and GraphQL answers a misspelt field name with a hint naming the similar real field, so those hints go off too where the server allows it.4 In the deprecated express-graphql middleware:
app.use('/graphql', graphqlHTTP({
schema: MySessionAwareGraphQLSchema,
validationRules: [NoIntrospection],
graphiql: process.env.NODE_ENV === 'development',
}));A hidden description does not replace access checks on each route. Separate test and beta hosts need the same settings: in an OWASP example, a beta API host lacked the rate limit of the main one, and a researcher guessed six-digit password reset codes there.11
Prompt for a coding agent
Check this project for development features that would be reachable in production. Look for debug mode settings (DEBUG in Django, APP_DEBUG in Laravel, the Werkzeug debugger), Spring Boot Actuator exposure settings, generated API documentation routes such as /openapi.json, /docs and /redoc, and GraphQL introspection and GraphiQL. Make each one read its value from an environment variable so it is on in development and off in production, and keep the Actuator health endpoint only. Do not remove access checks from any route. List each file and setting you changed, and any route that appears in the API documentation but has no authorization check.
In SecFlash
On the Exposure page, SecFlash reports a public OpenAPI or Swagger file as SF-EXP-204, GraphQL introspection as SF-EXP-203, reachable debug and status pages as SF-EXP-205, a readable phpinfo() page as SF-EXP-211, stack traces in error answers as SF-EXP-206 and a development build in production as SF-EXP-103. On the Security page, it reports readable Spring Boot Actuator endpoints as SF-SEC-651, error details shown to visitors as SF-SEC-636 and debug error messages as SF-SEC-637. Database tables visible in the GraphQL schema appear on the Cloud page as SF-CLD-516 for visitors without a sign-in and SF-CLD-517 for signed-in users.
See also
- Exposed administration interface
- Exposed sensitive files
- Client-side code exposure
- Subdomain enumeration
- Securing Rails, Django and Laravel applications
- Category: Security misconfiguration
References
- a b MITRE. "CWE-489: Active Debug Code". Common Weakness Enumeration, version 5.0.
- a b c "A02:2025 Security Misconfiguration". OWASP Top 10:2025. OWASP Foundation.
- a b c FastAPI. "Conditional OpenAPI". FastAPI documentation.
- a b OWASP. "GraphQL Cheat Sheet". OWASP Cheat Sheet Series.
- back Django Software Foundation. "Settings: DEBUG". Django 5.2 documentation.
- a b Spring. "Endpoints". Spring Boot reference documentation.
- a b Pallets. "Debugging Applications". Werkzeug documentation.
- back MITRE (24 October 2025). "Search Victim-Owned Websites, T1594". MITRE ATT&CK.
- back Laravel. "Configuration: Debug Mode". Laravel 12.x documentation.
- back NIST (12 January 2021). "CVE-2021-3129". National Vulnerability Database.
- a b OWASP (2023). "API9:2023 Improper Inventory Management". OWASP API Security Top 10.
External links
- OpenAPI Specification, OpenAPI Initiative
- Introspection, GraphQL documentation