The product dereferences a pointer that it expects to be valid but is NULL.

Resultant
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.

NPD
Common abbreviation for Null Pointer Dereference

null deref
Common abbreviation for Null Pointer Dereference

NPE
Common abbreviation for Null Pointer Exception

nil pointer dereference
used for access of nil in Go programs

Implementation

Medium

Availability
DoS: Crash, Exit, or Restart
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.

Integrity
Confidentiality
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.

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.
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.)
High

Automated Dynamic Analysis
Use tools that are integrated during
compilation to insert runtime error-checking mechanisms
related to memory safety errors, such as AddressSanitizer
(ASan) for C/C++ [REF-1518].
Moderate
Crafted inputs are necessary to
reach the code containing the error, such as generated
by fuzzers. Also, these tools may reduce performance,
and they only report the error condition - not the
original mistake that led to the
error.

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.
Moderate
Checking the return value of the function will typically be sufficient, however beware of race conditions (CWE-362) in a concurrent environment. This solution does not handle the use of improperly initialized variables (CWE-665).

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.

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.

void host_lookup(char *user_supplied_addr){
struct hostent *hp;in_addr_t *addr;char hostname[64];in_addr_t inet_addr(const char *cp);

/*routine that ensures user_supplied_addr is in the right format for conversion */

validate_addr_form(user_supplied_addr);addr = inet_addr(user_supplied_addr);hp = gethostbyaddr( addr, sizeof(struct in_addr), AF_INET);strcpy(hostname, hp->h_name);
}

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).

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.

String cmd = System.getProperty("cmd");cmd = cmd.trim();

This Android application has registered to handle a URL when sent an intent:

...
IntentFilter filter = new IntentFilter("com.example.URLHandler.openURL");MyReceiver receiver = new MyReceiver();registerReceiver(receiver, filter);
...

public class UrlHandlerReceiver extends BroadcastReceiver {
@Overridepublic void onReceive(Context context, Intent intent) {
if("com.example.URLHandler.openURL".equals(intent.getAction())) {String URL = intent.getStringExtra("URLToOpen");int length = URL.length();

...
}
}
}

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.

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.

func HandleRequest(client http.Client, request *http.Request) (*http.Response, error) {

response, err := client.Do(request)
defer response.Body.Close()
if err != nil {

return nil, err

}...
}

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.

CVE-2024-41130
C++ library for LLM inference has NULL pointer dereference if a read operation fails
https://www.cve.org/CVERecord?id=CVE-2024-41130

CVE-2005-3274
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.
https://www.cve.org/CVERecord?id=CVE-2005-3274

CVE-2002-1912
large number of packets leads to NULL dereference
https://www.cve.org/CVERecord?id=CVE-2002-1912

CVE-2005-0772
packet with invalid error status value triggers NULL dereference
https://www.cve.org/CVERecord?id=CVE-2005-0772

CVE-2009-4895
Chain: race condition for an argument value, possibly resulting in NULL dereference
https://www.cve.org/CVERecord?id=CVE-2009-4895

CVE-2020-29652
ssh component for Go allows clients to cause a denial of service (nil pointer dereference) against SSH servers.
https://www.cve.org/CVERecord?id=CVE-2020-29652

CVE-2009-2692
Chain: Use of an unimplemented network socket operation pointing to an uninitialized handler function (CWE-456) causes a crash because of a null pointer dereference (CWE-476).
https://www.cve.org/CVERecord?id=CVE-2009-2692

CVE-2009-3547
Chain: race condition (CWE-362) might allow resource to be released before operating on it, leading to NULL dereference (CWE-476)
https://www.cve.org/CVERecord?id=CVE-2009-3547

CVE-2009-3620
Chain: some unprivileged ioctls do not verify that a structure has been initialized before invocation, leading to NULL dereference
https://www.cve.org/CVERecord?id=CVE-2009-3620

CVE-2009-2698
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
https://www.cve.org/CVERecord?id=CVE-2009-2698

CVE-2009-2692
Chain: Use of an unimplemented network socket operation pointing to an uninitialized handler function (CWE-456) causes a crash because of a null pointer dereference (CWE-476)
https://www.cve.org/CVERecord?id=CVE-2009-2692

CVE-2009-0949
Chain: improper initialization of memory can lead to NULL dereference
https://www.cve.org/CVERecord?id=CVE-2009-0949

CVE-2008-3597
Chain: game server can access player data structures before initialization has happened leading to NULL dereference
https://www.cve.org/CVERecord?id=CVE-2008-3597

CVE-2020-6078
Chain: The return value of a function returning a pointer is not checked for success (CWE-252) resulting in the later use of an uninitialized variable (CWE-456) and a null pointer dereference (CWE-476)
https://www.cve.org/CVERecord?id=CVE-2020-6078

CVE-2008-0062
Chain: a message having an unknown message type may cause a reference to uninitialized memory resulting in a null pointer dereference (CWE-476) or dangling pointer (CWE-825), possibly crashing the system or causing heap corruption.
https://www.cve.org/CVERecord?id=CVE-2008-0062

CVE-2008-5183
Chain: unchecked return value can lead to NULL dereference
https://www.cve.org/CVERecord?id=CVE-2008-5183

CVE-2004-0079
SSL software allows remote attackers to cause a denial of service (crash) via a crafted SSL/TLS handshake that triggers a null dereference.
https://www.cve.org/CVERecord?id=CVE-2004-0079

CVE-2004-0365
Network monitor allows remote attackers to cause a denial of service (crash) via a malformed RADIUS packet that triggers a null dereference.
https://www.cve.org/CVERecord?id=CVE-2004-0365

