CWE-575 Variante Borrador

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.

Definición

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.
Impacto en el mundo real

Real-world CVEs caused by CWE-575

Todavía no hay CVEs públicos enlazados a esta CWE en el catálogo de MITRE.

Cómo lo explotan los atacantes

Ruta del atacante paso a paso

  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.

Ejemplo de código vulnerable

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.

Vulnerable 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) {...}
  		
  		...}
Ejemplo de código seguro

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.

Seguro 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.
Lista de prevención

How to prevent CWE-575

  • Architecture and Design Do not use AWT/Swing when writing EJBs.
Señales de detección

How to detect CWE-575

SAST High

Ejecuta análisis estático (SAST) sobre el código buscando el patrón inseguro en el flujo de datos.

DAST Moderate

Ejecuta pruebas dinámicas de seguridad de aplicaciones (DAST) contra el endpoint en vivo.

Runtime Moderate

Vigila los logs en tiempo de ejecución para detectar trazas de excepción inusuales, entradas malformadas o intentos de bypass de autorización.

Code review Moderate

Revisión de código: marca cualquier código nuevo que maneje entrada desde esta superficie sin usar los helpers validados del framework.

Auto-corrección de Plexicus

Plexicus detecta automáticamente CWE-575 y abre un PR de corrección en menos de 60 segundos.

Codex Remedium escanea cada commit, identifica esta debilidad concreta y entrega un pull request listo para revisión con el parche. Sin tickets. Sin traspasos.

Preguntas frecuentes

Frequently asked questions

¿Qué es 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.

¿Qué gravedad tiene CWE-575?

MITRE no ha publicado una calificación de probabilidad de explotación para esta debilidad. Trátala como de impacto medio hasta que tu modelo de amenazas demuestre lo contrario.

¿Qué lenguajes o plataformas se ven afectados por CWE-575?

MITRE lists the following affected platforms: Java.

¿Cómo puedo prevenir CWE-575?

Do not use AWT/Swing when writing EJBs.

¿Cómo detecta y corrige Plexicus CWE-575?

El motor SAST de Plexicus detecta la firma de flujo de datos para CWE-575 en cada commit. Cuando hay coincidencia, nuestro agente Codex Remedium abre un PR de corrección con el código corregido, las pruebas y un resumen de una línea para el revisor.

¿Dónde puedo aprender más sobre CWE-575?

MITRE publica la definición canónica en https://cwe.mitre.org/data/definitions/575.html. También puedes consultar la documentación de OWASP y NIST para guías relacionadas.

Listo cuando tú lo estés

Deja de pagar por desarrollador.
Empieza a cerrar el bucle.

Plexicus es el ASPM nativo de IA que escanea, filtra, corrige, pentestea y explica — de forma autónoma. Desarrolladores ilimitados, repos ilimitados, acciones de IA de uso justo. Nivel gratuito real, €269/mo anual cuando estés listo.