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.
Last updated
Overview
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.
Common consequences
What can happen when CWE-579 is exploited.
Quality Degradation
Affects: Other
How it happens
When it is introduced
Typically introduced during these phases of the software lifecycle.
Applies to
Languages
How to prevent it
Practical mitigations for CWE-579, grouped by where in the lifecycle they apply.
In order for session replication to work, the values the product stores as attributes in the session must implement the Serializable interface.
How to detect it
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
Code examples
Illustrative examples from MITRE showing how the weakness appears in code.
The following class adds itself to the session, but because it is not serializable, the session can no longer be replicated.
Vulnerable example
public class DataGlob {Terminology & mappings
Mapped taxonomies
- Software Fault Patterns: Glitch in computation (SFP1)
Frequently asked questions
Common questions about CWE-579.
- What is CWE-579?
- The product stores a non-serializable object as an HttpSession attribute, which can hurt reliability.
- How do you prevent CWE-579?
- In order for session replication to work, the values the product stores as attributes in the session must implement the Serializable interface.
- How is CWE-579 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-579?
- Exploiting CWE-579 can lead to: Quality Degradation.
References
- MITRE CWE definition (CWE-579) (opens in a new tab)
- CWE-579 vulnerabilities on NVD (opens in a new tab)
- Learn: What is a CWE?
Weakness data is sourced from the MITRE CWE catalog (v4.20). CVE associations are aggregated and kept current by RadicalNotion.AI.
Stay ahead of CWE-579
Get alerted the moment a new CWE-579 vulnerability affects your stack, with AI-written analysis, severity context, and remediation guidance.