CWE-690: Unchecked Return Value to NULL Pointer Dereference

Compound Draft Chain

CWE版本: 4.18

更新日期: 2025-09-09

弱点描述

The product does not check for an error after calling a function that can return with a NULL pointer if the function fails, which leads to a resultant NULL pointer dereference.

扩展描述

While unchecked return value weaknesses are not limited to returns of NULL pointers (see the examples in CWE-252), functions often return NULL to indicate an error status. When this error condition is not checked, a NULL pointer dereference can occur.

常见后果

影响范围: Availability

技术影响: DoS: Crash, Exit, or Restart

影响范围: Integrity Confidentiality Availability

技术影响: Execute Unauthorized Code or Commands Read Memory Modify Memory

说明: In rare circumstances, when NULL is equivalent to the 0x0 memory address and privileged code can access it, then writing or reading memory is possible, which may lead to code execution.

检测方法

方法: Black Box

This typically occurs in rarely-triggered error conditions, reducing the chances of detection during black box testing.

方法: White Box

Code analysis can require knowledge of API behaviors for library functions that might return NULL, reducing the chances of detection when unknown libraries are used.

观察示例

参考: CVE-2008-1052

Large Content-Length value leads to NULL pointer dereference when malloc fails.

参考: CVE-2006-6227

Large message length field leads to NULL pointer dereference when malloc fails.

参考: CVE-2006-2555

Parsing routine encounters NULL dereference when input is missing a colon separator.

参考: CVE-2003-1054

URI parsing API sets argument to NULL when a parsing failure occurs, such as when the Referer header is missing a hostname, leading to NULL dereference.

参考: CVE-2008-5183

chain: unchecked return value can lead to NULL dereference

引入模式

阶段 说明
Implementation A typical occurrence of this weakness occurs when an application includes user-controlled input to a malloc() call. The related code might be correct with respect to preventing buffer overflows, but if a large value is provided, the malloc() will fail due to insufficient memory. This problem also frequently occurs when a parsing routine expects that certain elements will always be present. If malformed input is provided, the parser might return NULL. For example, strtok() can return NULL.

适用平台

编程语言
C (Undetermined) C++ (Undetermined)

分类映射

分类名称 条目ID 条目名称 映射适配度
CERT C Secure Coding EXP34-C Do not dereference null pointers CWE More Specific
The CERT Oracle Secure Coding Standard for Java (2011) ERR08-J Do not catch NullPointerException or any of its ancestors -
SEI CERT Perl Coding Standard EXP32-PL Do not ignore function return values CWE More Specific
关键信息

CWE ID: CWE-690

抽象级别: Compound

结构: Chain

状态: Draft

相关弱点