CWE-478 · Słabość
Missing Default Case in Multiple Condition Expression
- Abstrakcja
- Bazowa
- Status
- Szkic
- Dodano
- 19 lipca 2006
- Ostatnia zmiana
- 11 grudnia 2025
Opis
The code does not have a default case in an expression with multiple conditions, such as a switch statement.
If a multiple-condition expression (such as a switch in C) omits the default case but does not consider or handle all possible values that could occur, then this might lead to complex logical errors and resultant weaknesses. Because of this, further decisions are made based on poor information, and cascading failure results. This cascading failure may result in any number of security issues, and constitutes a significant failure in the system.
Skutki
Integrity
Varies by Context; Alter Execution Logic
Depending on the logical circumstances involved, any consequences may result: e.g., issues of confidentiality, authentication, authorization, availability, integrity, accountability, or non-repudiation.
Zapobieganie
Implementation
Ensure that there are no cases unaccounted for when adjusting program flow or values based on the value of a given variable. In the case of switch style statements, the very simple act of creating a default case can, if done correctly, mitigate this situation. Often however, the default case is used simply to represent an assumed option, as opposed to working as a check for invalid input. This is poor practice and in some cases is as bad as omitting a default case entirely.
Słabość nadrzędna
Kiedy powstaje
- Implementation
Dotyczy
C, C++, Java, C#, Python, JavaScript
Źródła
- The CLASP Application Security Process — Secure Software, Inc., 2005
- 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.