# Improper Check for Unusual or Exceptional Conditions (CWE-754) The product does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the product. - Prevalence: Mittel 1 Sprachen abgedeckt - Impact: Hoch 1 Regeln mit hohem Schweregrad - Prevention: Dokumentiert 1 Fix-Beispiele **OWASP:** Insecure Design (A04:2021-Insecure Design) - #4 ## Description Failing to check for error conditions, return values, or exceptional cases can lead to undefined behavior, crashes, or security vulnerabilities when these conditions occur. ## Prevention Präventionsstrategien für Improper Check for Unusual Conditions basierend auf 1 Shoulder-Erkennungsregeln. ### JavaScript Use multi-phase migrations with data backup before destructive DDL operations like DROP TABLE or DROP COLUMN ## Warning Signs - [HIGH] Migration contains potentially destructive operation: .... Add safety checks and data preservation logic. ## Consequences - DoS - Nicht autorisierten Code ausführen - Anwendungsdaten lesen ## Mitigations - Alle Rückgabewerte und Fehlerbedingungen prüfen - Randfälle und Ausnahmebedingungen explizit behandeln - Praktiken der defensiven Programmierung anwenden ## Detection - Total rules: 1 - Languages: javascript, typescript ## Rules by Language ### Javascript (1 rules) - **TypeORM Unsafe Database Migration** [HIGH]: Unsafe migrations with DROP TABLE/COLUMN operations without backups cause permanent data loss and application crashes from schema mismatches. - Remediation: Backup data before destructive operations and use multi-phase migrations. ```typescript export class SafeColumnRemoval implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { // Backup before dropping await queryRunner.query(` CREATE TABLE "user_email_backup" AS SELECT id, email FROM "user" `); await queryRunner.dropColumn('user', 'email'); } } ``` Learn more: https://shoulder.dev/learn/typescript/cwe-754/unsafe-migration ### Typescript (1 rules) - **TypeORM Unsafe Database Migration** [HIGH]: Unsafe migrations with DROP TABLE/COLUMN operations without backups cause permanent data loss and application crashes from schema mismatches. - Remediation: Backup data before destructive operations and use multi-phase migrations. ```typescript export class SafeColumnRemoval implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { // Backup before dropping await queryRunner.query(` CREATE TABLE "user_email_backup" AS SELECT id, email FROM "user" `); await queryRunner.dropColumn('user', 'email'); } } ``` Learn more: https://shoulder.dev/learn/typescript/cwe-754/unsafe-migration