This vulnerability occurs when a developer forgets to include a 'break' statement inside a switch-case block. Without it, the code execution 'falls through' and unintentionally runs the logic for subsequent cases, leading to unexpected behavior.
A missing 'break' statement causes a switch block to fail its primary purpose: executing one distinct code path. Instead, it cascades from the matched case into the code for the cases below it. This 'fall-through' behavior is a common logic error that can bypass critical security checks, corrupt data, or trigger functions that should only run under specific conditions. While some languages allow intentional fall-through for specific patterns, omitting 'break' by mistake is a frequent source of bugs. To prevent this, developers should adopt a defensive coding style, such as always adding a 'break' as the default action and using linter rules to flag missing statements. Explicitly commenting any intentional fall-throughs makes the code safer and more maintainable.
Impact: Alter Execution Logic
This weakness can cause unintended logic to be executed and other unexpected application behavior.
javacMedium