CyberSecBulletin

Incorrect Calculation of Buffer Size

CWE-131

The product does not correctly calculate the size to be used when allocating a buffer.

We track 106 vulnerabilities of this type. 100% are rated high or critical, and the average CVSS score is 8.2. 1 has been exploited in real attacks.

How this weakness is prevented

  • Implementation: When allocating a buffer for the purpose of transforming, converting, or encoding an input, allocate enough memory to handle the largest possible encoding. For example, in a routine that converts & characters to & for HTML entity encoding, the output buffer needs to be at least 5 times as large as the input buffer.
  • Implementation: Understand the programming language's underlying representation and how it interacts with numeric calculation (CWE-681). Pay close attention to byte size discrepancies, precision, signed/unsigned distinctions, truncation, conversion and casting between types, not-a-number calculations, and how the language handles numbers that are too large or too small for its underlying representation. Also be careful to account for 32-bit, 64-bit, and other potential differences that may affect the numeric representation.
  • Implementation: Perform input validation on any numeric input by ensuring that it is within the expected range. Enforce that the input meets both the minimum and maximum requirements for the expected range.
  • Architecture and Design: For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
  • Implementation: When processing structured incoming data containing a size field followed by raw data, identify and resolve any inconsistencies between the size field and the actual size of the data (CWE-130).

