CWE-690 · Słabość
Unchecked Return Value to NULL Pointer Dereference
- Abstrakcja
- Złożona
- Status
- Szkic
- Dodano
- 11 kwietnia 2008
- Ostatnia zmiana
- 11 grudnia 2025
Opis
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.
Skutki
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.
Przykłady podatności
- 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
Zaczyna się od
Słabość nadrzędna
Kiedy powstaje
- 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.
Dotyczy
Memory-Unsafe, C, C++
Źródła
Wpis z katalogu CWE 4.20.