CWE-1069: Empty Exception Block

Description

An invokable code block contains an exception handling block that does not contain any code, i.e. is empty.

Submission Date :

July 2, 2018, midnight

Modification Date :

2023-06-29 00:00:00+00:00

Organization :

MITRE
Extended Description

When an exception handling block (such as a Catch and Finally block) is used, but that block is empty, this can prevent the product from running reliably. If the relevant code is reachable by an attacker, then this reliability problem might introduce a vulnerability.

Example Vulnerable Codes

Example - 1

In the following Java example, the code catches an ArithmeticException.



c = a / b;
int a = 1;int b = 0;int c = 0;try {} catch(ArithmeticException ae) {}
public static void main(String[] args) {}
public class Main {}

Since the exception block is empty, no action is taken.

In the code below the exception has been logged and the bad execution has been handled in the desired way allowing the program to continue in an expected way.



c = a / b;

log.error("Divided by zero detected, setting to -1.");c = -1;
int a = 1;int b = 0;int c = 0;try {} catch(ArithmeticException ae) {}
public static void main(String[] args) {}
public class Main {}

Related Weaknesses

This table shows the weaknesses and high level categories that are related to this weakness. These relationships are defined to give an overview of the different insight to similar items that may exist at higher and lower levels of abstraction.

Visit http://cwe.mitre.org/ for more details.