---
title: "CWE-476: NULL Pointer Dereference"
url: https://radicalnotion.ai/cwe/cwe-476
type: cwe
description: "The product dereferences a pointer that it expects to be valid but is NULL."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-476: NULL Pointer Dereference

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Stable
- **Likelihood of exploit:** Medium
- **CVEs with this as primary weakness:** 6,579
- **Of those, in CISA KEV:** 1
- **New in 2026:** 1,771
- **CWE catalog version:** 4.21

## Description

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

## Alternate terms

- **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

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Applicable platforms

**Languages:** C (Undetermined), C++ (Undetermined), Java (Undetermined), C# (Undetermined), Go (Undetermined), Python (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| 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. |

## Potential mitigations

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

## Detection methods

### 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

### 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\].

Effectiveness: 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.

## Demonstrative examples

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

Bad code:

```c
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);
}
```

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

Bad code:

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

### Example 3

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

Bad code:

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

public class UrlHandlerReceiver extends BroadcastReceiver {
    @Override
    public 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.

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

Bad code:

```go
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
    }
    ...
}
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2024-41130 | C++ library for LLM inference has NULL pointer dereference if a read operation fails |
| 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. |
| CVE-2002-1912 | large number of packets leads to NULL dereference |
| CVE-2005-0772 | packet with invalid error status value triggers NULL dereference |
| CVE-2009-4895 | Chain: race condition for an argument value, possibly resulting in NULL dereference |
| CVE-2020-29652 | ssh component for Go allows clients to cause a denial of service (nil pointer dereference) against SSH servers. |
| 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). |
| CVE-2009-3547 | Chain: race condition (CWE-362) might allow resource to be released before operating on it, leading to NULL dereference (CWE-476) |
| CVE-2009-3620 | Chain: some unprivileged ioctls do not verify that a structure has been initialized before invocation, leading to NULL dereference |
| 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 |
| CVE-2009-0949 | Chain: improper initialization of memory can lead to NULL dereference |
| CVE-2008-3597 | Chain: game server can access player data structures before initialization has happened leading to NULL dereference |
| 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) |
| 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. |
| CVE-2008-5183 | Chain: unchecked return value can lead to NULL dereference |
| 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. |
| 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. |
| 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. |
| 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. |
| CVE-2004-0389 | Server allows remote attackers to cause a denial of service (crash) via malformed requests that trigger a null dereference. |
| 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. |
| 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. |
| 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. |
| CVE-2001-1559 | Chain: System call returns wrong value (CWE-393), leading to a resultant NULL dereference (CWE-476). |

## Real CVEs with this weakness (sample of 12 of 6,579)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-21525 | Windows Remote Access Connection Manager Denial of Service Vulnerability | medium | 6.9 | - | Yes | 2026-02-10 |
| CVE-2026-23125 | sctp: move SCTP\_CMD\_ASSOC\_SHKEY right after SCTP\_CMD\_PEER\_INIT | critical | 10.0 | - | No | 2026-02-14 |
| CVE-2022-36648 | QEMU: rocker: NULL pointer dereference in of\_dpa\_cmd\_add\_l2\_flood() | critical | 10.0 | - | No | 2023-08-22 |
| CVE-2010-2495 | kernel: l2tp: Fix oops in pppol2tp\_xmit | critical | 10.0 | - | No | 2010-09-08 |
| CVE-2026-99366 | nfsd: don't modify a session slot when replaying its cached reply | critical | 9.8 | - | No | 2026-11-19 |
| CVE-2026-48174 | - | critical | 9.8 | - | No | 2026-11-05 |
| CVE-2026-99153 | scsi: libiscsi: Validate the ITT reflected in a Reject PDU | critical | 9.8 | - | No | 2026-10-28 |
| CVE-2026-98335 | wifi: mac80211: abort chanswitch when leaving a mesh | critical | 9.8 | - | No | 2026-10-06 |
| CVE-2026-98308 | ALSA: hda: trace PCM open only after assigning a stream | critical | 9.8 | - | No | 2026-10-06 |
| CVE-2026-98270 | drm/amdgpu: check ras and obj before dereference | critical | 9.8 | - | No | 2026-10-06 |
| CVE-2026-90012 | spi: Fix DMA mapping ownership on partial map failure | critical | 9.8 | - | No | 2026-09-16 |
| CVE-2026-89662 | NFSD: Prevent lock owner use-after-free during client teardown | critical | 9.8 | - | No | 2026-09-11 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-710](https://radicalnotion.ai/cwe/cwe-710) | Improper Adherence to Coding Standards |
| Parent | [CWE-754](https://radicalnotion.ai/cwe/cwe-754) | Improper Check for Unusual or Exceptional Conditions |
| Related | [CWE-252](https://radicalnotion.ai/cwe/cwe-252) | Unchecked Return Value |
| Related | [CWE-362](https://radicalnotion.ai/cwe/cwe-362) | Concurrent Execution using Shared Resource with Improper Synchronization |
| Related | [CWE-789](https://radicalnotion.ai/cwe/cwe-789) | Memory Allocation with Excessive Size Value |
| Related | [CWE-1325](https://radicalnotion.ai/cwe/cwe-1325) | Improperly Controlled Sequential Memory Allocation |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| 7 Pernicious Kingdoms | Null Dereference | - | - |
| CLASP | Null-pointer dereference | - | - |
| PLOVER | Null Dereference (Null Pointer Dereference) | - | - |
| OWASP Top Ten 2004 | Denial of Service | A9 | CWE More Specific |
| CERT C Secure Coding | Do not dereference null pointers | EXP34-C | Exact |
| Software Fault Patterns | Faulty Pointer Use | SFP7 | - |
| OpenSSF Secure Coding Guide for Python | Check for None Values | pyscg-0034 | - |

## Frequently asked questions

### What is CWE-476?

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

### What CVEs are caused by CWE-476?

6,579 recorded CVEs are attributed to CWE-476, including CVE-2026-21525, CVE-2026-23125 and CVE-2022-36648. 1 is listed in CISA's Known Exploited Vulnerabilities (KEV) catalog.

### Is CWE-476 part of the OWASP Top 10?

CWE-476 maps to OWASP Top Ten 2004: Denial of Service (A9) in the OWASP security taxonomy.

### How do you prevent CWE-476?

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.

### How is CWE-476 detected?

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.

### What are the consequences of CWE-476?

Exploiting CWE-476 can lead to: DoS: Crash, Exit, or Restart, Execute Unauthorized Code or Commands, Read Memory, Modify Memory.

### Is CWE-476 actively exploited?

Yes. 1 CWE-476 vulnerability is in CISA's KEV catalog of actively exploited flaws, out of 6,579 recorded CVEs.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/476.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-476). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
