---
title: "CWE-575: EJB Bad Practices: Use of AWT Swing"
url: https://radicalnotion.ai/cwe/cwe-575
type: cwe
description: "The product violates the Enterprise JavaBeans (EJB) specification by using AWT/Swing."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-575: EJB Bad Practices: Use of AWT Swing

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Draft
- **CVEs with this as primary weakness:** 0
- **Of those, in CISA KEV:** 0
- **New in 2026:** 0
- **CWE catalog version:** 4.21

## Description

The product violates the Enterprise JavaBeans (EJB) specification by using AWT/Swing.

The Enterprise JavaBeans specification \[REF-1543\] 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 AWT functionality to attempt to output information to a display, or to input information from a keyboard." The specification justifies this requirement in the following way: "Most servers do not allow direct interaction between an application program and a keyboard/display attached to the server system."

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Applicable platforms

**Languages:** Java (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Other | Quality Degradation | - |

## Potential mitigations

### Architecture and Design

Do not use AWT/Swing when writing EJBs.

## Detection methods

### Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

## Demonstrative examples

### Example 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.

Bad code:

```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) {...}

    ...
}
```

Good code:

```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);
    }
}
```

Good code:

```jsp
<%@ page import="converter.ejb.Converter, java.math.*, javax.naming.*"%>
<%!
    private Converter converter = null;
    public void jspInit() {
        try {
            InitialContext ic = new InitialContext();
            converter = (Converter) ic.lookup(Converter.class.getName());
        } catch (Exception ex) {
            System.out.println("Couldn't create converter bean."+ ex.getMessage());
        }
    }
    public void jspDestroy() {
        converter = null;
    }

%>
<html>
    <head><title>Converter</title></head>
    <body bgcolor="white">
        <h1>Converter</h1>
        <hr>
        <p>Enter an amount to convert:</p>
        <form method="get">
            <input type="text" name="amount" size="25"><br>
            <p>
            <input type="submit" value="Submit">
            <input type="reset" value="Reset">
        </form>
        <%
            String amount = request.getParameter("amount");
            if ( amount != null && amount.length() > 0 ) {
                BigDecimal d = new BigDecimal(amount);
                BigDecimal yenAmount = converter.dollarToYen(d);

        %>
        <p>
        <%= amount %> dollars are <%= yenAmount %> Yen.
        <p>
        <%
            }

        %>
    </body>
</html>
```

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-695](https://radicalnotion.ai/cwe/cwe-695) | Use of Low-Level Functionality |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| Software Fault Patterns | Use of an improper API | SFP3 | - |

## Frequently asked questions

### What is CWE-575?

The product violates the Enterprise JavaBeans (EJB) specification by using AWT/Swing.

### How do you prevent CWE-575?

Do not use AWT/Swing when writing EJBs.

### How is CWE-575 detected?

Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

### What are the consequences of CWE-575?

Exploiting CWE-575 can lead to: Quality Degradation.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/575.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-575). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
