# 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: 보통 1개 언어 지원 - Impact: 높음 1개의 높은 심각도 규칙 - Prevention: 문서화됨 1개의 수정 예시 **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 1개의 Shoulder 탐지 규칙을 기반으로 한 Improper Check for Unusual Conditions 예방 전략. ### 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 - 승인되지 않은 코드 실행 - 애플리케이션 데이터 읽기 ## Mitigations - 모든 반환값과 오류 조건을 확인하세요 - 엣지 케이스와 예외 조건을 명시적으로 처리하세요 - 방어적 프로그래밍 관행을 적용하세요 ## 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