Description
The product violates secure coding principles for mobile code by declaring a finalize() method public.
A product should never call finalize explicitly, except to call super.finalize() inside an implementation of finalize(). In mobile code situations, the otherwise error prone practice of manual garbage collection can become a security threat if an attacker can maliciously invoke a finalize() method because it is declared with public access.
Potential Impact
Confidentiality, Integrity, Availability
Alter Execution Logic, Execute Unauthorized Code or Commands, Modify Application Data
Demonstrative Examples
public final class urlTool extends Applet {public void finalize() {...}...}Mitigations & Prevention
If you are using finalize() as it was designed, there is no reason to declare finalize() with anything other than protected access.
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
- The CERT Oracle Secure Coding Standard for Java (2011): MET12-J — Do not use finalizers
- Software Fault Patterns: SFP28 — Unexpected access points
Frequently Asked Questions
What is CWE-583?
CWE-583 (finalize() Method Declared Public) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Variant-level weakness. The product violates secure coding principles for mobile code by declaring a finalize() method public.
How can CWE-583 be exploited?
Attackers can exploit CWE-583 (finalize() Method Declared Public) to alter execution logic, execute unauthorized code or commands, modify application data. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-583?
Key mitigations include: If you are using finalize() as it was designed, there is no reason to declare finalize() with anything other than protected access.
What is the severity of CWE-583?
CWE-583 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.