CWE-575 Variante Brouillon

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 specification's design principles.

Définition

What is CWE-575?

This vulnerability occurs when an Enterprise JavaBeans (EJB) component incorrectly uses AWT or Swing UI toolkits, violating the EJB specification's design principles.
The EJB specification explicitly prohibits beans from using AWT or Swing to handle user input or display output. This rule exists because EJB components are designed to run on application servers, which typically operate in headless environments without direct access to a keyboard, monitor, or graphical interface. Attempting to create UI elements in this context will fail or cause unpredictable behavior, breaking the application's portability across different EJB containers. For developers, this means all business logic within your EJB must remain separate from presentation-layer code. Instead of embedding AWT/Swing, user interactions should be handled by a dedicated client-tier application (like a web front-end or desktop client) that communicates with the EJB layer remotely. Adhering to this separation ensures your bean remains portable, scalable, and consistent with the server-side execution model intended for enterprise applications.
Impact réel

Real-world CVEs caused by CWE-575

Aucune référence CVE publique n'est liée à ce CWE dans le catalogue MITRE pour le moment.

Comment les attaquants l'exploitent

Parcours de l'attaquant étape par étape

  1. 1

    The following Java example is a simple converter class for converting US dollars to Yen. This converter class demonstrates the improper practice of using a stateless session Enterprise JavaBean that implements an AWT Component and AWT keyboard event listener to retrieve keyboard input from the user for the amount of the US dollars to convert to Yen.

  2. 2

    This use of the AWT and Swing APIs within any kind of Enterprise JavaBean not only violates the restriction of the EJB specification against using AWT or Swing within an EJB but also violates the intended use of Enterprise JavaBeans to separate business logic from presentation logic.

  3. 3

    The Stateless Session Enterprise JavaBean should contain only business logic. Presentation logic should be provided by some other mechanism such as Servlets or Java Server Pages (JSP) as in the following Java/JSP example.

Exemple de code vulnérable

Vulnerable Java

The following Java example is a simple converter class for converting US dollars to Yen. This converter class demonstrates the improper practice of using a stateless session Enterprise JavaBean that implements an AWT Component and AWT keyboard event listener to retrieve keyboard input from the user for the amount of the US dollars to convert to Yen.

Vulnérable Java
@Stateless
  public class ConverterSessionBean extends Component implements KeyListener, ConverterSessionRemote {
```
/* member variables for receiving keyboard input using AWT API */* 
  		
  		...
  		private StringBuffer enteredText = new StringBuffer();
  		
  		
  		 */* conversion rate on US dollars to Yen */* 
  		
  		private BigDecimal yenRate = new BigDecimal("115.3100");
  		
  		public ConverterSessionBean() {
  		```
  				super();
```
/* method calls for setting up AWT Component for receiving keyboard input */* 
  				
  				...
  				addKeyListener(this);}
  		
  		public BigDecimal dollarToYen(BigDecimal dollars) {
  		```
  			BigDecimal result = dollars.multiply(yenRate);
  			return result.setScale(2, BigDecimal.ROUND_DOWN);
  		}
```
/* member functions for implementing AWT KeyListener interface */* 
  		
  		public void keyTyped(KeyEvent event) {
  		```
  			...
  		}
  		public void keyPressed(KeyEvent e) {
  		}
  		public void keyReleased(KeyEvent e) {
  		}
```
/* member functions for receiving keyboard input and displaying output */* 
  		
  		public void paint(Graphics g) {...}
  		
  		...}
Exemple de code sécurisé

Secure Java

The Stateless Session Enterprise JavaBean should contain only business logic. Presentation logic should be provided by some other mechanism such as Servlets or Java Server Pages (JSP) as in the following Java/JSP example.

Sécurisé Java
@Stateless
  public class ConverterSessionBean implements ConverterSessionRemoteInterface {
```
/* conversion rate on US dollars to Yen */* 
  		private BigDecimal yenRate = new BigDecimal("115.3100");
  		
  		public ConverterSessionBean() {
  		}
  		
  		
  		 */* remote method to convert US dollars to Yen */* 
  		
  		public BigDecimal dollarToYen(BigDecimal dollars) {
  		```
  			BigDecimal result = dollars.multiply(yenRate);
  			return result.setScale(2, BigDecimal.ROUND_DOWN);
  		}
  }
What changed: the unsafe sink is replaced (or the input is validated/escaped) so the same payload no longer triggers the weakness.
Liste de contrôle de prévention

How to prevent CWE-575

  • Architecture and Design Do not use AWT/Swing when writing EJBs.
Signaux de détection

How to detect CWE-575

SAST High

Exécuter une analyse statique (SAST) sur le code source à la recherche du motif non sécurisé dans le flux de données.

DAST Moderate

Exécuter des tests de sécurité applicative dynamique (DAST) contre le point de terminaison en ligne.

Runtime Moderate

Surveiller les journaux runtime pour détecter des traces d'exception inhabituelles, des entrées malformées ou des tentatives de contournement d'autorisation.

Code review Moderate

Revue de code : signaler tout nouveau code qui traite les entrées de cette surface sans utiliser les helpers du framework validés.

Correction automatique Plexicus

Plexicus détecte automatiquement CWE-575 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.

Questions fréquentes

Frequently asked questions

Qu'est-ce que CWE-575 ?

This vulnerability occurs when an Enterprise JavaBeans (EJB) component incorrectly uses AWT or Swing UI toolkits, violating the EJB specification's design principles.

Quelle est la gravité de CWE-575 ?

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-575 ?

MITRE lists the following affected platforms: Java.

Comment puis-je prévenir CWE-575 ?

Do not use AWT/Swing when writing EJBs.

Comment Plexicus détecte et corrige CWE-575 ?

Le moteur SAST de Plexicus reconnaît la signature de flux de données de CWE-575 à 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-575 ?

MITRE publie la définition canonique à https://cwe.mitre.org/data/definitions/575.html. Vous pouvez également consulter la documentation OWASP et NIST pour des conseils adjacents.

Prêt quand vous l'êtes

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.