960
Nature Type ID Name Page
MemberOf 389 Error Conditions, Return Values, Status Codes 2322
Applicable Platforms
Language : C++ (Prevalence = Undetermined)
Language : Java (Prevalence = Undetermined)
Language : C# (Prevalence = Undetermined)
Language : Python (Prevalence = Undetermined)
Common Consequences
Scope Impact Likelihood
Non-Repudiation
Other
Hide Activities
Alter Execution Logic
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
Demonstrative Examples
Example 1:
The following code excerpt handles three types of exceptions in an identical fashion.
Example Language: Java (Good)
try {
doExchange();
}
catch (IOException e) {
logger.error("doExchange failed", e);
}
catch (InvocationTargetException e) {
logger.error("doExchange failed", e);
}
catch (SQLException e) {
logger.error("doExchange failed", e);
}
At first blush, it may seem preferable to deal with these exceptions in a single catch block, as
follows:
Example Language: (Bad)
try {
doExchange();
}
catch (Exception e) {
logger.error("doExchange failed", e);
}
However, if doExchange() is modified to throw a new type of exception that should be handled
in some different kind of way, the broad catch block will prevent the compiler from pointing
CWE Version 4.14
CWE-397: Declaration of Throws for Generic Exception
CWE-397: Declaration of Throws for Generic Exception