CWE-252: Unchecked Return Value

What is CWE-252?

CWE-252 is Unchecked Return Value. The flaw arises when the product does not check the return value from a method or function. The database currently holds 50 vulnerabilities mapped to CWE-252 and none of them are in the CISA Known Exploited Vulnerabilities catalog.

OWASP TOP 10:2025 RANK10 — A10:2025 — Mishandling of Exceptional Conditions
Related CVES (365 days)50
AbstractionBase
Likelihood of exploitLow

Vulnerabilities mapped to CWE-252

50 vulnerabilities257% increase year over year

No data

No vulnerability data in CISA KEV for CWE-252

Official definition

ByMitre CWE

The product does not check the return value from a method or function.

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

Characteristics

Modes of introduction

  • Implementation: Two common programmer assumptions are "this function call can never fail" and "it doesn't matter if this function call fails". If an attacker can force the function to fail or otherwise return a value that is not expected, then the subsequent program logic could lead to a vulnerability.

Common consequences

ImpactScopeExplanation
Unexpected State, Varies by Context, DoS: Crash, Exit, or RestartAvailability, IntegrityThe product could be prevented from detecting unexpected states and conditions, placing the product into a state that could lead to a crash or other unintended behaviors.
Bypass Protection MechanismAccess ControlIf the method/function is used for a protection mechanism, then an unchecked return value could prevent the code from being able to see if the protection mechanism fails. For example, if the program calls a function to drop privileges but does not check the return code to ensure that privileges were successfully dropped, then the program will continue to operate with the higher privileges.

Risk mitigations

  1. Implementation · Effectiveness: HighCheck the results of all functions that return a value and verify that the value is expected.Checking the return value of the function will typically be sufficient, however beware of race conditions (CWE-362) in a concurrent environment.
  2. ImplementationFor any pointers that could have been modified or provided from a function that can return NULL, check the pointer for NULL before use. When working with a multithreaded or otherwise asynchronous environment, ensure that proper locking APIs are used to lock before the check, and unlock when it has finished [REF-1484].
  3. ImplementationEnsure that you account for all possible return values from the function.
  4. ImplementationWhen designing a function, make sure you return a value or throw an exception in case of an error.

Detection methods

MethodApproachEffectiveness
Automated Static AnalysisAutomated 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.)High

Representative vulnerabilities

Below are representative vulnerabilities related to this CWE, prioritized by severity.

Sources (2)

CWE™ Program, operated by The MITRE Corporation. Copyright © 2006–2026, The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. CWE Terms of Use.

Learn more

Run an in-depth assessment with complete web risk management

CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.