Development tools and frameworks usually have options to make debugging easier for developers. Although these features are useful during
development, they should never be enabled for applications deployed in production. Debug instructions or error messages can leak detailed information
about the system, like the application’s path or file names.
Ask Yourself Whether
- The code or configuration enabling the application debug features is deployed on production servers or distributed to end users.
- The application runs by default with debug features activated.
There is a risk if you answered yes to any of those questions.
Recommended Secure Coding Practices
Do not enable debugging features on production servers or applications distributed to end users.
Sensitive Code Example
from django.conf import settings
settings.configure(DEBUG=True) # Sensitive when set to True
settings.configure(DEBUG_PROPAGATE_EXCEPTIONS=True) # Sensitive when set to True
settings.configure(default_settings=config, DEBUG=True) # Sensitive
Django’s "settings.py" or "global_settings.py" configuration file:
# NOTE: The following code raises issues only if the file is named "settings.py" or "global_settings.py". This is the default
# name of Django configuration file
DEBUG = True # Sensitive
DEBUG_PROPAGATE_EXCEPTIONS = True # Sensitive