CWEweakness
CWE-170 Improper Null Termination
Medium
Official page ↗
- Abstraction
- Base
- Structure
- Simple
- Status
- Incomplete
- Likelihood of exploit
- Medium
- Languages
- C, C++
- CWE version
- 5.0
Description
The product does not terminate or incorrectly terminates a string or array with a null character or equivalent terminator.
Common consequences
• Confidentiality, Integrity, Availability: Read Memory, Execute Unauthorized Code or Commands — The case of an omitted null character is the most dangerous of the possible issues. This will almost certainly result in information disclosure, and possibly a buffer overflow condition, which may be exploited to execute arbitrary code.
• Confidentiality, Integrity, Availability: DoS: Crash, Exit, or Restart, Read Memory, DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory) — If a null character is omitted from a string, then most string-copying functions will read data until they locate a null character, even outside of the intended boundaries of the string. This could: cause a crash due to a segmentation fault cause sensitive adjacent memory to be copied and sent to an outsider trigger a buffer overflow when the copy is being written to a fixed-size buffer.
• Integrity, Availability: Modify Memory, DoS: Crash, Exit, or Restart — Misplaced null characters may result in any number of security problems. The biggest issue is a subset of buffer overflow, and write-what-where conditions, where data corruption occurs from the writing of a null character over valid data, or even instructions. A randomly placed null character may put the system into an undefined state, and therefore make it prone to crashing. A misplaced null character may corrupt other data in memory.
• Integrity, Confidentiality, Availability, Access Control, Other: Alter Execution Logic, Execute Unauthorized Code or Commands — Should the null character corrupt the process flow, or affect a flag controlling access, it may lead to logical errors which allow for the execution of arbitrary code.
Potential mitigations
• [Requirements] Use a language that is not susceptible to these issues. However, be careful of null byte interaction errors (CWE-626) with lower-level constructs that may be written in a language that is susceptible.
• [Implementation] Ensure that all string functions used are understood fully as to how they append null characters. Also, be wary of off-by-one errors when appending nulls to the end of strings.
• [Implementation] If performance constraints permit, special code can be added that validates null-termination of string buffers, this is a rather naive and error-prone solution.
• [Implementation] Switch to bounded string manipulation functions. Inspect buffer lengths involved in the buffer overrun trace reported with the defect.
• [Implementation] Add code that fills buffers with nulls (however, the length of buffers still needs to be inspected, to ensure that the non null-terminated string is not written at the physical end of the buffer).
Detection methods
• 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.)
Observed examples
• CVE-2000-0312: Attacker does not null-terminate argv[] when invoking another program.
• CVE-2003-0777: Interrupted step causes resultant lack of null termination.
• CVE-2004-1072: Fault causes resultant lack of null termination, leading to buffer expansion.
• CVE-2001-1389: Multiple vulnerabilities related to improper null termination.
• CVE-2003-0143: Product does not null terminate a message buffer after snprintf-like call, leading to overflow.
• CVE-2009-2523: Chain: product does not handle when an input string is not NULL terminated (CWE-170), leading to buffer over-read (CWE-125) or heap-based buffer overflow (CWE-122).
Related
Observed example · CVE (6)
- CVE-2009-2523 The License Logging Server (llssrv.exe) in Microsoft Windows 2000 SP4 allows remote attackers to execute arbitrary code via an RPC message… vulnerability
- CVE-2004-1072 The binfmt_elf loader (binfmt_elf.c) in Linux kernel 2.4.x up to 2.4.27, and 2.6.x up to 2.6.8, may create an interpreter name string that… vulnerability
- CVE-2003-0777 saned in sane-backends 1.0.7 and earlier, when debug messages are enabled, does not properly handle dropped connections, which can prevent… vulnerability
- CVE-2003-0143 The pop_msg function in qpopper 4.0.x before 4.0.5fc2 does not null terminate a message buffer after a call to Qvsnprintf, which could… vulnerability
- CVE-2001-1389 Multiple vulnerabilities in xinetd 2.3.0 and earlier, and additional variants until 2.3.3, may allow remote attackers to cause a denial of… vulnerability
- CVE-2000-0312 cron in OpenBSD 2.5 allows local users to gain root privileges via an argv[] that is not NULL terminated, which is passed to cron's fake… vulnerability
Can also be · CWE (1)
- CWE-147 Improper Neutralization of Input Terminators weakness
Can precede · CWE (2)
Child of · CWE (2)
Peer of · CWE (3)
Referenced by CVE · weakness (65)
- CVE-2026-57185 Asterisk is an open source private branch exchange and telephony toolkit. vulnerability
- CVE-2026-114457 A flaw was found in mod_qos. vulnerability
- CVE-2026-83781 Improper null termination in Windows Program Compatibility Assistant Service allows an authorized attacker to elevate privileges locally. vulnerability
- CVE-2026-96850 Use of uninitialized resource in Windows Modern Device Management (MDM) allows an authorized attacker to disclose information locally. vulnerability
- CVE-2026-96860 Out-of-bounds read in Windows USB Print Driver allows an authorized attacker to disclose information locally. vulnerability
- CVE-2026-81882 radare2 is a UNIX-like reverse engineering framework and command-line toolset. vulnerability
- CVE-2026-73324 Certain VLC media player builds in versions 3.0.0 through 3.0.23 contain a memory-safety vulnerability reachable when processing media from… vulnerability
- CVE-2026-70587 Improper null termination in Windows Remote Desktop Protocol allows an unauthorized attacker to disclose information over a network. vulnerability
- CVE-2026-78506 Improper null termination in Microsoft Office Word allows an unauthorized attacker to disclose information locally. vulnerability
- CVE-2026-45798 Wazuh is a free and open source platform used for threat prevention, detection, and response. vulnerability
- CVE-2026-72095 In the Linux kernel, the following vulnerability has been resolved: dma-fence: Make dma_fence_dedup_array() robust against 0-count input… vulnerability
- CVE-2026-63860 In the Linux kernel, the following vulnerability has been resolved: RDMA/core: Prefer NLA_NUL_STRING These attributes are evaluated as… vulnerability
- CVE-2026-44452 h2o is an HTTP server with support for HTTP/1.x, HTTP/2 and HTTP/3. vulnerability
- CVE-2026-12386 Improper null termination vulnerability in TUBITAK BILGEM Software Technologies Research Institute Pardus Pen allows Overflow Buffers. vulnerability
- CVE-2026-55738 A stack-based buffer overflow exists in the raw_to_header function in src/microtar.c in rxi microtar 0.1.0. vulnerability
- CVE-2026-5067 A remote, unauthenticated attacker can trigger memory corruption in Zephyr's HTTP server WebSocket upgrade path by sending a crafted… vulnerability
- CVE-2026-8721 Crypt::OpenSSL::PKCS12 versions through 1.94 for Perl truncates passwords with embedded NULLs. vulnerability
- CVE-2026-42010 A flaw was found in gnutls. vulnerability
- CVE-2026-34462 Sandboxie-Plus is an open source sandbox-based isolation software for Windows. vulnerability
- CVE-2026-34464 Sandboxie-Plus is an open source sandbox-based isolation software for Windows. vulnerability
- CVE-2026-34032 Improper Null Termination, Out-of-bounds Read vulnerability in Apache HTTP Server. vulnerability
- CVE-2026-43028 In the Linux kernel, the following vulnerability has been resolved: netfilter: x_tables: ensure names are nul-terminated Reject names that… vulnerability
- CVE-2026-40334 libgphoto2 is a camera access and control library. vulnerability
- CVE-2026-33948 jq is a command-line JSON processor. vulnerability
- CVE-2026-2239 A flaw was found in GIMP. vulnerability
- CVE-2026-32837 miniaudio version 0.11.25 and earlier (fixed in commits 1df46ae and 1df46ae) contain a heap out-of-bounds read vulnerability in the WAV… vulnerability
- CVE-2026-23749 Golioth Firmware SDK version 0.19.1 prior to 0.22.0, fixed in commit 0e788217, contain an out-of-bounds read due to improper null… vulnerability
- CVE-2026-27692 iccDEV provides a set of libraries and tools for working with ICC color management profiles. vulnerability
- CVE-2025-67733 Valkey is a distributed key-value database. vulnerability
- CVE-2026-24852 iccDEV provides a set of libraries and tools that allow for the interaction, manipulation, and application of ICC color management profiles. vulnerability