CWE-576 Variante Rascunho

EJB Bad Practices: Use of Java I/O

This vulnerability occurs when an Enterprise JavaBeans (EJB) component incorrectly uses Java I/O (java.io) operations to access the file system, violating the EJB specification's design principles.

Definição

What is CWE-576?

This vulnerability occurs when an Enterprise JavaBeans (EJB) component incorrectly uses Java I/O (java.io) operations to access the file system, violating the EJB specification's design principles.
The EJB specification explicitly prohibits the use of java.io package file system access within enterprise beans. This restriction exists because EJB components are designed as portable business logic units that should remain independent of the server's underlying file structure. Using standard file I/O ties your component to a specific server environment, breaking portability and creating inconsistent behavior across different EJB containers. Instead of file system access, EJB components should interact with data through managed resource APIs like JDBC for databases or JMS for messaging. These standardized interfaces ensure proper transaction management, security, and scalability within the container's managed environment. Following this practice maintains the component's portability and leverages the container's built-in services for reliable data handling.
Impacto no mundo real

Real-world CVEs caused by CWE-576

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 stateless Enterprise JavaBean that retrieves the interest rate for the number of points for a mortgage. In this example, the interest rates for various points are retrieved from an XML document on the local file system, and the EJB uses the Java I/O API to retrieve the XML document from the local file system.

  2. 2

    This use of the Java I/O API within any kind of Enterprise JavaBean violates the EJB specification by using the java.io package for accessing files within the local filesystem.

  3. 3

    An Enterprise JavaBean should use a resource manager API for storing and accessing data. In the following example, the private member function getInterestRateFromXMLParser uses an XML parser API to retrieve the interest rates.

Exemplo de código vulnerável

Vulnerable Java

The following Java example is a simple stateless Enterprise JavaBean that retrieves the interest rate for the number of points for a mortgage. In this example, the interest rates for various points are retrieved from an XML document on the local file system, and the EJB uses the Java I/O API to retrieve the XML document from the local file system.

Vulnerável Java
@Stateless
  public class InterestRateBean implements InterestRateRemote {
  		private Document interestRateXMLDocument = null;
  		private File interestRateFile = null;
  		public InterestRateBean() {
  				try {
```
/* get XML document from the local filesystem */* 
  						interestRateFile = new File(Constants.INTEREST_RATE_FILE);
  						
  						if (interestRateFile.exists())
  						{
  						```
  							DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  							DocumentBuilder db = dbf.newDocumentBuilder();
  							interestRateXMLDocument = db.parse(interestRateFile);
  						}
  				} catch (IOException ex) {...}
  		}
  		public BigDecimal getInterestRate(Integer points) {
  			return getInterestRateFromXML(points);
  		}
```
/* member function to retrieve interest rate from XML document on the local file system */* 
  		
  		private BigDecimal getInterestRateFromXML(Integer points) {...}}
Exemplo de código seguro

Secure Java

An Enterprise JavaBean should use a resource manager API for storing and accessing data. In the following example, the private member function getInterestRateFromXMLParser uses an XML parser API to retrieve the interest rates.

Seguro Java
@Stateless
  public class InterestRateBean implements InterestRateRemote {
  		public InterestRateBean() {
  		}
  		public BigDecimal getInterestRate(Integer points) {
  			return getInterestRateFromXMLParser(points);
  		}
```
/* member function to retrieve interest rate from XML document using an XML parser API */* 
  		
  		private BigDecimal getInterestRateFromXMLParser(Integer points) {...}}
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-576

  • Implementation Do not use Java I/O when writing EJBs.
Sinais de deteção

How to detect CWE-576

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.

CWE-576

Don't catalog this weakness. Prove it's reachable.

Plexicus turns CWE catalogs into evidence: every CWE-pattern is matched against your real code graph, reach is proven on a sandbox clone, and verified findings ship as reviewed PRs.

Perguntas frequentes

Frequently asked questions

O que é o CWE-576?

This vulnerability occurs when an Enterprise JavaBeans (EJB) component incorrectly uses Java I/O (java.io) operations to access the file system, violating the EJB specification's design principles.

Qual a gravidade do CWE-576?

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

MITRE lists the following affected platforms: Java.

Como posso prevenir o CWE-576?

Do not use Java I/O when writing EJBs.

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

O motor SAST do Plexicus correlaciona a assinatura de fluxo de dados do CWE-576 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-576?

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

Pronto para validar o que importa?

Pronto para validar o que importa.

O Plexicus é Proof-Driven AppSec: achados validados, compreensão contextual e remediação revisada — ancorada em evidência, escopada com você.

Qualificação

Verifique se o AI Swarm Pentest se adequa ao seu ambiente.

Partilhe o contexto mínimo. Vamos rever o escopo e indicar o próximo passo comercial.

Antes de enviar — verifique se se encaixa

0 / 280

Sem compromisso. Se não se encaixa, dizemos.

SAMPLE HANDOVER · ILLUSTRATIVE

Sample evidence handover

A trimmed view of what your team receives at the end of an AI Swarm Pentest engagement. Real engagements include full technical evidence, executive narrative, and a remediation plan.

VALIDATED FINDING Evidence attached

Server-Side Request Forgery in webhooks/receiver

demo-project/sample-app · src/webhooks/receiver.py:42

SeverityHigh CVSS 3.18.6 Priority79 Confirmedvia replay

Untrusted caller-supplied URLs reach an internal egress without an allowlist. Replayed in a sandbox against a fresh authorized target — the same control was validated to fail twice.

REVIEWER-READY REMEDIATION Merge-ready PR

Validate the target URL against an allowlist of permitted hostnames. Reject private/internal IP ranges. Enforce HTTPS only.

plexicus/remediation/webhooks-ssrf 3 changed · 0 new files
42resp = requests.get(target_url)
42+if not is_allowed_host(target_url):
43+  raise WebhookRejected(target_url)
44+resp = requests.get(target_url, timeout=5)
Every engagement hands over:
  • Executive briefing
  • Validated findings list
  • Merge-ready PRs
  • Compliance mapping (NIS2 · DORA · CRA)
Ronda privada Para investidores