5.9medium
Buffer Overflow and Integer Overflow in yajl-ruby
- Severity
- 5.9medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 3.44% (higher than 89% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-jj47-x69x-mxrm
Description
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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| brianmario yajl-ruby | <= 1.4.1 | CVE List |
| yajl-ruby (RubyGems) | before 1.4.3 | GitHub Advisory Database |
| yajl-ruby_project yajl-ruby | before 1.4.2 | NVD |
All scores
| GitHub_M | 5.9medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H |
| GitHub | 5.9medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H |
| NVD | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| NVD | 5.0medium CVSS:2.0 | AV:N/AC:L/Au:N/C:P/I:N/A:N |
Classification
What each source says
CVE List
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.
GitHub Advisory Database
NOTE: A previous patch, 1.4.2, fixed the heap memory issue, but could still lead to a DoS infinite loop. Please update to version 1.4.3
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.
Details
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.
Impact
We rate this as a moderate severity vulnerability which mostly impacts process availability as we believe exploitation for arbitrary code execution to be unlikely.
Patches
Patched in yajl-ruby 1.4.3
Workarounds
Avoid passing large inputs to YAJL
References
For more information
If you have any questions or comments about this advisory:
- Open an issue in yajl-ruby
NVD (es)
yajl-riuby es un enlace en C a la biblioteca de análisis y generación de JSON YAJL. La rama 1.x y la rama 2.x de yajl contienen un desbordamiento de enteros que conlleva a una posterior corrupción de la memoria de la pila cuando trata con entradas grandes (~2GB). La lógica de reasignación en "yajl_buf.c#L64" puede hacer que el entero de 32 bits "need" sea convertido en 0 cuando "need" es acercado a un valor de 0x80000000 (es decir, ~2GB de datos), lo que resulta en una reasignación de buf-)alloc en un pequeño trozo de pila. Estos enteros están declarados como "size_t" en la rama 2.x de "yajl", lo que prácticamente evita que el problema ses desencadenado en plataformas de 64 bits, sin embargo esto no impide que este problema sea desencadenado en construcciones de 32 bits en las que "size_t" es un entero de 32 bits. El poblamiento posterior de este trozo de pila infra asignado es basado en el tamaño original del buffer, conllevando una corrupción de la memoria de la pila. Esta vulnerabilidad afecta principalmente a la disponibilidad de los procesos. Los mantenedores creen que la explotación para una ejecución de código arbitrario es poco probable. Se presenta un parche disponible y se espera que forme parte de la versión 1.4.2. Como medida de mitigación, evite pasar entradas grandes a YAJL
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2022-24795 changed 2025-04-22 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-jj47-x69x-mxrm changed 2024-02-16 | CC-BY-4.0 |
| NVD | CVE-2022-24795 changed 2026-06-17 | Public domain |