---
title: "CWE-253: Incorrect Check of Function Return Value"
url: https://radicalnotion.ai/cwe/cwe-253
type: cwe
description: "The product incorrectly checks a return value from a function, which prevents it from detecting errors or exceptional conditions."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-253: Incorrect Check of Function Return Value

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Incomplete
- **Likelihood of exploit:** Low
- **CVEs with this as primary weakness:** 63
- **Of those, in CISA KEV:** 0
- **New in 2026:** 31
- **CWE catalog version:** 4.21

## Description

The product incorrectly checks a return value from a function, which prevents it from detecting errors or exceptional conditions.

## Background

Important and common functions will return some value about the success of its actions. This will alert the program whether or not to handle any errors caused by that function.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Availability, Integrity | Unexpected State, DoS: Crash, Exit, or Restart | An unexpected return value could place the system in a state that could lead to a crash or other unintended behaviors. |

## Potential mitigations

### Architecture and Design (Language Selection)

Use a language or compiler that uses exceptions and requires the catching of those exceptions.

### Implementation

Properly check all functions which return a value.

### Implementation

When designing any function make sure you return a value or throw an exception in case of an error.

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

This code attempts to allocate memory for 4 integers and checks if the allocation succeeds.

Bad code:

```c
tmp = malloc(sizeof(int) * 4);
if (tmp < 0 ) {
    perror("Failure");
    //should have checked if the call returned 0
}
```

The code assumes that only a negative return value would indicate an error, but malloc() may return a null pointer when there is an error. The value of tmp could then be equal to 0, and the error would be missed.

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2023-49286 | Chain: function in web caching proxy does not correctly check a return value (CWE-253) leading to a reachable assertion (CWE-617) |

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2023-52040 | - | critical | 9.8 | - | No | 2024-01-24 |
| CVE-2017-7474 | keycloak-connect and keycloak-js improperly handle invalid tokens | critical | 9.8 | - | No | 2017-05-12 |
| CVE-2022-48829 | NFSD: Fix NFSv3 SETATTR/CREATE's handling of large file sizes | critical | 9.1 | - | No | 2024-07-16 |
| CVE-2026-89957 | s390/vfio-ap: Fix hot-unplug skipped when last AP adapter or domain removed | high | 8.8 | - | No | 2026-09-16 |
| CVE-2026-64153 | drm/msm: Fix iommu\_map\_sgtable() return value check and avoid WARN | high | 8.8 | - | No | 2026-07-19 |
| CVE-2026-35091 | Corosync: corosync: denial of service and information disclosure via crafted udp packet | high | 8.2 | - | No | 2026-04-01 |
| CVE-2026-46010 | rxrpc: Fix error handling in rxgk\_extract\_token() | high | 8.1 | - | No | 2026-05-27 |
| CVE-2026-98002 | iommu/amd: Fix ineffective error check in nested domain allocation | high | 7.8 | - | No | 2026-09-25 |
| CVE-2026-90388 | iommu/dma: Check atomic pool allocation result directly | high | 7.8 | - | No | 2026-09-17 |
| CVE-2026-53174 | ovl: keep err zero after successful ovl\_cache\_get() | high | 7.8 | - | No | 2026-06-25 |
| CVE-2026-53090 | bpf: Fix ld\_{abs,ind} failure path analysis in subprogs | high | 7.8 | - | No | 2026-06-24 |
| CVE-2026-0648 | - | high | 7.8 | - | No | 2026-01-27 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-573](https://radicalnotion.ai/cwe/cwe-573) | Improper Following of Specification by Caller |
| Parent | [CWE-754](https://radicalnotion.ai/cwe/cwe-754) | Improper Check for Unusual or Exceptional Conditions |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CLASP | Misinterpreted function return value | - | - |
| Software Fault Patterns | Unchecked Status Condition | SFP4 | - |
| CERT C Secure Coding | Detect and handle standard library errors | ERR33-C | Imprecise |
| CERT C Secure Coding | Detect and handle POSIX library errors | POS54-C | Imprecise |

## Frequently asked questions

### What is CWE-253?

The product incorrectly checks a return value from a function, which prevents it from detecting errors or exceptional conditions.

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

63 recorded CVEs are attributed to CWE-253, including CVE-2023-52040, CVE-2017-7474 and CVE-2022-48829.

### How do you prevent CWE-253?

Use a language or compiler that uses exceptions and requires the catching of those exceptions.

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

Exploiting CWE-253 can lead to: Unexpected State, DoS: Crash, Exit, or Restart.

### Is CWE-253 actively exploited?

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

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

---

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