CWE-478: Missing Default Case in Multiple Condition Expression
The code does not have a default case in an expression with multiple conditions, such as a switch statement.
How it's found
Missing Default Case in Multiple Condition Expression is typically found by tracing untrusted input from where it enters the system to the point where it is used without the check or neutralization this weakness describes, combining manual code review with dynamic testing.
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.
Vulnerable vs. safe
//Break never reached because of exit()printf("Security check failed!\n");exit(-1);break;
printf("Security check passed.\n");break;
case FAILED:case PASSED:// program execution continues...#define FAILED 0#define PASSED 1int result;...result = security_check(data);switch (result) {}...//Break never reached because of exit()printf("Security check failed!\n");exit(-1);break;
printf("Security check passed.\n");break;
printf("Unknown error (%d), exiting...\n",result);exit(-1);
case FAILED:case PASSED:default:#define FAILED 0#define PASSED 1int result;...result = security_check(data);switch (result) {}Consequences
- 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.
Mitigations
- 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.
Where this fits in a TurboPentest engagement
TurboPentest's agentic pentest is powerful and covers a broad range of issues automatically. This particular class is best confirmed in a manual IntegSec engagement, where human pentesters apply deeper methodology and a larger context window than any automated pass.
Frequently asked questions
What is CWE-478?
The code does not have a default case in an expression with multiple conditions, such as a switch statement.
How do you find Missing Default Case in Multiple Condition Expression?
Missing Default Case in Multiple Condition Expression is typically found by tracing untrusted input from where it enters the system to the point where it is used without the check or neutralization this weakness describes, combining manual code review with dynamic testing.
What is the impact of CWE-478?
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.
Does TurboPentest test for Missing Default Case in Multiple Condition Expression?
TurboPentest's agentic pentest is powerful and covers a broad range of issues automatically. This particular class is best confirmed in a manual IntegSec engagement, where human pentesters apply deeper methodology and a larger context window than any automated pass.
Related CWEs
Find these issues before an attacker does
TurboPentest runs an agentic AI pentest against your target and reports findings with proof, from $99 per target.
Start a $99 pentest