CWE-575 Variante Rascunho

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.

Definição

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 no mundo real

Real-world CVEs caused by CWE-575

Ainda não há referências CVE públicas associadas a este CWE no catálogo da MITRE.

Como os atacantes a exploram

Trajeto do atacante passo a passo

  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.

Exemplo de código vulnerável

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.

Vulnerável 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) {...}
  		
  		...}
Exemplo 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 verificação de prevenção

How to prevent CWE-575

  • Architecture and Design Do not use AWT/Swing when writing EJBs.
Sinais de deteção

How to detect CWE-575

SAST High

Executar análise estática (SAST) na base de código à procura do padrão inseguro no fluxo de dados.

DAST Moderate

Executar testes dinâmicos de segurança de aplicações (DAST) contra o endpoint em execução.

Runtime Moderate

Monitorizar os registos em tempo de execução para traços de exceção invulgares, input malformado ou tentativas de contornar a autorização.

Code review Moderate

Revisão de código: sinalizar qualquer novo código que trate input desta superfície sem usar os ajudantes validados do framework.

Correção automática do Plexicus

O Plexicus deteta automaticamente o CWE-575 e abre um PR de correção em menos de 60 segundos.

O Codex Remedium analisa cada commit, identifica esta fraqueza exata e entrega um pull request pronto para revisão com o patch. Sem tickets. Sem transferências.

Perguntas frequentes

Frequently asked questions

O que é o 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.

Qual a gravidade do CWE-575?

A MITRE não publicou uma classificação de probabilidade de exploração para esta fraqueza. Trate-a como impacto médio até o seu modelo de ameaças provar o contrário.

Que linguagens ou plataformas são afetadas pelo CWE-575?

MITRE lists the following affected platforms: Java.

Como posso prevenir o CWE-575?

Do not use AWT/Swing when writing EJBs.

Como é que o Plexicus deteta e corrige o CWE-575?

O motor SAST do Plexicus correlaciona a assinatura de fluxo de dados do CWE-575 em cada commit. Quando é encontrada uma correspondência, o nosso agente Codex Remedium abre um PR de correção com o código corrigido, testes e um resumo de uma linha para o revisor.

Onde posso saber mais sobre o CWE-575?

A MITRE publica a definição canónica em https://cwe.mitre.org/data/definitions/575.html. Pode também consultar a documentação da OWASP e do NIST para orientações adjacentes.

Pronto quando você estiver

Pare de pagar por desenvolvedor.
Comece a fechar o ciclo.

O Plexicus é o ASPM nativo de IA que verifica, filtra, corrige, pentesta e explica — de forma autónoma. Programadores ilimitados, repos ilimitados, ações de IA de utilização justa. Nível gratuito real, €269/mo anual quando estiver pronto.