1297
The product calls a thread's run() method instead of calling start(), which causes the code to run in
the thread of the caller instead of the callee.
Extended Description
In most cases a direct call to a Thread object's run() method is a bug. The programmer intended
to begin a new thread of control, but accidentally called run() instead of start(), so the run() method
will execute in the caller's thread of control.
Relationships
The table(s) below shows the weaknesses and high level categories that are related to this
weakness. These relationships are defined as ChildOf, ParentOf, MemberOr and give insight to
similar items that may exist at higher and lower levels of abstraction. In addition, relationships such
as PeerOf and CanAlsoBe are defined to show similar weaknesses that may want to be explored.
Relevant to the view "Research Concepts" (CWE-1000)
Nature Type ID Name Page
ChildOf 821 Incorrect Synchronization 1722
Applicable Platforms
Language : Java (Prevalence = Undetermined)
Common Consequences
Scope Impact Likelihood
Other Quality Degradation
Varies by Context
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
Use the start() method instead of the run() method.
Demonstrative Examples
Example 1:
The following excerpt from a Java program mistakenly calls run() instead of start().
Example Language: Java (Bad)
Thread thr = new Thread() {
public void run() {
...
}
};
thr.run();
Affected Resources
• System Process
CWE Version 4.14
CWE-573: Improper Following of Specification by Caller
CWE-573: Improper Following of Specification by Caller