Why AI tools produce this: AI coding tools generate this anti-pattern by default, it appears in a large share of AI-written auth code.
Why this matters
In production this leaks the SECRET_KEY, environment variables, and full tracebacks, and Flask's Werkzeug debugger additionally exposes an interactive console that allows remote code execution.
Never enable debug mode in production. Drive it from an environment variable that defaults to off, e.g. debug=os.environ.get("FLASK_DEBUG") == "1" (Flask) or DEBUG = os.environ.get("DJANGO_DEBUG") == "1" (Django).
import osfrom flask import Flaskapp = Flask(__name__)# ok: auth.py.flow.debug-enabled -- debug not enabled at alldef serve(): app.run(host="127.0.0.1")# ok: auth.py.flow.debug-enabled -- explicitly disableddef serve_no_debug(): app.run(host="127.0.0.1", debug=False)# ok: auth.py.flow.debug-enabled -- driven by an environment variabledef serve_env(): app.run(debug=os.environ.get("FLASK_DEBUG") == "1")# ok: auth.py.flow.debug-enabled -- disabled in production settingsDEBUG = False# ok: auth.py.flow.debug-enabled -- read from the environment, defaults offDJANGO_DEBUG = os.environ.get("DJANGO_DEBUG") == "1"
Suppressing this rule
If a finding is a genuine false positive, scope the suppression to the exact line and leave a reason, never disable the rule project-wide. Disable directives are line-scoped by design.