1309
This use of the Java Class Loader class within any kind of Enterprise JavaBean violates the
restriction of the EJB specification against obtaining the current class loader as this could
compromise the security of the application using the EJB.
Example 2:
An EJB is also restricted from creating a custom class loader and creating a class and instance of a
class from the class loader, as shown in the following example.
Example Language: Java (Bad)
@Stateless
public class LoaderSessionBean implements LoaderSessionRemote {
public LoaderSessionBean() {
try {
ClassLoader loader = new CustomClassLoader();
Class c = loader.loadClass("someClass");
Object obj = c.newInstance();
/* perform some task that uses the new class instance member variables or functions */
...
} catch (Exception ex) {...}
}
public class CustomClassLoader extends ClassLoader {
}
}
MemberOf Relationships
This MemberOf relationships table shows additional CWE Catgeories and Views that reference this
weakness as a member. This information is often useful in understanding where a weakness fits
within the context of external information sources.
Nature Type ID Name Page
MemberOf 1001 SFP Secondary Cluster: Use of an Improper API 888 2420
MemberOf 1412 Comprehensive Categorization: Poor Coding Practices 1400 2538
Taxonomy Mappings
Mapped Taxonomy Name Node ID Fit Mapped Node Name
Software Fault Patterns SFP3 Use of an improper API
CWE-579: J2EE Bad Practices: Non-serializable Object Stored in Session
Weakness ID : 579
Structure : Simple
Abstraction : Variant
Description
The product stores a non-serializable object as an HttpSession attribute, which can hurt reliability.
Extended Description
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.
Relationships
The table(s) below shows the weaknesses and high level categories that are related to this
weakness. These relationships are defined as ChildOf, ParentOf, MemberOr and give insight to
CWE Version 4.14
CWE-579: J2EE Bad Practices: Non-serializable Object Stored in Session
CWE-579: J2EE Bad Practices: Non-serializable Object Stored in Session