Latest Incorrect Calculation of Buffer Size vulnerabilities

  • 7.5 High severity

    FreeBSD: Integer Overflow or Wraparound

    CVE-2024-45287FreeBSD

    A malicious value of size in a structure of packed libnv can cause an integer overflow, leading to the allocation of a smaller buffer than required for the parsed data.

  • 7.8 High severity

    Linux: Incorrect Calculation of Buffer Size

    CVE-2024-43843Linux

    In the Linux kernel, the following vulnerability has been resolved: riscv, bpf: Fix out-of-bounds issue when preparing trampoline image We get the size of the trampoline image during the dry run phase and allocate memory based on that size. The allocated image

  • 7.5 High severity

    CODESYS Control for BeagleBone SL: Incorrect Calculation of Buffer Size

    CVE-2024-5000Codesys

    An unauthenticated remote attacker can use a malicious OPC UA client to send a crafted request to affected CODESYS products which can cause a DoS due to incorrect calculation of buffer size.

  • 7.5 High severity

    Junos OS: Incorrect Calculation of Buffer Size

    CVE-2024-30405Juniper Networks

    An Incorrect Calculation of Buffer Size vulnerability in Juniper Networks Junos OS SRX 5000 Series devices using SPC2 line cards while ALGs are enabled allows an attacker sending specific crafted packets to cause a transit traffic Denial of Service (DoS). Cont

  • 7.5 High severity

    OpenBSD: Incorrect Calculation of Buffer Size

    CVE-2023-52558OpenBSD

    In OpenBSD 7.4 before errata 002 and OpenBSD 7.3 before errata 019, a network buffer that had to be split at certain length that could crash the kernel after receiving specially crafted escape sequences.

  • 9.0 Critical severity

    various: Incorrect Calculation of Buffer Size

    CVE-2023-50736Lexmark

    A memory corruption vulnerability has been identified in PostScript interpreter in various Lexmark devices. The vulnerability can be leveraged by an attacker to execute arbitrary code.

  • 9.8 Critical severity

    libbiosig: Out-of-bounds Write

    CVE-2024-23606The Biosig ProjectEPSS 1.68%

    An out-of-bounds write vulnerability exists in the sopen_FAMOS_read functionality of The Biosig Project libbiosig 2.5.0 and Master Branch (ab0ee111). A specially crafted .famos file can lead to arbitrary code execution. An attacker can provide a malicious file

  • 7.5 High severity

    BIG-IP: Incorrect Calculation of Buffer Size

    CVE-2024-23805F5

    Undisclosed requests can cause the Traffic Management Microkernel (TMM) to terminate. For the Application Visibility and Reporting module, this may occur when the HTTP Analytics profile with URLs enabled under Collected Entities is configured on a virtual serv

  • 7.5 High severity

    GSDK: Incorrect Calculation of Buffer Size

    CVE-2023-6387Silabs.com

    A potential buffer overflow exists in the Bluetooth LE HCI CPC sample application in the Gecko SDK which may result in a denial of service or remote code execution

  • 9.8 Critical severity

    eFilm Workstation: Out-of-bounds Write

    CVE-2024-23622IBM Merge HealthcareEPSS 1.85%

    A stack-based buffer overflow exists in IBM Merge Healthcare eFilm Workstation license server. A remote, unauthenticated attacker can exploit this vulnerability to achieve remote code execution with SYSTEM privileges.

  • 9.8 Critical severity

    eFilm Workstation: Buffer Copy without Checking Size of Input

    CVE-2024-23621IBM Merge HealthcareEPSS 1.85%

    A buffer overflow exists in IBM Merge Healthcare eFilm Workstation license server. A remote, unauthenticated attacker can exploit this vulnerability to achieve remote code execution.

  • 9.8 Critical severity

    FreeBSD: Incorrect Calculation of Buffer Size

    CVE-2023-5941FreeBSDEPSS 1.21%

    In versions of FreeBSD 12.4-RELEASE prior to 12.4-RELEASE-p7 and FreeBSD 13.2-RELEASE prior to 13.2-RELEASE-p5 the __sflush() stdio function in libc does not correctly update FILE objects' write space members for write-buffered streams when the write(2) system

  • 7.5 High severity

    SIMATIC S7-1500 CPU 1518-4 PN/DP MFP: Incorrect Calculation of Buffer Size

    CVE-2023-45871Siemens

    An issue was discovered in drivers/net/ethernet/intel/igb/igb_main.c in the IGB driver in the Linux kernel before 6.5.3. A buffer size may not be adequate for frames larger than the MTU.

  • 8.8 High severity

    redis: Out-of-bounds Write

    CVE-2023-36824RedisEPSS 77.4%

    Redis is an in-memory database that persists on disk. In Redit 7.0 prior to 7.0.12, extracting key names from a command and a list of arguments may, in some cases, trigger a heap overflow and result in reading random heap memory, heap corruption and potentiall

  • 7.5 High severity

    Apache Guacamole: Incorrect Calculation of Buffer Size

    CVE-2023-30575ApacheEPSS 1.01%

    Apache Guacamole 1.5.1 and older may incorrectly calculate the lengths of instruction elements sent during the Guacamole protocol handshake, potentially allowing an attacker to inject Guacamole instructions during the handshake through specially-crafted data.

  • 9.8 Critical severity

    RIOT: Out-of-bounds Write

    CVE-2023-24819Riot-os

    RIOT-OS, an operating system that supports Internet of Things devices, contains a network stack with the ability to process 6LoWPAN frames. Prior to version 2022.10, an attacker can send a crafted frame to the device resulting in an out of bounds write in the

  • 8.1 High severity

    PHP: Allocation of Resources Without Limits or Throttling

    CVE-2023-0568PHP GroupEPSS 1.24%

    In PHP 8.0.X before 8.0.28, 8.1.X before 8.1.16 and 8.2.X before 8.2.3, core path resolution function allocate buffer one byte too small. When resolving paths with lengths close to system MAXPATHLEN setting, this may lead to the byte after the allocated buffer

  • 7.8 High severity

    kernel: Out-of-bounds Write

    CVE-2022-4378Kernel

    A stack overflow flaw was found in the Linux kernel's SYSCTL subsystem in how a user changes certain kernel parameters and variables. This flaw allows a local user to crash or potentially escalate their privileges on the system.

  • 7.5 High severity

    tensorflow: Incorrect Calculation of Buffer Size

    CVE-2022-41907TensorFlow

    TensorFlow is an open source platform for machine learning. When `tf.raw_ops.ResizeNearestNeighborGrad` is given a large `size` input, it overflows. We have patched the issue in GitHub commit 00c821af032ba9e5f5fa3fe14690c8d28a657624. The fix will be included i

  • 7.5 High severity

    tensorflow: Incorrect Calculation of Buffer Size

    CVE-2022-41887TensorFlow

    TensorFlow is an open source platform for machine learning. `tf.keras.losses.poisson` receives a `y_pred` and `y_true` that are passed through `functor::mul` in `BinaryOp`. If the resulting dimensions overflow an `int32`, TensorFlow will crash due to a size mi

  • 7.5 High severity

    tensorflow: Incorrect Calculation of Buffer Size

    CVE-2022-41886TensorFlow

    TensorFlow is an open source platform for machine learning. When `tf.raw_ops.ImageProjectiveTransformV2` is given a large output shape, it overflows. We have patched the issue in GitHub commit 8faa6ea692985dbe6ce10e1a3168e0bd60a723ba. The fix will be included

  • 7.5 High severity

    tensorflow: Incorrect Calculation of Buffer Size

    CVE-2022-41885TensorFlow

    TensorFlow is an open source platform for machine learning. When `tf.raw_ops.FusedResizeAndPadConv2D` is given a large tensor shape, it overflows. We have patched the issue in GitHub commit d66e1d568275e6a2947de97dca7a102a211e01ce. The fix will be included in

  • 7.1 High severity

    PHP: Out-of-bounds Read

    CVE-2022-31630PHP GroupEPSS 1.52%

    In PHP versions prior to 7.4.33, 8.0.25 and 8.1.12, when using imageloadfont() function in gd extension, it is possible to supply a specially crafted font file, such as if the loaded font is used with imagechar() function, the read outside allocated buffer wil

  • 7.8 High severity

    sysstat: Incorrect Calculation of Buffer Size

    CVE-2022-39377SysstatEPSS 1.36%

    sysstat is a set of system performance tools for the Linux operating system. On 32 bit systems, in versions 9.1.16 and newer but prior to 12.7.1, allocate_structures contains a size_t overflow in sa_common.c. The allocate_structures function insufficiently che

  • 7.5 High severity

    linux_kernel: Allocation of Resources Without Limits or Throttling

    CVE-2022-43945LinuxEPSS 5.46%

    The Linux kernel NFSD implementation prior to versions 5.19.17 and 6.0.2 are vulnerable to buffer overflow. NFSD tracks the number of pages held by each NFSD thread by combining the receive and send buffers of a remote procedure call (RPC) into a single array

  • 7.8 High severity

    Microsoft Windows Kernel Privilege Escalation Exploited

    CVE-2020-17087MicrosoftEPSS 5.43%

    Windows Kernel Local Elevation of Privilege Vulnerability