Debug or preview mode left on in production

Last updated November 13, 2026
Steps
- Search configuration and startup code for debug flags: DEBUG = True, app.run(debug=True), flask run --debug, NODE_ENV=development, Next.js next dev used as the production command, Express error handlers that dump stacks, an open GraphQL or API playground, profiler or __debug__ routes, and preview or staging middleware that is reachable on the live hostname.
- Set production so debug is off and cannot be flipped from a public request. In Django, DEBUG = False and a non-empty ALLOWED_HOSTS (Django will not run without ALLOWED_HOSTS when debug is off). Load the flag from an environment variable that is false in production.
- Do not run the framework’s development server on the public site. Use the production server your platform expects (for example a WSGI/ASGI server for Django or Flask, or next start / the host’s production build for Next.js).
- Confirm Flask/Werkzeug’s interactive debugger is off. Flask’s documentation warns that the debugger allows executing Python from the browser and that its PIN is not something to rely on for security.
- Close extra debug surfaces: verbose error pages (see the related pattern on leaking stack traces), source maps on the production hostname, unauthenticated preview or GraphiQL/Swagger UIs, and any “debug toolbar” package.
- Keep detailed errors in server logs or an error-tracking tool that only your team can see—not in the response sent to users.
- Retest by triggering a harmless error on production-like settings and confirming the user sees a generic message, not a traceback, source excerpt or debugger.
Why it matters
CWE-489, Active Debug Code (also called leftover debug code), is when a product is released with debugging code still enabled. MITRE notes it can lead to bypassing protections, reading application data or gaining privileges, depending on what the debug features expose. Django’s official deployment checklist is direct: never enable debug in production, because it leaks lots of information about your project. Flask’s debugging guide is equally direct: do not run the development server or enable the built-in debugger in production. The OWASP Django Security Cheat Sheet likewise treats turning DEBUG off as a production requirement. This is a configuration mistake to find in your own deployment, not a reason to probe someone else’s site.
Sources
MITRE CWE-489: Active Debug Code — https://cwe.mitre.org/data/definitions/489.html
Django documentation: Deployment checklist — https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
Flask documentation: Debugging Application Errors — https://flask.palletsprojects.com/en/stable/debugging/
OWASP Cheat Sheet: Django Security — https://cheatsheetseries.owasp.org/cheatsheets/Django_Security_Cheat_Sheet.html
Checked at the source on November 8, 2026.
Related patterns
- Error messages that leak stack traces, queries or keys
- Exposed .env or .git on a deployed site
- Production source maps that publish your app's original source code
- API routes with no auth check
- API secret keys shipped in your frontend bundle
- Passwords, tokens and personal data written to your logs
- Hard-coded credentials left in vibe-coded apps
- GraphQL APIs with introspection on and no depth or cost limits
Found a problem you'd rather not fix yourself?
Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.
Get it fixed by StorenTechVibe Security Weekly
One email a week with new failure patterns and how to fix them.
By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.