1307
Example Language: Java (Bad)
@Stateless
public class StockSymbolBean extends Thread implements StockSymbolRemote {
ServerSocket serverSocket = null;
Socket clientSocket = null;
boolean listening = false;
public StockSymbolBean() {
try {
serverSocket = new ServerSocket(Constants.SOCKET_PORT);
} catch (IOException ex) {...}
listening = true;
while(listening) {
start();
}
}
public String getStockSymbol(String name) {...}
public BigDecimal getStockValue(String symbol) {...}
public void run() {
try {
clientSocket = serverSocket.accept();
} catch (IOException e) {...}
...
}
}
The previous two examples within any type of Enterprise JavaBean violate the EJB specification by
attempting to listen on a socket, accepting connections on a socket, or using a socket for multicast.
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-578: EJB Bad Practices: Use of Class Loader
Weakness ID : 578
Structure : Simple
Abstraction : Variant
Description
The product violates the Enterprise JavaBeans (EJB) specification by using the class loader.
Extended Description
The Enterprise JavaBeans specification requires that every bean provider follow a set of
programming guidelines designed to ensure that the bean will be portable and behave consistently
in any EJB container. In this case, the product violates the following EJB guideline: "The enterprise
bean must not attempt to create a class loader; obtain the current class loader; set the context
class loader; set security manager; create a new security manager; stop the JVM; or change the
input, output, and error streams." The specification justifies this requirement in the following way:
"These functions are reserved for the EJB container. Allowing the enterprise bean to use these
CWE Version 4.14
CWE-578: EJB Bad Practices: Use of Class Loader
CWE-578: EJB Bad Practices: Use of Class Loader