| Impact | Details |
|---|---|
|
DoS: Crash, Exit, or Restart |
Scope: Availability |
|
Execute Unauthorized Code or Commands; Read Memory; Modify Memory |
Scope: Integrity, Confidentiality, Availability
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.
|
| Nature | Type | ID | Name |
|---|---|---|---|
| StartsWith | BaseBase - a weakness that is still mostly independent of a resource or technology, but with sufficient details to provide specific methods for detection and prevention. Base level weaknesses typically describe issues in terms of 2 or 3 of the following dimensions: behavior, property, technology, language, and resource. | 252 | Unchecked Return Value |
| FollowedBy | BaseBase - a weakness that is still mostly independent of a resource or technology, but with sufficient details to provide specific methods for detection and prevention. Base level weaknesses typically describe issues in terms of 2 or 3 of the following dimensions: behavior, property, technology, language, and resource. | 476 | NULL Pointer Dereference |
| Nature | Type | ID | Name |
|---|---|---|---|
| ChildOf | Base Base - a weakness that is still mostly independent of a resource or technology, but with sufficient details to provide specific methods for detection and prevention. Base level weaknesses typically describe issues in terms of 2 or 3 of the following dimensions: behavior, property, technology, language, and resource. | 252 | Unchecked Return Value |
| Phase | Note |
|---|---|
| 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 Prevalence)
C++ (Undetermined Prevalence)
Example 1
The code below makes a call to the getUserName() function but doesn't check the return value before dereferencing (which may cause a NullPointerException).
Example 2
This example takes an IP address from a user, verifies that it is well formed and then looks up the hostname and copies it into a buffer.
If an attacker provides an address that appears to be well-formed, but the address does not resolve to a hostname, then the call to gethostbyaddr() will return NULL. Since the code does not check the return value from gethostbyaddr (CWE-252), a NULL pointer dereference (CWE-476) would then occur in the call to strcpy().
Note that this code is also vulnerable to a buffer overflow (CWE-119).
Note: this is a curated list of examples for users to understand the variety of ways in which this weakness can be introduced. It is not a complete list of all CVEs that are related to this CWE entry.
| Reference | Description |
|---|---|
|
Large Content-Length value leads to NULL pointer dereference when malloc fails.
|
|
|
Large message length field leads to NULL pointer dereference when malloc fails.
|
|
|
Parsing routine encounters NULL dereference when input is missing a colon separator.
|
|
|
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.
|
|
|
chain: unchecked return value can lead to NULL dereference
|
| Method | Details |
|---|---|
|
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.
|
| Nature | Type | ID | Name |
|---|---|---|---|
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 851 | The CERT Oracle Secure Coding Standard for Java (2011) Chapter 8 - Exceptional Behavior (ERR) |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 876 | CERT C++ Secure Coding Section 08 - Memory Management (MEM) |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 1157 | SEI CERT C Coding Standard - Guidelines 03. Expressions (EXP) |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 1181 | SEI CERT Perl Coding Standard - Guidelines 03. Expressions (EXP) |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 1399 | Comprehensive Categorization: Memory Safety |
Rationale
This CWE entry is a named chain, which combines multiple weaknesses.Comments
Mapping to each separate weakness in the chain would be more precise.| Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
|---|---|---|---|
| CERT C Secure Coding | EXP34-C | CWE More Specific | Do not dereference null pointers |
| 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 | CWE More Specific | Do not ignore function return values |
| Submissions | ||
|---|---|---|
| Submission Date | Submitter | Organization |
|
2008年04月11日
(CWE Draft 9, 2008年04月11日) |
CWE Content Team | MITRE |
| Modifications | ||
| Modification Date | Modifier | Organization |
| 2023年06月29日 | CWE Content Team | MITRE |
| updated Mapping_Notes, Relationships | ||
| 2023年04月27日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2021年03月15日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, Relationships | ||
| 2020年06月25日 | CWE Content Team | MITRE |
| updated Common_Consequences | ||
| 2019年01月03日 | CWE Content Team | MITRE |
| updated Relationships, Taxonomy_Mappings | ||
| 2017年11月08日 | CWE Content Team | MITRE |
| updated Relationships, Relevant_Properties, Taxonomy_Mappings, Time_of_Introduction | ||
| 2017年01月19日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2014年06月23日 | CWE Content Team | MITRE |
| updated Modes_of_Introduction, Other_Notes | ||
| 2011年09月13日 | CWE Content Team | MITRE |
| updated Relationships, Taxonomy_Mappings | ||
| 2011年06月01日 | CWE Content Team | MITRE |
| updated Common_Consequences, Relationships, Taxonomy_Mappings | ||
| 2010年09月27日 | CWE Content Team | MITRE |
| updated Observed_Examples | ||
| 2009年12月28日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples | ||
| 2008年09月08日 | CWE Content Team | MITRE |
| updated Applicable_Platforms, Description, Detection_Factors, Relationships, Other_Notes | ||
| 2008年07月01日 | Eric Dalci | Cigital |
| updated Time_of_Introduction | ||
| 2008年07月01日 | Sean Eidemiller | Cigital |
| added/updated demonstrative examples | ||
Use of the Common Weakness Enumeration (CWE™) and the associated references from this website are subject to the Terms of Use. CWE is sponsored by the U.S. Department of Homeland Security (DHS) Cybersecurity and Infrastructure Security Agency (CISA) and managed by the Homeland Security Systems Engineering and Development Institute (HSSEDI) which is operated by The MITRE Corporation (MITRE). Copyright © 2006–2025, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation.