CVE Vulnerabilities

CVE-2022-24795

Heap-based Buffer Overflow

Published: Apr 05, 2022 | Modified: Nov 07, 2023
CVSS 3.x
7.5
HIGH
Source:
NVD
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
CVSS 2.x
5 MEDIUM
AV:N/AC:L/Au:N/C:P/I:N/A:N
RedHat/V2
RedHat/V3
5.9 MODERATE
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H
Ubuntu
MEDIUM

yajl-ruby is a C binding to the YAJL JSON parsing and generation library. The 1.x branch and the 2.x branch of yajl contain an integer overflow which leads to subsequent heap memory corruption when dealing with large (~2GB) inputs. The reallocation logic at yajl_buf.c#L64 may result in the need 32bit integer wrapping to 0 when need approaches a value of 0x80000000 (i.e. ~2GB of data), which results in a reallocation of buf->alloc into a small heap chunk. These integers are declared as size_t in the 2.x branch of yajl, which practically prevents the issue from triggering on 64bit platforms, however this does not preclude this issue triggering on 32bit builds on which size_t is a 32bit integer. Subsequent population of this under-allocated heap chunk is based on the original buffer size, leading to heap memory corruption. This vulnerability mostly impacts process availability. Maintainers believe exploitation for arbitrary code execution is unlikely. A patch is available and anticipated to be part of yajl-ruby version 1.4.2. As a workaround, avoid passing large inputs to YAJL.

Weakness

A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().

Affected Software

Name Vendor Start Version End Version
Yajl-ruby Yajl-ruby_project * 1.4.2 (excluding)
Red Hat Enterprise Linux 8 RedHat yajl-0:2.1.0-11.el8 *
Red Hat Enterprise Linux 8.6 Extended Update Support RedHat yajl-0:2.1.0-13.el8_6 *
Red Hat Enterprise Linux 9 RedHat yajl-0:2.1.0-21.el9 *
Argyll Ubuntu bionic *
Argyll Ubuntu impish *
Argyll Ubuntu kinetic *
Argyll Ubuntu lunar *
Argyll Ubuntu mantic *
Argyll Ubuntu trusty *
Argyll Ubuntu xenial *
Burp Ubuntu bionic *
Burp Ubuntu impish *
Burp Ubuntu kinetic *
Burp Ubuntu lunar *
Burp Ubuntu mantic *
Burp Ubuntu trusty *
Burp Ubuntu xenial *
Centreon-broker Ubuntu trusty *
Centreon-broker Ubuntu xenial *
Collada2gltf Ubuntu bionic *
Collada2gltf Ubuntu impish *
Collada2gltf Ubuntu kinetic *
Collada2gltf Ubuntu lunar *
Collada2gltf Ubuntu trusty *
Collada2gltf Ubuntu xenial *
Icinga2 Ubuntu bionic *
Icinga2 Ubuntu impish *
Icinga2 Ubuntu kinetic *
Icinga2 Ubuntu lunar *
Icinga2 Ubuntu mantic *
Icinga2 Ubuntu trusty *
Icinga2 Ubuntu xenial *
Libbson Ubuntu bionic *
Libbson Ubuntu trusty *
Libbson Ubuntu xenial *
Lnav Ubuntu bionic *
Lnav Ubuntu impish *
Lnav Ubuntu kinetic *
Lnav Ubuntu lunar *
Lnav Ubuntu mantic *
Lnav Ubuntu trusty *
Lnav Ubuntu xenial *
Php-mongodb Ubuntu bionic *
Php-mongodb Ubuntu impish *
Php-mongodb Ubuntu kinetic *
Php-mongodb Ubuntu lunar *
Php-mongodb Ubuntu mantic *
Php-mongodb Ubuntu trusty *
Php-mongodb Ubuntu xenial *
R-cran-jsonlite Ubuntu bionic *
R-cran-jsonlite Ubuntu impish *
R-cran-jsonlite Ubuntu kinetic *
R-cran-jsonlite Ubuntu lunar *
R-cran-jsonlite Ubuntu mantic *
R-cran-jsonlite Ubuntu trusty *
R-cran-jsonlite Ubuntu xenial *
Ruby-yajl Ubuntu bionic *
Ruby-yajl Ubuntu impish *
Ruby-yajl Ubuntu kinetic *
Ruby-yajl Ubuntu lunar *
Ruby-yajl Ubuntu mantic *
Ruby-yajl Ubuntu trusty *
Ruby-yajl Ubuntu xenial *
Tulip Ubuntu impish *
Tulip Ubuntu kinetic *
Tulip Ubuntu lunar *
Tulip Ubuntu mantic *
Tulip Ubuntu trusty *
Tulip Ubuntu xenial *
Yajl Ubuntu bionic *
Yajl Ubuntu esm-infra/bionic *
Yajl Ubuntu esm-infra/xenial *
Yajl Ubuntu focal *
Yajl Ubuntu impish *
Yajl Ubuntu jammy *
Yajl Ubuntu kinetic *
Yajl Ubuntu lunar *
Yajl Ubuntu trusty *
Yajl Ubuntu trusty/esm *
Yajl Ubuntu upstream *
Yajl Ubuntu xenial *

Potential Mitigations

  • Use automatic buffer overflow detection mechanisms that are offered by certain compilers or compiler extensions. Examples include: the Microsoft Visual Studio /GS flag, Fedora/Red Hat FORTIFY_SOURCE GCC flag, StackGuard, and ProPolice, which provide various mechanisms including canary-based detection and range/index checking.
  • D3-SFCV (Stack Frame Canary Validation) from D3FEND [REF-1334] discusses canary-based detection in detail.
  • Run or compile the software using features or extensions that randomly arrange the positions of a program’s executable and libraries in memory. Because this makes the addresses unpredictable, it can prevent an attacker from reliably jumping to exploitable code.
  • Examples include Address Space Layout Randomization (ASLR) [REF-58] [REF-60] and Position-Independent Executables (PIE) [REF-64]. Imported modules may be similarly realigned if their default memory addresses conflict with other modules, in a process known as “rebasing” (for Windows) and “prelinking” (for Linux) [REF-1332] using randomly generated addresses. ASLR for libraries cannot be used in conjunction with prelink since it would require relocating the libraries at run-time, defeating the whole purpose of prelinking.
  • For more information on these techniques see D3-SAOR (Segment Address Offset Randomization) from D3FEND [REF-1335].

References