---
title: "CWE-493: Critical Public Variable Without Final Modifier"
url: https://radicalnotion.ai/cwe/cwe-493
type: cwe
description: "The product has a critical public variable that is not final."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-493: Critical Public Variable Without Final Modifier

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Draft
- **Likelihood of exploit:** High
- **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 has a critical public variable that is not final.

## Background

Mobile code, such as 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 program is running.

Final provides security by only allowing non-mutable objects to be changed after being set. However, only objects which are not extended can be made final.

## Modes of introduction

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

## Applicable platforms

**Languages:** Object-Oriented (Undetermined), Java (Undetermined), C++ (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity | Modify Application Data | If a field is non-final and public, it can be changed once the value is set by any function that has access to the class that contains the field. The object could potentially be tampered with. This could lead to a vulnerability if other parts of the program make assumptions about the contents of the field. |
| Confidentiality | Read Application Data | The object could potentially allow the object to be read. |

## Potential mitigations

### Implementation

Declare all public fields as final when possible, especially if it is used to maintain internal state of an Applet or of classes used by an Applet. If a field must be public, then perform all appropriate sanity checks before accessing the field from your 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

## Demonstrative examples

### Example 1

Suppose this WidgetData class is used for an e-commerce web site. The programmer attempts to prevent price-tampering attacks by setting the price of the widget using the constructor.

Bad code:

```java
public final class WidgetData extends Applet {
    public float price;
    ...
    public WidgetData(...) {
        this.price = LookupPrice("MyWidgetType");
    }
}
```

The price field is not final. Even though the value is set by the constructor, it could be modified by anybody that has access to an instance of WidgetData.

### Example 2

Assume the following code is intended to provide the location of a configuration file that controls execution of the application.

Bad code:

```c++
public string configPath = "/etc/application/config.dat";
```

Bad code:

```java
public String configPath = new String("/etc/application/config.dat");
```

While this field is readable from any function, and thus might allow an information leak of a pathname, a more serious problem is that it can be changed by any function.

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-732](https://radicalnotion.ai/cwe/cwe-732) | Incorrect Permission Assignment for Critical Resource |
| Child | [CWE-500](https://radicalnotion.ai/cwe/cwe-500) | Public Static Field Not Marked Final |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| 7 Pernicious Kingdoms | Mobile Code: Non-Final Public Field | - | - |
| CLASP | Failure to provide confidentiality for stored data | - | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Do not use public static nonfinal variables | OBJ10-J | - |
| Software Fault Patterns | Unexpected access points | SFP28 | - |

## Frequently asked questions

### What is CWE-493?

The product has a critical public variable that is not final.

### How do you prevent CWE-493?

Declare all public fields as final when possible, especially if it is used to maintain internal state of an Applet or of classes used by an Applet. If a field must be public, then perform all appropriate sanity checks before accessing the field from your code.

### How is CWE-493 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-493?

Exploiting CWE-493 can lead to: Modify Application Data, Read Application Data.

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

---

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