1319
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 1071 Empty Code Block 1910
Weakness Ordinalities
Indirect :
Applicable Platforms
Language : Java (Prevalence = Undetermined)
Common Consequences
Scope Impact Likelihood
Other Other
An empty synchronized block will wait until nobody else
is using the synchronizer being specified. While this may
be part of the desired behavior, because you haven't
protected the subsequent code by placing it inside the
synchronized block, nothing is stopping somebody else
from modifying whatever it was you were waiting for while
you run the subsequent code.
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
When you come across an empty synchronized statement, or a synchronized statement in
which the code has been commented out, try to determine what the original intentions were and
whether or not the synchronized block is still necessary.
Demonstrative Examples
Example 1:
The following code attempts to synchronize on an object, but does not execute anything in
the synchronized block. This does not actually accomplish anything and may be a sign that a
programmer is wrestling with synchronization but has not yet achieved the result they intend.
Example Language: Java (Bad)
synchronized(this) { }
CWE Version 4.14
CWE-586: Explicit Call to Finalize()
CWE-586: Explicit Call to Finalize()