CWEweakness

CWE-193 Off-by-one Error

Official page ↗
Alternate terms
off-by-five
Abstraction
Base
Structure
Simple
Status
Draft
Languages
C, Not Language-Specific
CWE version
5.0

Description

A product calculates or uses an incorrect maximum or minimum value that is 1 more, or 1 less, than the correct value.

Common consequences

• Availability: DoS: Crash, Exit, or Restart, DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory), DoS: Instability — This weakness will generally lead to undefined behavior and therefore crashes. In the case of overflows involving loop index variables, the likelihood of infinite loops is also high. • Integrity: Modify Memory — If the value in question is important to data (as opposed to flow), simple data corruption has occurred. Also, if the wrap around results in other conditions such as buffer overflows, further memory corruption may occur. • Confidentiality, Availability, Access Control: Execute Unauthorized Code or Commands, Bypass Protection Mechanism — This weakness can sometimes trigger buffer overflows which can be used to execute arbitrary code. This is usually outside the scope of a program's implicit security policy.

Potential mitigations

• [Implementation] When copying character arrays or using character manipulation methods, the correct size parameter must be used to account for the null terminator that needs to be added at the end of the array. Some examples of functions susceptible to this weakness in C include strcpy(), strncpy(), strcat(), strncat(), printf(), sprintf(), scanf() and sscanf().

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-2003-0252: Off-by-one error allows remote attackers to cause a denial of service and possibly execute arbitrary code via requests that do not contain newlines. • CVE-2001-1391: Off-by-one vulnerability in driver allows users to modify kernel memory. • CVE-2002-0083: Off-by-one error allows local users or remote malicious servers to gain privileges. • CVE-2002-0653: Off-by-one buffer overflow in function usd by server allows local users to execute arbitrary code as the server user via .htaccess files with long entries. • CVE-2002-0844: Off-by-one buffer overflow in version control system allows local users to execute arbitrary code. • CVE-1999-1568: Off-by-one error in FTP server allows a remote attacker to cause a denial of service (crash) via a long PORT command. • CVE-2004-0346: Off-by-one buffer overflow in FTP server allows local users to gain privileges via a 1024 byte RETR command. • CVE-2004-0005: Multiple buffer overflows in chat client allow remote attackers to cause a denial of service and possibly execute arbitrary code. • CVE-2003-0356: Multiple off-by-one vulnerabilities in product allow remote attackers to cause a denial of service and possibly execute arbitrary code. • CVE-2001-1496: Off-by-one buffer overflow in server allows remote attackers to cause a denial of service and possibly execute arbitrary code. • CVE-2004-0342: This is an interesting example that might not be an off-by-one. • CVE-2001-0609: An off-by-one enables a terminating null to be overwritten, which causes 2 strings to be merged and enable a format string. • CVE-2002-1745: Off-by-one error allows source code disclosure of files with 4 letter extensions that match an accepted 3-letter extension. • CVE-2002-1816: Off-by-one buffer overflow. • CVE-2002-1721: Off-by-one error causes an snprintf call to overwrite a critical internal variable with a null value. • CVE-2003-0466: Off-by-one error in function used in many products leads to a buffer overflow during pathname management, as demonstrated using multiple commands in an FTP server. • CVE-2003-0625: Off-by-one error allows read of sensitive memory via a malformed request. • CVE-2006-4574: Chain: security monitoring product has an off-by-one error that leads to unexpected length values, triggering an assertion.

Related

