Description
The product incorrectly checks a return value from a function, which prevents it from detecting errors or exceptional conditions.
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.
Potential Impact
Availability, Integrity
Unexpected State, DoS: Crash, Exit, or Restart
Demonstrative Examples
tmp = malloc(sizeof(int) * 4);if (tmp < 0 ) {
perror("Failure");
//should have checked if the call returned 0
}Mitigations & Prevention
Use a language or compiler that uses exceptions and requires the catching of those exceptions.
Properly check all functions which return a value.
When designing any function make sure you return a value or throw an exception in case of an error.
Detection Methods
- Automated Static Analysis High — 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 sea
Real-World CVE Examples
| CVE ID | 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) |
Related Weaknesses
Taxonomy Mappings
- CLASP: — Misinterpreted function return value
- Software Fault Patterns: SFP4 — Unchecked Status Condition
- CERT C Secure Coding: ERR33-C — Detect and handle standard library errors
- CERT C Secure Coding: POS54-C — Detect and handle POSIX library errors
Frequently Asked Questions
What is CWE-253?
CWE-253 (Incorrect Check of Function Return Value) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The product incorrectly checks a return value from a function, which prevents it from detecting errors or exceptional conditions.
How can CWE-253 be exploited?
Attackers can exploit CWE-253 (Incorrect Check of Function Return Value) to unexpected state, dos: crash, exit, or restart. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-253?
Key mitigations include: Use a language or compiler that uses exceptions and requires the catching of those exceptions.
What is the severity of CWE-253?
CWE-253 is classified as a Base-level weakness (Medium abstraction). It has been observed in 1 real-world CVEs.