Security

What is Cloneable Class Containing Sensitive (CWE-498)?

Learn how Cloneable Class Containing Sensitive Information works, see real-world code examples, and discover framework-specific fixes to prevent this...

SP
Shreya Pillai July 29, 2026 5 min read Security
AI-friendly summary

What it is: Cloneable Class Containing Sensitive Information (CWE-498) is a vulnerability that occurs when a class with sensitive data can be cloned, allowing unauthorized access.

Why it matters: This issue bypasses security checks in constructors and exposes sensitive information to attackers.

How to fix it: Ensure the clone method is final and throw super.clone() to prevent cloning.

TL;DR: Cloneable Class Containing Sensitive Information (CWE-498) allows unauthorized access to sensitive data through class cloning, bypassing security checks. Fix by ensuring the clone method is final and throws super.clone().

Field Value
CWE ID CWE-498
OWASP Category Not directly mapped
CAPEC None known
Typical Severity Medium
Affected Technologies Java, Python, Node.js
Detection Difficulty Moderate
Last Updated 2026-07-29

What is Cloneable Class Containing Sensitive Information?

Cloneable Class Containing Sensitive Information (CWE-498) is a type of vulnerability that occurs when a class with sensitive data can be cloned, allowing unauthorized access to the sensitive information. As defined by the MITRE Corporation under CWE-498, this issue bypasses security checks in constructors and exposes sensitive data.

Quick Summary

Cloneable Class Containing Sensitive Information (CWE-703) is a serious vulnerability that allows attackers to clone classes containing sensitive data without executing the constructor’s security checks. This can lead to unauthorized access to sensitive information and compromise confidentiality. Jump to: Overview · How It Works · Business Impact · Attack Scenario · Detection · Fixes

Jump to: Quick Summary · Cloneable Class Containing Sensitive Information Overview · How Cloneable Class Containing Sensitive Information Works · Business Impact of Cloneable Class Containing Sensitive Information · Cloneable Class Containing Sensitive Information Attack Scenario · How to Detect Cloneable Class Containing Sensitive Information · How to Fix Cloneable Class Containing Sensitive Information · Framework-Specific Fixes for Cloneable Class Containing Sensitive Information · How to Ask AI to Check Your Code for Cloneable Class Containing Sensitive Information · Cloneable Class Containing Sensitive Information Best Practices Checklist · Cloneable Class Containing Sensitive Information FAQ · Vulnerabilities Related to Cloneable Class Containing Sensitive Information · References · Scan Your Own Site

Cloneable Class Containing Sensitive Information Overview

What

Cloneable Class Containing Sensitive Information is a vulnerability where classes with sensitive data can be cloned, bypassing security checks.

Why it matters

This issue allows unauthorized access to sensitive information and compromises confidentiality.

Where it occurs

It occurs in any application that uses cloneable classes containing sensitive data without proper validation or protection during cloning.

Who is affected

Applications using Java, Python, Node.js, and other languages with cloneable objects are at risk if they do not properly secure sensitive data.

Who is NOT affected

Systems already implementing robust security checks for cloning operations are not vulnerable.

How Cloneable Class Containing Sensitive Information Works

Root Cause

The root cause lies in the ability to clone a class containing sensitive information without executing the constructor’s security checks.

Attack Flow

  1. Attacker identifies a cloneable class with sensitive data.
  2. Attacker clones the object, bypassing any security measures within the constructor.
  3. Sensitive data is accessed through the cloned object.

Prerequisites to Exploit

  • The target application must contain a cloneable class with sensitive information.
  • The cloning method should not enforce security checks during instantiation.

Vulnerable Code

public class SecureData implements Cloneable {
    private String secret;