Observed example · CVE (18)

  • CVE-2006-4574 Off-by-one error in the MIME Multipart dissector in Wireshark (formerly Ethereal) 0.10.1 through 0.99.3 allows remote attackers to cause a… vulnerability
  • CVE-2004-0342 WFTPD Pro Server 3.21 Release 1, with the XeroxDocutech option enabled, allows local users to cause a denial of service (crash) via a (1)… vulnerability
  • CVE-2004-0346 Off-by-one buffer overflow in _xlate_ascii_write() in ProFTPD 1.2.7 through 1.2.9rc2p allows local users to gain privileges via a 1024 byte… vulnerability
  • CVE-2004-0005 Multiple buffer overflows in Gaim 0.75 allow remote attackers to cause a denial of service and possibly execute arbitrary code via (1)… vulnerability
  • CVE-2003-0466 Off-by-one error in the fb_realpath() function, as derived from the realpath function in BSD, may allow attackers to execute arbitrary… vulnerability
  • CVE-2003-0625 Off-by-one error in certain versions of xfstt allows remote attackers to read potentially sensitive memory via a malformed client request… vulnerability
  • CVE-2003-0252 Off-by-one error in the xlog function of mountd in the Linux NFS utils package (nfs-utils) before 1.0.4 allows remote attackers to cause a… vulnerability
  • CVE-2003-0356 Multiple off-by-one vulnerabilities in Ethereal 0.9.11 and earlier allow remote attackers to cause a denial of service and possibly execute… vulnerability
  • CVE-2002-1721 Off-by-one error in alterMIME 0.1.10 and 0.1.11 allows remote attackers to cause a denial of service (crash) via an x-header that causes… vulnerability
  • CVE-2002-1745 Off-by-one error in the CodeBrws.asp sample script in Microsoft IIS 5.0 allows remote attackers to view the source code for files with… vulnerability
  • CVE-2002-1816 Off-by-one buffer overflow in the sock_gets function in sockhelp.c for ATPhttpd 0.4b and earlier allows remote attackers to execute… vulnerability
  • CVE-2002-0844 Off-by-one overflow in the CVS PreservePermissions of rcs.c for CVSD before 1.11.2 allows local users to execute arbitrary code. vulnerability
  • CVE-2002-0653 Off-by-one buffer overflow in the ssl_compat_directive function, as called by the rewrite_command hook for mod_ssl Apache module 2.8.9 and… vulnerability
  • CVE-2002-0083 Off-by-one error in the channel code of OpenSSH 2.0 through 3.0.2 allows local users or remote malicious servers to gain privileges. vulnerability
  • CVE-2001-1496 Off-by-one buffer overflow in Basic Authentication in Acme Labs thttpd 1.95 through 2.20 allows remote attackers to cause a denial of… vulnerability
  • CVE-2001-0609 Format string vulnerability in Infodrom cfingerd 1.4.3 and earlier allows a remote attacker to gain additional privileges via a malformed… vulnerability
  • CVE-2001-1391 Off-by-one vulnerability in CPIA driver of Linux kernel before 2.2.19 allows users to modify kernel memory. vulnerability
  • CVE-1999-1568 Off-by-one error in NcFTPd FTP server before 2.4.1 allows a remote attacker to cause a denial of service (crash) via a long PORT command. vulnerability

Can precede · CWE (3)

  • CWE-119 Improper Restriction of Operations within the Bounds of a Memory Buffer weakness
  • CWE-170 Improper Null Termination weakness
  • CWE-617 Reachable Assertion weakness

Child of · CWE (1)

  • CWE-682 Incorrect Calculation weakness

