CWE-246 Variante Borrador

J2EE Bad Practices: Direct Use of Sockets

This vulnerability occurs when a J2EE application creates network sockets directly, bypassing the container-managed communication framework provided by the platform.

Definición

What is CWE-246?

This vulnerability occurs when a J2EE application creates network sockets directly, bypassing the container-managed communication framework provided by the platform.
The J2EE specification restricts direct socket use primarily for connecting to legacy systems when no higher-level alternative exists. When developers implement custom network protocols or even re-implement standard ones, they must solve complex security challenges—like proper authentication, encryption, and input validation—that are already handled by the platform's tested frameworks. Without deep security expertise, these custom solutions often introduce critical flaws that attackers can exploit. Managing this at scale is difficult; an ASPM like Plexicus can help you track and remediate these flaws across your entire stack. While SAST tools can flag the direct socket usage pattern, Plexicus uses AI to analyze the context and suggest the specific framework-based code fix, such as replacing raw sockets with a managed service, saving hours of manual investigation and rewrite.
Impacto en el mundo real

Real-world CVEs caused by CWE-246

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

    Identifica una ruta de código que maneje entrada no confiable sin validación.

  2. 2

    Crea un payload que ejercite el comportamiento inseguro — inyección, traversal, overflow o abuso de lógica.

  3. 3

    Envía el payload a través de una solicitud normal y observa la reacción de la aplicación.

  4. 4

    Itera hasta que la respuesta filtre datos, ejecute código del atacante o escale privilegios.

Ejemplo de código vulnerable

Vulnerable Java

The following example opens a socket to connect to a remote server.

Vulnerable Java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
```
// Perform servlet tasks.* 
  		...
  		
  		
  		 *// Open a socket to a remote server (bad).* 
  		Socket sock = null;
  		
  		try {
  		```
  				sock = new Socket(remoteHostname, 3000);
```
// Do something with the socket.* 
  				...} catch (Exception e) {
  		```
  			...
  		}
  }
Ejemplo de código seguro

Secure pseudo

Seguro pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
  const safe = validateAndEscape(input);
  return executeWithGuards(safe);
}
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-246

  • Architecture and Design Use framework method calls instead of using sockets directly.
Señales de detección

How to detect CWE-246

Automated Static Analysis High

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.)

Auto-corrección de Plexicus

Plexicus detecta automáticamente CWE-246 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-246?

This vulnerability occurs when a J2EE application creates network sockets directly, bypassing the container-managed communication framework provided by the platform.

¿Qué gravedad tiene CWE-246?

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

MITRE lists the following affected platforms: Java.

¿Cómo puedo prevenir CWE-246?

Use framework method calls instead of using sockets directly.

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

El motor SAST de Plexicus detecta la firma de flujo de datos para CWE-246 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-246?

MITRE publica la definición canónica en https://cwe.mitre.org/data/definitions/246.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.