Description
The product contains an empty synchronized block.
An empty synchronized block does not actually accomplish any synchronization and may indicate a troubled section of code. An empty synchronized block can occur because code no longer needed within the synchronized block is commented out without removing the synchronized block.
Potential Impact
Other
Other
Demonstrative Examples
synchronized(this) { }public void setID(int ID){synchronized(this){this.ID = ID;}}Mitigations & Prevention
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.
Detection Methods
- Automated Static Analysis High — 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 sea
Related Weaknesses
Taxonomy Mappings
- Software Fault Patterns: SFP21 — Multiple locks/unlocks
Frequently Asked Questions
What is CWE-585?
CWE-585 (Empty Synchronized Block) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Variant-level weakness. The product contains an empty synchronized block.
How can CWE-585 be exploited?
Attackers can exploit CWE-585 (Empty Synchronized Block) to other. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-585?
Key mitigations include: 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 sy
What is the severity of CWE-585?
CWE-585 is classified as a Variant-level weakness (Low-Medium abstraction). Its actual severity depends on the specific context and how the weakness manifests in your application.