How to fix: Flask debug mode enabled in production
The Flask interactive debugger (Werkzeug) is accessible, indicating DEBUG=True in a production environment.
Why it matters
The Flask Werkzeug interactive debugger allows arbitrary Python code execution in the browser. Any visitor can run any Python command on your server. This is a complete server compromise.
When Flask runs with debug=True, unhandled exceptions show an interactive debugger that executes Python code. This must NEVER be enabled in production.
How to fix it
- 1Set FLASK_ENV=production and FLASK_DEBUG=0 in your deployment
- 2Never use app.run(debug=True) in production
- 3Set a strong debugger PIN if debug mode is needed in staging
Code examples
Disable debug mode
# NEVER run with debug=True in production
# app.run(debug=True) # REMOVE THIS
# Correct production startup:
if __name__ == "__main__":
app.run(debug=False, host="0.0.0.0", port=5000)
# Or use gunicorn:
# gunicorn -w 4 -b 0.0.0.0:5000 app:appReferences
Detected automatically by VulnRadar. The check id is flask-debug-page-exposure, stable across every scan so you can filter or diff on it.
More info disclosure checks
- MediumRails Session Cookie Missing HttpOnly Flag
- InfoServer header truncated
- InfoPHP session cookie naming exposes runtime
- Infoconfig.js / settings.js referenced (verify contents)
- Infoenv.js / environment.js referenced (verify contents)
- InfoSitemap.xml publicly accessible
- InfoOpenAPI schema version exposed in URL
- LowCORS exposes internal CDN hostname
Questions
- How severe is Flask debug mode enabled in production?
- VulnRadar rates this critical severity in the info disclosure category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id flask-debug-page-exposure, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Flask debug mode enabled in production map to?
- It maps to CWE-489. In the OWASP Top 10 it falls under A05:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.