| Impact | Details |
|---|---|
|
DoS: Crash, Exit, or Restart |
Scope: Availability
NULL pointer dereferences usually result in the failure of the process unless exception handling (on some platforms) is available and implemented. Even when exception handling is being used, it can still be very difficult to return the software to a safe state of operation.
|
|
Execute Unauthorized Code or Commands; Read Memory; Modify Memory |
Scope: Integrity, Confidentiality
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.
|
| Phase(s) | Mitigation |
|---|---|
|
Implementation |
For 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].
|
|
Requirements |
Select a programming language that is not susceptible to these issues.
|
|
Implementation |
Check the results of all functions that return a value and verify that the value is non-null before acting upon it.
Effectiveness: Moderate |
|
Architecture and Design |
Identify all variables and data stores that receive information from external sources, and apply input validation to make sure that they are only initialized to expected values.
|
|
Implementation |
Explicitly initialize all variables and other data stores, either during declaration or just before the first usage.
|
| Nature | Type | ID | Name |
|---|---|---|---|
| ChildOf | Pillar Pillar - a weakness that is the most abstract type of weakness and represents a theme for all class/base/variant weaknesses related to it. A Pillar is different from a Category as a Pillar is still technically a type of weakness that describes a mistake, while a Category represents a common characteristic used to group related things. | 710 | Improper Adherence to Coding Standards |
| ChildOf | Class Class - a weakness that is described in a very abstract fashion, typically independent of any specific language or technology. More specific than a Pillar Weakness, but more general than a Base Weakness. Class level weaknesses typically describe issues in terms of 1 or 2 of the following dimensions: behavior, property, and resource. | 754 | Improper Check for Unusual or Exceptional Conditions |
| CanFollow | 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 |
| CanFollow | Class Class - a weakness that is described in a very abstract fashion, typically independent of any specific language or technology. More specific than a Pillar Weakness, but more general than a Base Weakness. Class level weaknesses typically describe issues in terms of 1 or 2 of the following dimensions: behavior, property, and resource. | 362 | Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition') |
| CanFollow | Variant Variant - a weakness that is linked to a certain type of product, typically involving a specific language or technology. More specific than a Base weakness. Variant level weaknesses typically describe issues in terms of 3 to 5 of the following dimensions: behavior, property, technology, language, and resource. | 789 | Memory Allocation with Excessive Size Value |
| CanFollow | 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. | 1325 | Improperly Controlled Sequential Memory Allocation |
| Nature | Type | ID | Name |
|---|---|---|---|
| MemberOf | Category Category - a CWE entry that contains a set of other entries that share a common characteristic. | 465 | Pointer Issues |
| Nature | Type | ID | Name |
|---|---|---|---|
| ChildOf | Class Class - a weakness that is described in a very abstract fashion, typically independent of any specific language or technology. More specific than a Pillar Weakness, but more general than a Base Weakness. Class level weaknesses typically describe issues in terms of 1 or 2 of the following dimensions: behavior, property, and resource. | 754 | Improper Check for Unusual or Exceptional Conditions |
| Phase | Note |
|---|---|
| Implementation |
C (Undetermined Prevalence)
C++ (Undetermined Prevalence)
Java (Undetermined Prevalence)
C# (Undetermined Prevalence)
Go (Undetermined Prevalence)
Example 1
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).
Example 2
In the following code, the programmer assumes that the system always has a property named "cmd" defined. If an attacker can control the program's environment so that "cmd" is not defined, the program throws a NULL pointer exception when it attempts to call the trim() method.
Example 3
This Android application has registered to handle a URL when sent an intent:
The application assumes the URL will always be included in the intent. When the URL is not present, the call to getStringExtra() will return null, thus causing a null pointer exception when length() is called.
Example 4
Consider the following example of a typical client server exchange. The HandleRequest function is intended to perform a request and use a defer to close the connection whenever the function returns.
If a user supplies a malformed request or violates the client policy, the Do method can return a nil response and a non-nil err.
This HandleRequest Function evaluates the close before checking the error. A deferred call's arguments are evaluated immediately, so the defer statement panics due to a nil response.
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 |
|---|---|
|
race condition causes a table to be corrupted if a timer activates while it is being modified, leading to resultant NULL dereference; also involves locking.
|
|
|
large number of packets leads to NULL dereference
|
|
|
packet with invalid error status value triggers NULL dereference
|
|
|
Chain: race condition for an argument value, possibly resulting in NULL dereference
|
|
|
ssh component for Go allows clients to cause a denial of service (nil pointer dereference) against SSH servers.
|
|
|
Chain: some unprivileged ioctls do not verify that a structure has been initialized before invocation, leading to NULL dereference
|
|
|
Chain: IP and UDP layers each track the same value with different mechanisms that can get out of sync, possibly resulting in a NULL dereference
|
|
|
Chain: uninitialized function pointers can be dereferenced allowing code execution
|
|
|
Chain: improper initialization of memory can lead to NULL dereference
|
|
|
Chain: game server can access player data structures before initialization has happened leading to NULL dereference
|
|
|
Chain: unchecked return value can lead to NULL dereference
|
|
|
SSL software allows remote attackers to cause a denial of service (crash) via a crafted SSL/TLS handshake that triggers a null dereference.
|
|
|
Network monitor allows remote attackers to cause a denial of service (crash) via a malformed RADIUS packet that triggers a null dereference.
|
|
|
Network monitor allows remote attackers to cause a denial of service (crash) via a malformed Q.931, which triggers a null dereference.
|
|
|
Chat client allows remote attackers to cause a denial of service (crash) via a passive DCC request with an invalid ID number, which causes a null dereference.
|
|
|
Server allows remote attackers to cause a denial of service (crash) via malformed requests that trigger a null dereference.
|
|
|
OS allows remote attackers to cause a denial of service (crash from null dereference) or execute arbitrary code via a crafted request during authentication protocol selection.
|
|
|
Game allows remote attackers to cause a denial of service (server crash) via a missing argument, which triggers a null pointer dereference.
|
|
|
Network monitor allows remote attackers to cause a denial of service (crash) or execute arbitrary code via malformed packets that cause a NULL pointer dereference.
|
|
| Ordinality | Description |
|---|---|
|
Resultant
|
(where the weakness is typically related to the presence of some other weaknesses)
NULL pointer dereferences are frequently resultant from rarely encountered error conditions and race conditions, since these are most likely to escape detection during the testing phases.
|
| Method | Details |
|---|---|
|
Automated Dynamic Analysis |
This weakness can be detected using dynamic tools and techniques that interact with the software using large test suites with many diverse inputs, such as fuzz testing (fuzzing), robustness testing, and fault injection. The software's operation may slow down, but it should not become unstable, crash, or generate incorrect results.
Effectiveness: Moderate |
|
Manual Dynamic Analysis |
Identify error conditions that are not likely to occur during normal usage and trigger them. For example, run the program under low memory conditions, run with insufficient privileges or permissions, interrupt a transaction before it is completed, or disable connectivity to basic network services such as DNS. Monitor the software for any unexpected behavior. If you trigger an unhandled exception or similar error that was discovered and handled by the application's environment, it may still indicate unexpected conditions that were not handled by the application itself.
|
|
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 |
| Nature | Type | ID | Name |
|---|---|---|---|
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 398 | 7PK - Code Quality |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 730 | OWASP Top Ten 2004 Category A9 - Denial of Service |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 737 | CERT C Secure Coding Standard (2008) Chapter 4 - Expressions (EXP) |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 742 | CERT C Secure Coding Standard (2008) Chapter 9 - Memory Management (MEM) |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 808 | 2010 Top 25 - Weaknesses On the Cusp |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 867 | 2011 Top 25 - Weaknesses On the Cusp |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 871 | CERT C++ Secure Coding Section 03 - Expressions (EXP) |
| 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 | ViewView - a subset of CWE entries that provides a way of examining CWE content. The two main view structures are Slices (flat lists) and Graphs (containing relationships between entries). | 884 | CWE Cross-section |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 971 | SFP Secondary Cluster: Faulty Pointer Use |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 1136 | SEI CERT Oracle Secure Coding Standard for Java - Guidelines 02. Expressions (EXP) |
| 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 | ViewView - a subset of CWE entries that provides a way of examining CWE content. The two main view structures are Slices (flat lists) and Graphs (containing relationships between entries). | 1200 | Weaknesses in the 2019 CWE Top 25 Most Dangerous Software Errors |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 1306 | CISQ Quality Measures - Reliability |
| MemberOf | ViewView - a subset of CWE entries that provides a way of examining CWE content. The two main view structures are Slices (flat lists) and Graphs (containing relationships between entries). | 1337 | Weaknesses in the 2021 CWE Top 25 Most Dangerous Software Weaknesses |
| MemberOf | ViewView - a subset of CWE entries that provides a way of examining CWE content. The two main view structures are Slices (flat lists) and Graphs (containing relationships between entries). | 1350 | Weaknesses in the 2020 CWE Top 25 Most Dangerous Software Weaknesses |
| MemberOf | ViewView - a subset of CWE entries that provides a way of examining CWE content. The two main view structures are Slices (flat lists) and Graphs (containing relationships between entries). | 1387 | Weaknesses in the 2022 CWE Top 25 Most Dangerous Software Weaknesses |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 1412 | Comprehensive Categorization: Poor Coding Practices |
| MemberOf | ViewView - a subset of CWE entries that provides a way of examining CWE content. The two main view structures are Slices (flat lists) and Graphs (containing relationships between entries). | 1425 | Weaknesses in the 2023 CWE Top 25 Most Dangerous Software Weaknesses |
| MemberOf | ViewView - a subset of CWE entries that provides a way of examining CWE content. The two main view structures are Slices (flat lists) and Graphs (containing relationships between entries). | 1430 | Weaknesses in the 2024 CWE Top 25 Most Dangerous Software Weaknesses |
Rationale
This CWE entry is at the Base level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.Comments
Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.| Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
|---|---|---|---|
| 7 Pernicious Kingdoms | Null Dereference | ||
| CLASP | Null-pointer dereference | ||
| PLOVER | Null Dereference (Null Pointer Dereference) | ||
| OWASP Top Ten 2004 | A9 | CWE More Specific | Denial of Service |
| CERT C Secure Coding | EXP34-C | Exact | Do not dereference null pointers |
| Software Fault Patterns | SFP7 | Faulty Pointer Use |
| Submissions | ||
|---|---|---|
| Submission Date | Submitter | Organization |
|
2006年07月19日
(CWE Draft 3, 2006年07月19日) |
7 Pernicious Kingdoms | |
| Contributions | ||
| Contribution Date | Contributor | Organization |
|
2024年02月29日
(CWE 4.15, 2024年07月16日) |
Abhi Balakrishnan | |
| Provided diagram to improve CWE usability | ||
| Modifications | ||
| Modification Date | Modifier | Organization |
|
2025年09月09日
(CWE 4.18, 2025年09月09日) |
CWE Content Team | MITRE |
| updated Potential_Mitigations, References | ||
|
2025年04月03日
(CWE 4.17, 2025年04月03日) |
CWE Content Team | MITRE |
| updated Demonstrative_Examples, Potential_Mitigations | ||
|
2024年11月19日
(CWE 4.16, 2024年11月19日) |
CWE Content Team | MITRE |
| updated Relationships | ||
|
2024年07月16日
(CWE 4.15, 2024年07月16日) |
CWE Content Team | MITRE |
| updated Alternate_Terms, Demonstrative_Examples, Description, Diagram, Potential_Mitigations, Relationships, Weakness_Ordinalities | ||
| 2023年10月26日 | CWE Content Team | MITRE |
| updated Observed_Examples | ||
| 2023年06月29日 | CWE Content Team | MITRE |
| updated Mapping_Notes, Relationships | ||
| 2023年04月27日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, Detection_Factors, References, Relationships | ||
| 2022年10月13日 | CWE Content Team | MITRE |
| updated Alternate_Terms, Applicable_Platforms, Observed_Examples | ||
| 2022年06月28日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2022年04月28日 | CWE Content Team | MITRE |
| updated Alternate_Terms | ||
| 2021年07月20日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2021年03月15日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, Observed_Examples | ||
| 2020年12月10日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2020年08月20日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2020年06月25日 | CWE Content Team | MITRE |
| updated Common_Consequences | ||
| 2020年02月24日 | CWE Content Team | MITRE |
| updated References | ||
| 2019年09月19日 | CWE Content Team | MITRE |
| updated References, Relationships | ||
| 2019年06月20日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2019年01月03日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2017年11月08日 | CWE Content Team | MITRE |
| updated Relationships, Taxonomy_Mappings, White_Box_Definitions | ||
| 2017年01月19日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2015年12月07日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2014年07月30日 | CWE Content Team | MITRE |
| updated Relationships, Taxonomy_Mappings | ||
| 2014年02月18日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples | ||
| 2012年05月11日 | CWE Content Team | MITRE |
| updated Observed_Examples, Related_Attack_Patterns, Relationships | ||
| 2011年09月13日 | CWE Content Team | MITRE |
| updated Relationships, Taxonomy_Mappings | ||
| 2011年06月27日 | CWE Content Team | MITRE |
| updated Related_Attack_Patterns, Relationships | ||
| 2011年06月01日 | CWE Content Team | MITRE |
| updated Common_Consequences | ||
| 2010年12月13日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2010年09月27日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, Observed_Examples, Relationships | ||
| 2010年06月21日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, Description, Detection_Factors, Potential_Mitigations | ||
| 2010年02月16日 | CWE Content Team | MITRE |
| updated Potential_Mitigations, Relationships | ||
| 2009年12月28日 | CWE Content Team | MITRE |
| updated Common_Consequences, Demonstrative_Examples, Other_Notes, Potential_Mitigations, Weakness_Ordinalities | ||
| 2009年10月29日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2009年05月27日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples | ||
| 2008年11月24日 | CWE Content Team | MITRE |
| updated Relationships, Taxonomy_Mappings | ||
| 2008年09月08日 | CWE Content Team | MITRE |
| updated Applicable_Platforms, Common_Consequences, Relationships, Other_Notes, Taxonomy_Mappings, Weakness_Ordinalities | ||
| 2008年08月01日 | KDM Analytics | |
| added/updated white box definitions | ||
| 2008年07月01日 | Eric Dalci | Cigital |
| updated Time_of_Introduction | ||
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.