1161
Detection Methods
Automated Static Analysis
Automated static analysis, commonly referred to as Static Application Security Testing (SAST),
can find some instances of this weakness by analyzing source code (or binary/compiled code)
without having to execute it. Typically, this is done by building a model of data flow and control
flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input)
with "sinks" (destinations where the data interacts with external components, a lower layer such
as the OS, etc.)
Effectiveness = High
Potential Mitigations
Phase: Implementation
Always use explicit block delimitation and use static-analysis technologies to enforce this
practice.
Demonstrative Examples
Example 1:
In this example, the programmer has indented the statements to call Do_X() and Do_Y(), as if the
intention is that these functions are only called when the condition is true. However, because there
are no braces to signify the block, Do_Y() will always be executed, even if the condition is false.
Example Language: C (Bad)
if (condition==true)
Do_X();
Do_Y();
This might not be what the programmer intended. When the condition is critical for security, such as
in making a security decision or detecting a critical error, this may produce a vulnerability.
Example 2:
In this example, the programmer has indented the Do_Y() statement as if the intention is that the
function should be associated with the preceding conditional and should only be called when the
condition is true. However, because Do_X() was called on the same line as the conditional and
there are no braces to signify the block, Do_Y() will always be executed, even if the condition is
false.
Example Language: C (Bad)
if (condition==true) Do_X();
Do_Y();
This might not be what the programmer intended. When the condition is critical for security, such as
in making a security decision or detecting a critical error, this may produce a vulnerability.
Observed Examples
Reference Description
CVE-2014-1266 incorrect indentation of "goto" statement makes it more difficult to detect an
incorrect goto (Apple's "goto fail")
https://www.cve.org/CVERecord?id=CVE-2014-1266
MemberOf Relationships
This MemberOf relationships table shows additional CWE Catgeories and Views that reference this
weakness as a member. This information is often useful in understanding where a weakness fits
within the context of external information sources.
CWE Version 4.14
CWE-484: Omitted Break Statement in Switch
CWE-484: Omitted Break Statement in Switch