CVE-2022-24795
JSON

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 packageVersionsReported by
brianmario yajl-ruby<= 1.4.1CVE List
yajl-ruby (RubyGems)before 1.4.3GitHub Advisory Database
yajl-ruby_project yajl-rubybefore 1.4.2NVD

All scores

GitHub_M5.9medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H
GitHub5.9medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H
NVD7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
NVD5.0medium CVSS:2.0AV:N/AC:L/Au:N/C:P/I:N/A:N

Classification

CWE-122CWE-190

SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.

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

https://github.com/brianmario/yajl-ruby/blob/7168bd79b888900aa94523301126f968a93eb3a6/ext/yajl/yajl_buf.c#L64

For more information

If you have any questions or comments about this advisory:

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

https://github.com/brianmario/yajl-ruby/security/advisories/GHSA-jj47-x69x-mxrmexploit, third-party-advisory, web
https://github.com/brianmario/yajl-ruby/commit/7168bd79b888900aa94523301126f968a93eb3a6patch, third-party-advisory, web
https://github.com/brianmario/yajl-ruby/blob/7168bd79b888900aa94523301126f968a93eb3a6/ext/yajl/yajl_buf.c#L64exploit, third-party-advisory, web
https://lists.debian.org/debian-lts-announce/2023/07/msg00013.htmlmailing-list, web
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/KLE3C4CECEJ4EUYI56KXI6OWACWXX7WN/vendor-advisory
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/YO32YDJ74DADC7CMJNLSLBVWN5EXGF5J/vendor-advisory
https://lists.debian.org/debian-lts-announce/2023/08/msg00003.htmlmailing-list, web
https://nvd.nist.gov/vuln/detail/CVE-2022-24795advisory
https://github.com/brianmario/yajl-rubypackage
https://github.com/rubysec/ruby-advisory-db/blob/master/gems/yajl-ruby/CVE-2022-24795.ymlweb
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/KLE3C4CECEJ4EUYI56KXI6OWACWXX7WNweb
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/YO32YDJ74DADC7CMJNLSLBVWN5EXGF5Jweb

Sources

SourceRecordLicence
CVE ListCVE-2022-24795 changed 2025-04-22CVE Terms of Use
GitHub Advisory DatabaseGHSA-jj47-x69x-mxrm changed 2024-02-16CC-BY-4.0
NVDCVE-2022-24795 changed 2026-06-17Public domain