CWE-478: Missing Default Case in Multiple Condition Expression

BaseDraft

The code does not have a default case in an expression with multiple conditions, such as a switch statement.

View on MITRE
Back to CWE Lookup

Extended Description

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.

Technical Details

Structure
Simple

Applicable To

Languages
CC++JavaC#PythonJavaScript
Platforms

Frequently Asked Questions

What is CWE-478: Missing Default Case in Multiple Condition Expression?+

CWE-478: Missing Default Case in Multiple Condition Expression is a Common Weakness Enumeration (CWE) entry maintained by MITRE. 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.

What are the security consequences of Missing Default Case in Multiple Condition Expression?+

If exploited, CWE-478 (Missing Default Case in Multiple Condition Expression) it can compromise Integrity, leading to outcomes such as Varies by Context and Alter Execution Logic.

How do you prevent or mitigate Missing Default Case in Multiple Condition Expression?+

Recommended mitigations for CWE-478 include: 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.

Which programming languages are affected by Missing Default Case in Multiple Condition Expression?+

CWE-478 commonly affects C, C++, Java, C#, Python and JavaScript. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.

What is the difference between a CWE and a CVE?+

A CWE (Common Weakness Enumeration) like CWE-478 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.

Learn More