CWE-484: Omitted Break Statement in Switch

Base Draft Simple

CWE版本: 4.18

更新日期: 2025-09-09

弱点描述

The product omits a break statement within a switch or similar construct, causing code associated with multiple conditions to execute. This can cause problems when the programmer only intended to execute code associated with one condition.

扩展描述

This can lead to critical code executing in situations where it should not.

常见后果

影响范围: Other

技术影响: Alter Execution Logic

说明: This weakness can cause unintended logic to be executed and other unexpected application behavior.

潜在缓解措施

阶段: Implementation

描述: Omitting a break statement so that one may fall through is often indistinguishable from an error, and therefore should be avoided. If you need to use fall-through capabilities, make sure that you have clearly documented this within the switch statement, and ensure that you have examined all the logical possibilities.

阶段: Implementation

描述: The functionality of omitting a break statement could be clarified with an if statement. This method is much safer.

检测方法

方法: White Box

Omission of a break statement might be intentional, in order to support fallthrough. Automated detection methods might therefore be erroneous. Semantic understanding of expected product behavior is required to interpret whether the code is correct.

方法: Black Box

Since this weakness is associated with a code construct, it would be indistinguishable from other errors that produce the same behavior.

方法: Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

有效性: High

引入模式

阶段 说明
Implementation -

适用平台

编程语言
C (Undetermined) C++ (Undetermined) Java (Undetermined) C# (Undetermined) PHP (Undetermined)

分类映射

分类名称 条目ID 条目名称 映射适配度
CLASP - Omitted break statement -
Software Fault Patterns SFP4 Unchecked Status Condition -
关键信息

CWE ID: CWE-484

抽象级别: Base

结构: Simple

状态: Draft

利用可能性: Medium

相关弱点