1304
Mapped Taxonomy Name Node ID Fit Mapped Node Name
Software Fault Patterns SFP3 Use of an improper API
CWE-576: EJB Bad Practices: Use of Java I/O
Weakness ID : 576
Structure : Simple
Abstraction : Variant
Description
The product violates the Enterprise JavaBeans (EJB) specification by using the java.io package.
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: "An enterprise
bean must not use the java.io package to attempt to access files and directories in the file system."
The specification justifies this requirement in the following way: "The file system APIs are not wellsuited
for business components to access data. Business components should use a resource
manager API, such as JDBC, to store data."
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
similar items that may exist at higher and lower levels of abstraction. In addition, relationships such
as PeerOf and CanAlsoBe are defined to show similar weaknesses that may want to be explored.
Relevant to the view "Research Concepts" (CWE-1000)
Nature Type ID Name Page
ChildOf 695 Use of Low-Level Functionality 1524
Applicable Platforms
Language : Java (Prevalence = Undetermined)
Common Consequences
Scope Impact Likelihood
Other Quality Degradation
Potential Mitigations
Phase: Implementation
Do not use Java I/O when writing EJBs.
Demonstrative Examples
Example 1:
The following Java example is a simple stateless Enterprise JavaBean that retrieves the interest
rate for the number of points for a mortgage. In this example, the interest rates for various points
are retrieved from an XML document on the local file system, and the EJB uses the Java I/O API to
retrieve the XML document from the local file system.
Example Language: Java (Bad)
@Stateless
public class InterestRateBean implements InterestRateRemote {
private Document interestRateXMLDocument = null;
private File interestRateFile = null;
public InterestRateBean() {
CWE Version 4.14
CWE-577: EJB Bad Practices: Use of Sockets
CWE-577: EJB Bad Practices: Use of Sockets