Referenced by CVE · weakness (257)

  • CVE-2026-115916 vLLM is an inference and serving engine for large language models. vulnerability
  • CVE-2026-116735 libpff through 20260926 contains an off-by-one bounds check in libpff_table_read_6c_record_entries that allows attackers to trigger a heap… vulnerability
  • CVE-2026-114460 A flaw was found in mod_qos. vulnerability
  • CVE-2026-12727 IBM MQ could allow an authenticated attacker to cause potential process instability due to an off-by-one buffer overflow when processing… vulnerability
  • CVE-2026-101302 TLS 1.3 embeds the actual record type as the last non-zero byte of the decrypted payload, optionally followed by zero padding. vulnerability
  • CVE-2026-108443 Off-by-one error in Microsoft Office Word allows an unauthorized attacker to execute code over a network. vulnerability
  • CVE-2026-111273 unarr through 1.1.1 contains an off-by-one heap-based buffer overflow in tar_get_name() in tar/parse-tar.c, reachable through the… vulnerability
  • CVE-2026-110604 Mini-XML 4.0.0 through 4.0.6 contains an off-by-one stack out-of-bounds write in mxml_strtod() when the locale decimal point is not '.'. vulnerability
  • CVE-2026-102857 Heap-based buffer overflow in Microsoft Office Visio allows an unauthorized attacker to execute code over a network. vulnerability
  • CVE-2026-97741 Heap-based buffer overflow in Microsoft Office Excel allows an unauthorized attacker to execute code over a network. vulnerability
  • CVE-2026-104774 OWASP Coraza WAF is a golang modsecurity compatible web application firewall library. vulnerability
  • CVE-2026-42618 In NTFS-3G before 2026.7.7, a heap buffer overflow exists in ntfs_decompress() in compress.c that allows an attacker to corrupt one byte of… vulnerability
  • CVE-2026-83742 Unsigned integer underflow in wstrncat() in src/port.c in wolfSSL wolfSSH from v1.4.11 through v1.5.0 on non-Windows platforms allows an… vulnerability
  • CVE-2026-104033 A flaw was found in SSSD. vulnerability
  • CVE-2026-106584 In ssh-keygen in OpenSSH before 10.6, certificates could have incorrect expiration times because of Daylight Saving mishandling. vulnerability
  • CVE-2026-100889 A vulnerability was detected in Trusted Domain Project OpenDKIM up to 2.11.0. vulnerability
  • CVE-2026-101014 A vulnerability was detected in Trusted Domain Project OpenDMARC up to 1.4.2. vulnerability
  • CVE-2026-18460 Off-by-one Error, Out-of-bounds Write vulnerability in RTI Connext Professional (Core Libraries) allows Overflow Buffers. vulnerability
  • CVE-2026-83600 Netdata is an open source observability tool. vulnerability
  • CVE-2026-93018 Imager versions before 1.036 for Perl disclose uninitialised heap memory reading a paletted image with pixel indexes past its colour map in… vulnerability
  • CVE-2026-76081 ZITADEL is an open source identity management platform. vulnerability
  • CVE-2026-90781 alsa-lib through 1.2.16.1 contains a stack buffer overflow in the __snd_ctl_ascii_elem_id_parse() function that writes one byte past a… vulnerability
  • CVE-2026-69609 Out-of-bounds read in Windows Win32K allows an authorized attacker to disclose information locally. vulnerability
  • CVE-2026-81396 Stack-based buffer overflow in Microsoft Office Excel allows an unauthorized attacker to execute code locally. vulnerability
  • CVE-2026-81738 OpenVPN 2.5.0 through 2.7.6 on Windows using the tap-windows6 driver allows attackers to trigger an out-of-bounds write via crafted… vulnerability
  • CVE-2026-86297 A vulnerability was identified in D-Link DIR-605 B1v202WWB03. vulnerability
  • CVE-2026-17469 IBM i 7.6, 7.5, 7.4, and 7.3 could allow a local authenticated attacker to cause a denial of service due to an off-by-one write in the LPD… vulnerability
  • CVE-2026-57160 PJSIP is a free and open source multimedia communication library written in C. vulnerability
  • CVE-2026-85454 MOOS core-moos through 10.4.0 contains a buffer overflow vulnerability in CMOOSSerialPort::GetTelegram() that writes a NUL terminator one… vulnerability
  • CVE-2026-14368 The LwM2M JSON content formatter's get_string() in subsys/net/lib/lwm2m/lwm2m_rw_json.c copies a parsed JSON string into a caller-supplied… vulnerability
Show all 257 ›

Referenced by CWE · has member (1)