Debug Logging of Environment Variables
Developers often log entire environment dictionaries during debugging or application startup to troubleshoot configuration issues. This practice exposes all environment variables, including sensitive secrets, to log files and monitoring systems. Debug logs that are accidentally left enabled in production amplify this risk.
Preview example – PYTHON
import os
import logging
# VULNERABLE: Logging all environment variables
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
def startup_diagnostics():
logger.debug("Application environment:")
for key, value in os.environ.items():
logger.debug(f"{key}={value}") # Exposes DB_PASSWORD, API_KEYS, etc!
# Also vulnerable - logging entire environ dict
logger.debug(f"Full environment: {dict(os.environ)}")