This vulnerability occurs when a program calls a function that can return a NULL pointer to signal failure, but the code does not check for this error condition before using the returned value, leading to a crash or unexpected behavior from dereferencing the NULL pointer.
Many functions in C and similar languages use a NULL pointer return value to indicate that an operation failed, such as when memory allocation fails or a required resource isn't found. If a developer assumes the call was always successful and uses the return value directly—for example, by trying to read or write to that memory location—the program will attempt to dereference NULL, typically causing a segmentation fault and a crash. This is a specific and common case of a broader class of unchecked return value errors. While not all functions signal errors with NULL (some use special integers or status codes), the pattern of failing to validate a function's output before proceeding is a frequent source of instability. Properly handling these potential NULL returns by adding checks is a fundamental practice for writing robust and secure software that can gracefully manage unexpected states.
Impact: DoS: Crash, Exit, or Restart
Impact: Execute Unauthorized Code or CommandsRead MemoryModify 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.
javac
/*routine that ensures user_supplied_addr is in the right format for conversion /
c