    public SecureData(String secret) {
        this.secret = secret;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

This code demonstrates a vulnerable implementation where the clone() method simply calls super.clone() without any security checks.

Secure Code

public class SecureData implements Cloneable {
    private String secret;

    public SecureData(String secret) {
        this.secret = secret;
    }

    @Override
    protected final Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

The secure version makes the clone() method final and ensures it cannot be overridden, preventing unauthorized cloning.

Business Impact of Cloneable Class Containing Sensitive Information

Confidentiality

Sensitive data can be accessed by attackers through cloned objects, compromising confidentiality.

  • Financial information may be exposed to unauthorized users.
  • Personal user data could be leaked or misused.

Integrity

Integrity is not directly impacted in this scenario as the issue primarily affects access control and confidentiality.

Availability

Availability is also unaffected since the vulnerability does not disrupt system operations but exposes sensitive data.

Cloneable Class Containing Sensitive Information Attack Scenario

  1. An attacker identifies a cloneable class with sensitive information.
  2. The attacker clones the object, bypassing any security measures within the constructor.
  3. The attacker accesses and utilizes the cloned sensitive data for malicious purposes.

How to Detect Cloneable Class Containing Sensitive Information

Manual Testing

  • Check if classes containing sensitive data implement Cloneable.
  • Ensure that the clone method enforces proper security checks during cloning.

Automated Scanners (SAST / DAST)

Static analysis can detect instances where classes with sensitive data are marked as cloneable without proper validation. Dynamic testing can confirm whether these objects can be cloned in a running application.

PenScan Detection

PenScan’s scanner engines such as ZAP, Nuclei, Wapiti, Nikto, SSLyze, Dalfox, and Nmap can detect this vulnerability by identifying classes with sensitive data that are cloneable without proper checks.

False Positive Guidance

False positives may occur if the cloned object is used in a controlled environment where security measures are already in place. Ensure that cloning operations are properly validated to avoid false detections.

How to Fix Cloneable Class Containing Sensitive Information

  • Make the clone() method final.
  • Throw super.clone() to prevent unauthorized cloning of sensitive data.

Framework-Specific Fixes for Cloneable Class Containing Sensitive Information

Java

public class SecureData implements Cloneable {
    private String secret;

    public SecureData(String secret) {
        this.secret = secret;
    }

    @Override
    protected final Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

How to Ask AI to Check Your Code for Cloneable Class Containing Sensitive Information

Copy-paste prompt

Review the following Java code block for potential CWE-498 Cloneable Class Containing Sensitive Information vulnerabilities and rewrite it using final clone method: [paste code here]

Cloneable Class Containing Sensitive Information Best Practices Checklist

  • Ensure that classes containing sensitive data are not marked as cloneable.
  • Make the clone() method final to prevent unauthorized cloning.
  • Implement proper security checks during cloning operations.

Cloneable Class Containing Sensitive Information FAQ

How does Cloneable Class Containing Sensitive Information work?

It occurs when a class with sensitive data can be cloned, allowing the data to be accessed without executing the constructor that may perform security checks.

Why is Cloneable Class Containing Sensitive Information dangerous?

By bypassing the constructor’s security checks, attackers can access sensitive information directly through cloning.

How do I detect Cloneable Class Containing Sensitive Information in my code?

Look for classes that implement the clone method and contain sensitive data without proper validation or protection during cloning.

What is the impact of Cloneable Class Containing Sensitive Information on business operations?

It can lead to unauthorized access to sensitive information, compromising confidentiality and potentially leading to financial loss and reputational damage.

How do I fix Cloneable Class Containing Sensitive Information in Java?

Ensure that the clone method is final and throw super.clone() to prevent unauthorized cloning of sensitive data.

What are some best practices for preventing Cloneable Class Containing Sensitive Information?

Restrict access to classes containing sensitive information, ensure proper validation during cloning, and use secure coding practices.

Can you provide an example of vulnerable code for Cloneable Class Containing Sensitive Information?

A class with a public clone method that does not perform security checks when creating a new instance.

CWE Name Relationship
CWE-668 Exposure of Resource to Wrong Sphere ChildOf
CWE-200 Exposure of Sensitive Information to an Unauthorized Actor CanPrecede

References

Scan Your Own Site

Manual code review catches what you know to look for. An automated scan catches what you didn’t. Scan your own website using PenScan to find Cloneable Class Containing Sensitive Information and other risks before an attacker does.