---
title: "CWE-369: Divide By Zero"
url: https://radicalnotion.ai/cwe/cwe-369
type: cwe
description: "The product divides a value by zero."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-369: Divide By Zero

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Draft
- **Likelihood of exploit:** Medium
- **CVEs with this as primary weakness:** 535
- **Of those, in CISA KEV:** 0
- **New in 2026:** 139
- **CWE catalog version:** 4.21

## Description

The product divides a value by zero.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | This weakness typically occurs when an unexpected value is provided to the product, or if an error occurs that is not properly detected. It frequently occurs in calculations involving physical dimensions such as size, length, width, and height. |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Availability | DoS: Crash, Exit, or Restart | A Divide by Zero results in a crash. |

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

### Fuzzing

Fuzz testing (fuzzing) is a powerful technique for generating large numbers of diverse inputs - either randomly or algorithmically - and dynamically invoking the code with those inputs. Even with random inputs, it is often capable of generating unexpected results such as crashes, memory corruption, or resource consumption. Fuzzing effectively produces repeatable test cases that clearly indicate bugs, which helps developers to diagnose the issues.

Effectiveness: High

## Demonstrative examples

### Example 1

The following Java example contains a function to compute an average but does not validate that the input value used as the denominator is not zero. This will create an exception for attempting to divide by zero. If this error is not handled by Java exception handling, unexpected results can occur.

Bad code:

```java
public int computeAverageResponseTime (int totalTime, int numRequests) {
    return totalTime / numRequests;
}
```

Good code:

```java
public int computeAverageResponseTime (int totalTime, int numRequests) throws ArithmeticException {
    if (numRequests == 0) {
        System.out.println("Division by zero attempted!");
        throw ArithmeticException;
    }
    return totalTime / numRequests;
}
```

By validating the input value used as the denominator the following code will ensure that a divide by zero error will not cause unexpected results. The following Java code example will validate the input value, output an error message, and throw an exception.

### Example 2

The following C/C++ example, adapted from \[REF-371\], contains a function that divides two numeric values without verifying that the input value used as the denominator is not zero. This will create an error for attempting to divide by zero, if this error is not caught by the error handling capabilities of the language, unexpected results can occur.

Bad code:

```c
double divide(double x, double y){
    return x/y;
}
```

Good code:

```c
const int DivideByZero = 10;
double divide(double x, double y){
    if ( 0 == y ){
        throw DivideByZero;
    }
    return x/y;
}
...
try{
    divide(10, 0);
}
catch( int i ){
    if(i==DivideByZero) {
        cerr<<"Divide by zero error";
    }
}
```

By validating the input value used as the denominator the following code will ensure that a divide by zero error will not cause unexpected results. If the method is called and a zero is passed as the second argument a DivideByZero error will be thrown and should be caught by the calling block with an output message indicating the error.

### Example 3

The following C# example, adapted from \[REF-372\], contains a function that divides two numeric values without verifying that the input value used as the denominator is not zero. This will create an error for attempting to divide by zero. If this error is not caught by the error handling capabilities of the language, unexpected results can occur.

Bad code:

```c#
int Division(int x, int y){
    return (x / y);
}
```

Good code:

```c#
int SafeDivision(int x, int y){
    try{
        return (x / y);
    }
    catch (System.DivideByZeroException dbz){
        System.Console.WriteLine("Division by zero attempted!");
        return 0;
    }
}
```

The method can be modified to raise, catch and handle the DivideByZeroException if the input value used as the denominator is zero.

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2007-3268 | Invalid size value leads to divide by zero. |
| CVE-2007-2723 | "Empty" content triggers divide by zero. |
| CVE-2007-2237 | Height value of 0 triggers divide by zero. |

## Real CVEs with this weakness (sample of 12 of 535)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2021-32494 | radare2: division by zero vulnerability in Mach-O parser's rebase\_buffer function | critical | 10.0 | - | No | 2023-07-07 |
| CVE-2024-57932 | gve: guard XDP xmit NDO on existence of xdp queues | critical | 9.8 | - | No | 2025-01-21 |
| CVE-2017-11720 | - | critical | 9.8 | - | No | 2017-07-28 |
| CVE-2026-46470 | - | critical | 9.1 | - | No | 2026-05-14 |
| CVE-2020-20892 | - | high | 8.8 | - | No | 2021-09-20 |
| CVE-2025-4637 | Divide By Zero in dlib | high | 8.7 | - | No | 2025-05-14 |
| CVE-2019-16228 | py-lmdb Divide by Zero interruptions | high | 8.7 | - | No | 2019-09-11 |
| CVE-2026-37232 | - | high | 8.6 | - | No | 2026-06-01 |
| CVE-2024-26945 | crypto: iaa - Fix nr\_cpus \< nr\_iaa case | high | 8.4 | - | No | 2024-05-01 |
| CVE-2026-91955 | FreeRDP before 3.31.0 Denial of Service via Desktop Dimensions | high | 8.2 | - | No | 2026-09-15 |
| CVE-2026-97578 | media: verisilicon: rockchip: guard VPU981 AV1 divisor and tile buffer | high | 7.8 | - | No | 2026-09-25 |
| CVE-2026-74449 | drm/amd/display: Fix divide-by-zero in calculate\_mcache\_setting on zero viewport | high | 7.8 | - | No | 2026-08-15 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-682](https://radicalnotion.ai/cwe/cwe-682) | Incorrect Calculation |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| OWASP Top Ten 2004 | Denial of Service | A9 | CWE More Specific |
| CERT C Secure Coding | Detect and handle floating point errors | FLP03-C | - |
| CERT C Secure Coding | Ensure that division and remainder operations do not result in divide-by-zero errors | INT33-C | Exact |
| The CERT Oracle Secure Coding Standard for Java (2011) | Ensure that division and modulo operations do not result in divide-by-zero errors | NUM02-J | - |
| Software Fault Patterns | Glitch in computation | SFP1 | - |
| PLC Top 20 | Use PLC flags as integrity checks | 4 | - |

## Frequently asked questions

### What is CWE-369?

The product divides a value by zero.

### What CVEs are caused by CWE-369?

535 recorded CVEs are attributed to CWE-369, including CVE-2021-32494, CVE-2024-57932 and CVE-2017-11720.

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

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

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

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

### Is CWE-369 actively exploited?

535 recorded CVEs are caused by CWE-369; none are currently in CISA's KEV catalog of actively exploited flaws.

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

---

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