JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
Java


JAVA.CLASS.SER.ND : Serialization Not Disabled (Java)

要旨

Serialization for a class has not been explicitly disabled by defining a writeObject() method that always throws an exception.

プロパティ

クラス名 Serialization Not Disabled (Java)
日本語クラス名 Serialization Not Disabled (Java)
クラス分類 信頼性 (reliability)
ニーモニック JAVA.CLASS.SER.ND
カテゴリー
CWE CWE:499 Serializable Class Containing Sensitive Data
  CWE:502 Deserialization of Untrusted Data
CERT-Java CERT-Java:SER01-J Do not deviate from the proper signatures of serialization methods
  CERT-Java:SER03-J Do not serialize unencrypted sensitive data
  CERT-Java:SER06-J Make defensive copies of private mutable components during deserialization
  CERT-Java:SER07-J Do not use the default serialized form for classes with implementation-defined invariants
  CERT-Java:SER12-J Prevent deserialization of untrusted data
OWASP-2021 OWASP-2021:A8 Software and data integrity failures
OWASP-2025 OWASP-2025:A08 Software or Data Integrity Failures
対応言語 Available for Java and Kotlin.
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Serialization Not Disabled (Java)"

In the following code excerpt, class MyWindow is serializable (because it extends serializable class JFrame).

However, the programmer has annotated the class with @SuppressWarnings("serial"), suppressing any compiler warnings about the missing serialVersionUID field. CodeSonar observes this suppression and reasons that the programmer does not intend the class to be serialized. However, serialization has not been explicitly disabled.

// MyWindow.java
import javax.swing.JFrame;

@SuppressWarnings("serial")
public class MyWindow extends JFrame {  // "Serialization Not Disabled" warning issued here 
  private final int secret;

  public MyWindow(int secret) {
      this.secret = secret;
  }
}

In this example, the programmer should explicitly prevent serialization of class MyWindow, as follows.

// MyWindow.java, after modification
import java.io.ObjectOutputStream;
import javax.swing.JFrame;

@SuppressWarnings("serial")
public class MyWindow extends JFrame {
  private final int secret;

  public MyWindow(int secret) {
      this.secret = secret;
  }

  private void writeObject(ObjectOutputStream stream) {
      throw new RuntimeException("Serialization is not allowed");
  }
}

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。

 

To report problems with this documentation, please visit https://support.codesecure.com/.