Katalog CWE

CWE-484 · Słabość

Omitted Break Statement in Switch

Abstrakcja
Bazowa
Status
Szkic
Ryzyko wykorzystania
średnie
Dodano
19 lipca 2006
Ostatnia zmiana
11 grudnia 2025

Podatności CVE z tą słabościąPełny wpis na cwe.mitre.org ↗

Opis

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.

Skutki

  • Other

    Alter Execution Logic

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

Zapobieganie

  • 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.

Słabość nadrzędna

Kiedy powstaje

Dotyczy

C, C++, Java, C#, PHP, Not Language-Specific

Źródła

  1. The CLASP Application Security Process — Secure Software, Inc., 2005
  2. The Art of Software Security Assessment — Mark Dowd, John McDonald, Justin Schuh, Chapter 7, "Switch Statements", Page 337, Addison Wesley, 2006

Wpis z katalogu CWE 4.20.