Skip to main content
CriticalInfo disclosureOWASP A05:2021CWE-489

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

  1. 1Set FLASK_ENV=production and FLASK_DEBUG=0 in your deployment
  2. 2Never use app.run(debug=True) in production
  3. 3Set a strong debugger PIN if debug mode is needed in staging

Code examples

Disable debug mode

Python
# 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:app

References

Detected automatically by VulnRadar. The check id is flask-debug-page-exposure, stable across every scan so you can filter or diff on it.

See every info disclosure check

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.

Propose a checkHow a check is built

Scan your own site for flask debug mode enabled in production

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

Flask debug mode enabled in production fix | VulnRadar