# Unchecked Error Condition (CWE-391) The product does not properly check when a function or operation returns a value that is associated with an error condition. **Stack:** Python - Prevalence: Mittel 3 Sprachen abgedeckt - Impact: Hoch 1 Regeln mit hohem Schweregrad - Prevention: Dokumentiert 3 Fix-Beispiele **OWASP:** Insecure Design (A04:2021-Insecure Design) - #4 ## Description When error conditions are not checked, the application may continue with invalid or unexpected state, potentially leading to crashes, data corruption, or security vulnerabilities. ## Prevention Präventionsstrategien für Unchecked Error Condition basierend auf 1 Shoulder-Erkennungsregeln. ### Python Log exceptions or handle them explicitly instead of silently swallowing with pass ## Warning Signs - [MEDIUM] empty except blocks that silently swallow exceptions ## Consequences - DoS - Nicht autorisierten Code ausführen - Anwendungsdaten ändern ## Mitigations - Alle Rückgabewerte und Fehlerbedingungen prüfen - Wo angemessen, Exception-Handling verwenden - Angemessene Mechanismen zur Fehlerwiederherstellung umsetzen ## Detection - Total rules: 3 - Languages: go, javascript, typescript, python ## Rules by Language ### Python (1 rules) - **Empty Exception Handler** [MEDIUM]: Detects empty except blocks that silently swallow exceptions. This can hide security-critical errors, authentication failures, or data validation issues. - Remediation: Log exceptions or handle them explicitly instead of using empty except blocks. ```python import logging logger = logging.getLogger(__name__) try: risky_operation() except Exception as e: logger.error(f"Operation failed: {e}", exc_info=True) return {'error': 'Operation failed'}, 500 ``` Learn more: https://shoulder.dev/learn/python/cwe-391/empty-except