---
title: "CWE-382: J2EE Bad Practices: Use of System.exit()"
url: https://radicalnotion.ai/cwe/cwe-382
type: cwe
description: "A J2EE application uses System.exit()."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-382: J2EE Bad Practices: Use of System.exit()

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

A J2EE application uses System.exit().

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | A call to System.exit() is probably part of leftover debug code or code imported from a non-J2EE application. |

## Applicable platforms

**Languages:** Java (Undetermined)

**Technologies:** Web Based (Undetermined), Web Server (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Availability | DoS: Crash, Exit, or Restart | Access to a function that can shut down the application is an avenue for Denial of Service (DoS) attacks, since use of System.exit() also shuts down the application's container. |

## Potential mitigations

### Architecture and Design (Separation of Privilege)

The shutdown function should be a privileged function available only to a properly authorized administrative user.

### Implementation

Web applications should not call methods that cause the virtual machine to exit, such as System.exit().

### Implementation

Web applications should not throw any Throwables to the application server, as this may adversely affect the container.

### Implementation

Non-web applications may have a main() method that contains a System.exit(), but generally should not call System.exit() from other locations in the code.

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

Effectiveness: High

## Demonstrative examples

### Example 1

Included in the doPost() method defined below is a call to System.exit() in the event of a specific exception.

Bad code:

```java
Public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    try {
        ...
    } catch (ApplicationSpecificException ase) {
        logger.error("Caught: " + ase.toString());
        System.exit(1);
    }
}
```

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-705](https://radicalnotion.ai/cwe/cwe-705) | Incorrect Control Flow Scoping |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| 7 Pernicious Kingdoms | J2EE Bad Practices: System.exit() | - | - |
| OWASP Top Ten 2004 | Denial of Service | A9 | CWE More Specific |
| The CERT Oracle Secure Coding Standard for Java (2011) | Do not allow untrusted code to terminate the JVM | ERR09-J | - |
| Software Fault Patterns | Use of an improper API | SFP3 | - |

## Frequently asked questions

### What is CWE-382?

A J2EE application uses System.exit().

### Is CWE-382 part of the OWASP Top 10?

CWE-382 maps to OWASP Top Ten 2004: Denial of Service (A9) in the OWASP security taxonomy.

### How do you prevent CWE-382?

The shutdown function should be a privileged function available only to a properly authorized administrative user.

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

Exploiting CWE-382 can lead to: DoS: Crash, Exit, or Restart.

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

---

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