CWE-478

Missing Default Case in Multiple Condition Expression

Medium

Description

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

Potential Impact

How to Fix

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.

Detection Methods

Related Weaknesses

References

View on MITRE CWE Database →

Need Help Fixing This Vulnerability?

Our security experts can help you identify and remediate CWE-478 vulnerabilities in your codebase.

Get Security Assessment