---
title: "CWE-583: finalize() Method Declared Public"
url: https://radicalnotion.ai/cwe/cwe-583
type: cwe
description: "The product violates secure coding principles for mobile code by declaring a finalize() method public."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-583: finalize() Method Declared Public

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Incomplete
- **CVEs with this as primary weakness:** 0
- **Of those, in CISA KEV:** 0
- **New in 2026:** 0
- **CWE catalog version:** 4.21

## Description

The product violates secure coding principles for mobile code by declaring a finalize() method public.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Applicable platforms

**Languages:** Java (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Confidentiality, Integrity, Availability | Alter Execution Logic, Execute Unauthorized Code or Commands, Modify Application Data | 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 mitigations

### Implementation

A product should never call finalize explicitly, except to call super.finalize() inside an implementation of finalize(). 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

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 Java Applet code mistakenly declares a public finalize() method.

Bad code:

```java
public final class urlTool extends Applet {
    public void finalize() {
        ...
    }
    ...
}
```

Mobile code, in this case a Java Applet, is code that is transmitted across a network and executed on a remote machine. Because mobile code developers have little if any control of the environment in which their code will execute, special security concerns become relevant. One of the biggest environmental threats results from the risk that the mobile code will run side-by-side with other, potentially malicious, mobile code. Because all of the popular web browsers execute code from multiple sources together in the same JVM, many of the security guidelines for mobile code are focused on preventing manipulation of your objects' state and behavior by adversaries who have access to the same virtual machine where your product is running.

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-732](https://radicalnotion.ai/cwe/cwe-732) | Incorrect Permission Assignment for Critical Resource |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| The CERT Oracle Secure Coding Standard for Java (2011) | Do not use finalizers | MET12-J | - |
| Software Fault Patterns | Unexpected access points | SFP28 | - |

## Frequently asked questions

### What is CWE-583?

The product violates secure coding principles for mobile code by declaring a finalize() method public.

### How do you prevent CWE-583?

A product should never call finalize explicitly, except to call super.finalize() inside an implementation of finalize(). If you are using finalize() as it was designed, there is no reason to declare finalize() with anything other than protected access.

### How is CWE-583 detected?

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.)

### What are the consequences of CWE-583?

Exploiting CWE-583 can lead to: Alter Execution Logic, Execute Unauthorized Code or Commands, Modify Application Data.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/583.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-583). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
