Variant · Low-Medium

CWE-579: J2EE Bad Practices: Non-serializable Object Stored in Session

The product stores a non-serializable object as an HttpSession attribute, which can hurt reliability.

CWE-579 · Variant Level ·1 Mitigations

Description

The product stores a non-serializable object as an HttpSession attribute, which can hurt reliability.

A J2EE application can make use of multiple JVMs in order to improve application reliability and performance. In order to make the multiple JVMs appear as a single application to the end user, the J2EE container can replicate an HttpSession object across multiple JVMs so that if one JVM becomes unavailable another can step in and take its place without disrupting the flow of the application. This is only possible if all session data is serializable, allowing the session to be duplicated between the JVMs.

Potential Impact

Other

Quality Degradation

Demonstrative Examples

The following class adds itself to the session, but because it is not serializable, the session can no longer be replicated.
Bad
public class DataGlob {
                        String globName;String globValue;
                           public void addToSession(HttpSession session) {session.setAttribute("glob", this);}
                     }

Mitigations & Prevention

Implementation

In order for session replication to work, the values the product stores as attributes in the session must implement the Serializable interface.

Detection Methods

  • Automated Static Analysis High — 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 sea

Taxonomy Mappings

  • Software Fault Patterns: SFP1 — Glitch in computation

Frequently Asked Questions

What is CWE-579?

CWE-579 (J2EE Bad Practices: Non-serializable Object Stored in Session) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Variant-level weakness. The product stores a non-serializable object as an HttpSession attribute, which can hurt reliability.

How can CWE-579 be exploited?

Attackers can exploit CWE-579 (J2EE Bad Practices: Non-serializable Object Stored in Session) to quality degradation. This weakness is typically introduced during the Implementation phase of software development.

How do I prevent CWE-579?

Key mitigations include: In order for session replication to work, the values the product stores as attributes in the session must implement the Serializable interface.

What is the severity of CWE-579?

CWE-579 is classified as a Variant-level weakness (Low-Medium abstraction). Its actual severity depends on the specific context and how the weakness manifests in your application.