CVE-2003-1013
Network monitor allows remote attackers to cause a denial of service (crash) via a malformed Q.931, which triggers a null dereference.
https://www.cve.org/CVERecord?id=CVE-2003-1013

CVE-2003-1000
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.
https://www.cve.org/CVERecord?id=CVE-2003-1000

CVE-2004-0389
Server allows remote attackers to cause a denial of service (crash) via malformed requests that trigger a null dereference.
https://www.cve.org/CVERecord?id=CVE-2004-0389

CVE-2004-0119
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.
https://www.cve.org/CVERecord?id=CVE-2004-0119

CVE-2004-0458
Game allows remote attackers to cause a denial of service (server crash) via a missing argument, which triggers a null pointer dereference.
https://www.cve.org/CVERecord?id=CVE-2004-0458

CVE-2002-0401
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.
https://www.cve.org/CVERecord?id=CVE-2002-0401

CVE-2001-1559
Chain: System call returns wrong value (CWE-393), leading to a resultant NULL dereference (CWE-476).
https://www.cve.org/CVERecord?id=CVE-2001-1559

Null Dereference

Null-pointer dereference

Null Dereference (Null Pointer Dereference)

A9
Denial of Service
CWE More Specific

EXP34-C
Do not dereference null pointers
Exact

SFP7
Faulty Pointer Use

Allowed
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.
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.

7 Pernicious Kingdoms
2006-07-19
Draft 3
2006-07-19

Eric Dalci
Cigital
2008-07-01
updated Time_of_Introduction

KDM Analytics
2008-08-01
added/updated white box definitions

CWE Content Team
MITRE
2008-09-08
updated Applicable_Platforms, Common_Consequences, Relationships, Other_Notes, Taxonomy_Mappings, Weakness_Ordinalities

CWE Content Team
MITRE
2008-11-24
updated Relationships, Taxonomy_Mappings

CWE Content Team
MITRE
2009-05-27
updated Demonstrative_Examples

CWE Content Team
MITRE
2009-10-29
updated Relationships

CWE Content Team
MITRE
2009-12-28
updated Common_Consequences, Demonstrative_Examples, Other_Notes, Potential_Mitigations, Weakness_Ordinalities

CWE Content Team
MITRE
2010-02-16
updated Potential_Mitigations, Relationships

CWE Content Team
MITRE
2010-06-21
updated Demonstrative_Examples, Description, Detection_Factors, Potential_Mitigations

CWE Content Team
MITRE
2010-09-27
updated Demonstrative_Examples, Observed_Examples, Relationships

CWE Content Team
MITRE
2010-12-13
updated Relationships

CWE Content Team
MITRE
2011-06-01
updated Common_Consequences

CWE Content Team
MITRE
2011-06-27
updated Related_Attack_Patterns, Relationships

CWE Content Team
MITRE
2011-09-13
updated Relationships, Taxonomy_Mappings

CWE Content Team
MITRE
2012-05-11
updated Observed_Examples, Related_Attack_Patterns, Relationships

CWE Content Team
MITRE
2014-02-18
updated Demonstrative_Examples

CWE Content Team
MITRE
2014-07-30
updated Relationships, Taxonomy_Mappings

CWE Content Team
MITRE
2015-12-07
updated Relationships

CWE Content Team
MITRE
2017-01-19
updated Relationships

CWE Content Team
MITRE
2017-11-08
updated Relationships, Taxonomy_Mappings, White_Box_Definitions

CWE Content Team
MITRE
2019-01-03
updated Relationships

CWE Content Team
MITRE
2019-06-20
updated Relationships

CWE Content Team
MITRE
2019-09-19
updated References, Relationships

CWE Content Team
MITRE
2020-02-24
updated References

CWE Content Team
MITRE
2020-06-25
updated Common_Consequences

CWE Content Team
MITRE
2020-08-20
updated Relationships

CWE Content Team
MITRE
2020-12-10
updated Relationships

CWE Content Team
MITRE
2021-03-15
updated Demonstrative_Examples, Observed_Examples

CWE Content Team
MITRE
2021-07-20
updated Relationships

CWE Content Team
MITRE
2022-04-28
updated Alternate_Terms

CWE Content Team
MITRE
2022-06-28
updated Relationships

CWE Content Team
MITRE
2022-10-13
updated Alternate_Terms, Applicable_Platforms, Observed_Examples

CWE Content Team
MITRE
2023-04-27
updated Demonstrative_Examples, Detection_Factors, References, Relationships

CWE Content Team
MITRE
2023-06-29
updated Mapping_Notes, Relationships

CWE Content Team
MITRE
2023-10-26
updated Observed_Examples

CWE Content Team
MITRE
2024-07-16
4.15
2024-07-16
updated Alternate_Terms, Demonstrative_Examples, Description, Diagram, Potential_Mitigations, Relationships, Weakness_Ordinalities

CWE Content Team
MITRE
2024-11-19
4.16
2024-11-19
updated Relationships

CWE Content Team
MITRE
2025-04-03
4.17
2025-04-03
updated Demonstrative_Examples, Potential_Mitigations

CWE Content Team
MITRE
2025-09-09
4.18
2025-09-09
updated Potential_Mitigations, References

CWE Content Team
MITRE
2025-12-11
4.19
2025-12-11
updated Detection_Factors, Observed_Examples, References, Relationships

Abhi Balakrishnan
2024-02-29
4.15
2024-07-16
Provided diagram to improve CWE usability