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

# CWE-577: EJB Bad Practices: Use of Sockets

- **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 sockets.

## Background

The Enterprise JavaBeans specification 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 \[REF-1543\]. In this case, the product violates the following EJB guideline: "An enterprise bean must not attempt to listen on a socket, accept connections on a socket, or use a socket for multicast." The specification justifies this requirement in the following way: "The EJB architecture allows an enterprise bean instance to be a network socket client, but it does not allow it to be a network server. Allowing the instance to become a network server would conflict with the basic function of the enterprise bean-- to serve the EJB clients."

## Modes of introduction

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

## Applicable platforms

**Languages:** Java (Undetermined)

## Common consequences

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

## Potential mitigations

### Architecture and Design, Implementation

Do not use Sockets 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 stateless Enterprise JavaBean that retrieves stock symbols and stock values. The Enterprise JavaBean creates a socket and listens for and accepts connections from clients on the socket.

Bad code:

```java
@Stateless
public class StockSymbolBean implements StockSymbolRemote {

    ServerSocket serverSocket = null;
    Socket clientSocket = null;

    public StockSymbolBean() {
        try {
            serverSocket = new ServerSocket(Constants.SOCKET_PORT);
        } catch (IOException ex) {...}

        try {
            clientSocket = serverSocket.accept();
        } catch (IOException e) {...}
    }

    public String getStockSymbol(String name) {...}

    public BigDecimal getStockValue(String symbol) {...}

    private void processClientInputFromSocket() {...}
}
```

Bad code:

```java
@Stateless
public class StockSymbolBean extends Thread implements StockSymbolRemote {

    ServerSocket serverSocket = null;
    Socket clientSocket = null;
    boolean listening = false;

    public StockSymbolBean() {
        try {
            serverSocket = new ServerSocket(Constants.SOCKET_PORT);
        } catch (IOException ex) {...}

        listening = true;
        while(listening) {
            start();
        }
    }

    public String getStockSymbol(String name) {...}

    public BigDecimal getStockValue(String symbol) {...}

    public void run() {
        try {
            clientSocket = serverSocket.accept();
        } catch (IOException e) {...}
        ...
    }
}
```

## 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-577?

The product violates the Enterprise JavaBeans (EJB) specification by using sockets.

### How do you prevent CWE-577?

Do not use Sockets when writing EJBs.

### How is CWE-577 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-577?

Exploiting CWE-577 can lead to: Quality Degradation.

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

---

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