---
title: "CWE-498: Cloneable Class Containing Sensitive Information"
url: https://radicalnotion.ai/cwe/cwe-498
type: cwe
description: "The code contains a class with sensitive data, but the class is cloneable. The data can then be accessed by cloning the class."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-498: Cloneable Class Containing Sensitive Information

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

## Description

The code contains a class with sensitive data, but the class is cloneable. The data can then be accessed by cloning the class.

## Modes of introduction

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

## Applicable platforms

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

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Access Control, Confidentiality | Bypass Protection Mechanism, Read Application Data | A class that does not explicitly deny cloning can be cloned by any other class without running the constructor. Cloneable classes are effectively open classes, since data cannot be hidden in the. This is also dangerous since the constructor may perform security-related checks. By allowing the object to be cloned, those checks may be bypassed. |

## Potential mitigations

### Implementation

If you do make your classes clonable, ensure that your clone method is final and throw super.clone().

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

## Demonstrative examples

### Example 1

The following example demonstrates the weakness.

Bad code:

```java
public class CloneClient {
    public CloneClient() //throws
    java.lang.CloneNotSupportedException {

        Teacher t1 = new Teacher("guddu","22,nagar road");
        //...
        // Do some stuff to remove the teacher.
        Teacher t2 = (Teacher)t1.clone();
        System.out.println(t2.name);
    }
    public static void main(String args[]) {

        new CloneClient();
    }
}
class Teacher implements Cloneable {

    public Object clone() {

        try {
            return super.clone();
        }
        catch (java.lang.CloneNotSupportedException e) {

            throw new RuntimeException(e.toString());
        }
    }
    public String name;
    public String clas;
    public Teacher(String name,String clas) {

        this.name = name;
        this.clas = clas;
    }
}
```

Good code:

```java
public final void clone() throws java.lang.CloneNotSupportedException {
    throw new java.lang.CloneNotSupportedException();
}
```

Make classes uncloneable by defining a clone function like:

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-668](https://radicalnotion.ai/cwe/cwe-668) | Exposure of Resource to Wrong Sphere |
| Can precede | [CWE-200](https://radicalnotion.ai/cwe/cwe-200) | Exposure of Sensitive Information to an Unauthorized Actor |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CLASP | Information leak through class cloning | - | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Sensitive classes must not let themselves be copied | OBJ07-J | - |
| Software Fault Patterns | Exposed Data | SFP23 | - |

## Frequently asked questions

### What is CWE-498?

The code contains a class with sensitive data, but the class is cloneable. The data can then be accessed by cloning the class.

### How do you prevent CWE-498?

If you do make your classes clonable, ensure that your clone method is final and throw super.clone().

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

Exploiting CWE-498 can lead to: Bypass Protection Mechanism, Read Application Data.

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

---

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