Exécuter une analyse statique (SAST) sur le code source à la recherche du motif non sécurisé dans le flux de données.
EJB Bad Practices: Use of Java I/O
This vulnerability occurs when an Enterprise JavaBeans (EJB) component incorrectly uses Java I/O (java.io) operations to access the file system, violating the EJB specification's design principles.
What is CWE-576?
Real-world CVEs caused by CWE-576
Aucune référence CVE publique n'est liée à ce CWE dans le catalogue MITRE pour le moment.
Parcours de l'attaquant étape par étape
- 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.
- 2
This use of the Java I/O API within any kind of Enterprise JavaBean violates the EJB specification by using the java.io package for accessing files within the local filesystem.
- 3
An Enterprise JavaBean should use a resource manager API for storing and accessing data. In the following example, the private member function getInterestRateFromXMLParser uses an XML parser API to retrieve the interest rates.
Vulnerable Java
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.
@Stateless
public class InterestRateBean implements InterestRateRemote {
private Document interestRateXMLDocument = null;
private File interestRateFile = null;
public InterestRateBean() {
try {
```
/* get XML document from the local filesystem */*
interestRateFile = new File(Constants.INTEREST_RATE_FILE);
if (interestRateFile.exists())
{
```
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
interestRateXMLDocument = db.parse(interestRateFile);
}
} catch (IOException ex) {...}
}
public BigDecimal getInterestRate(Integer points) {
return getInterestRateFromXML(points);
}
```
/* member function to retrieve interest rate from XML document on the local file system */*
private BigDecimal getInterestRateFromXML(Integer points) {...}} Secure Java
An Enterprise JavaBean should use a resource manager API for storing and accessing data. In the following example, the private member function getInterestRateFromXMLParser uses an XML parser API to retrieve the interest rates.
@Stateless
public class InterestRateBean implements InterestRateRemote {
public InterestRateBean() {
}
public BigDecimal getInterestRate(Integer points) {
return getInterestRateFromXMLParser(points);
}
```
/* member function to retrieve interest rate from XML document using an XML parser API */*
private BigDecimal getInterestRateFromXMLParser(Integer points) {...}} How to prevent CWE-576
- Implementation Do not use Java I/O when writing EJBs.
How to detect CWE-576
Exécuter des tests de sécurité applicative dynamique (DAST) contre le point de terminaison en ligne.
Surveiller les journaux runtime pour détecter des traces d'exception inhabituelles, des entrées malformées ou des tentatives de contournement d'autorisation.
Revue de code : signaler tout nouveau code qui traite les entrées de cette surface sans utiliser les helpers du framework validés.
Plexicus détecte automatiquement CWE-576 et ouvre une PR de correction en moins de 60 secondes.
Codex Remedium analyse chaque commit, identifie cette faiblesse précise et livre une pull request prête à être relue avec le correctif. Pas de tickets. Pas de transferts.
Frequently asked questions
Qu'est-ce que CWE-576 ?
This vulnerability occurs when an Enterprise JavaBeans (EJB) component incorrectly uses Java I/O (java.io) operations to access the file system, violating the EJB specification's design principles.
Quelle est la gravité de CWE-576 ?
MITRE n'a pas publié de note de probabilité d'exploitation pour cette faiblesse. Traitez-la comme un impact moyen jusqu'à ce que votre modèle de menace prouve le contraire.
Quels langages ou plateformes sont affectés par CWE-576 ?
MITRE lists the following affected platforms: Java.
Comment puis-je prévenir CWE-576 ?
Do not use Java I/O when writing EJBs.
Comment Plexicus détecte et corrige CWE-576 ?
Le moteur SAST de Plexicus reconnaît la signature de flux de données de CWE-576 à chaque commit. Lorsqu'une correspondance est trouvée, notre agent Codex Remedium ouvre une PR de correction avec le code corrigé, les tests et un résumé d'une ligne pour le relecteur.
Où puis-je en savoir plus sur CWE-576 ?
MITRE publie la définition canonique à https://cwe.mitre.org/data/definitions/576.html. Vous pouvez également consulter la documentation OWASP et NIST pour des conseils adjacents.
Weaknesses related to CWE-576
Use of Low-Level Functionality
This vulnerability occurs when code bypasses high-level framework controls by directly using low-level system functions, violating the…
Direct Use of Unsafe JNI
This weakness occurs when a Java application directly calls native code through the Java Native Interface (JNI), exposing the entire…
J2EE Bad Practices: Direct Management of Connections
This vulnerability occurs when a J2EE application handles database connections directly instead of using the container's built-in…
J2EE Bad Practices: Direct Use of Sockets
This vulnerability occurs when a J2EE application creates network sockets directly, bypassing the container-managed communication…
J2EE Bad Practices: Direct Use of Threads
Creating or managing threads directly within a J2EE application is a risky practice that violates the platform's standards and often leads…
EJB Bad Practices: Use of Synchronization Primitives
This vulnerability occurs when an Enterprise JavaBeans (EJB) component improperly uses thread synchronization primitives, violating the…
EJB Bad Practices: Use of AWT Swing
This vulnerability occurs when an Enterprise JavaBeans (EJB) component incorrectly uses AWT or Swing UI toolkits, violating the EJB…
Arrêtez de payer par développeur.
Commencez à fermer la boucle.
Plexicus est l'ASPM natif IA qui scanne, filtre, corrige, penteste et explique — de façon autonome. Développeurs illimités, dépôts illimités, actions IA à usage équitable. Vrai niveau gratuit, €269/mo annuel quand vous êtes prêt.