# CVE-2022-24795: Buffer Overflow and Integer Overflow in yajl-ruby

> Integer overflow in yajl-ruby causes heap corruption and denial of service when processing large inputs, primarily affecting 32-bit systems.

- **Severity:** Medium 5.9 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 5 Apr 2022
- **Updated:** 22 Apr 2025
- **Also known as:** ALSA-2022:7524, ALSA-2022:8252, AZL-10552, AZL-35233, CLSA-2026-1791550583, DEBIAN-CVE-2022-24795, GHSA-jj47-x69x-mxrm, OESA-2022-1752, OESA-2022-1912, RHSA-2022:7524, RHSA-2022:8252, RLSA-2022:7524, RLSA-2022:8252, SUSE-SU-2022:1746-1, SUSE-SU-2022:1918-1, SUSE-SU-2022:3162-1, UBUNTU-CVE-2022-24795, openSUSE-SU-2024:12258-1

## What is CVE-2022-24795?

CVE-2022-24795 is a medium-severity vulnerability in brianmario yajl-ruby, published on 5 Apr 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official 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.

Weakness: CWE-190 (Integer Overflow or Wraparound), CWE-122 (Heap-based Buffer Overflow)

## Which versions are affected by CVE-2022-24795?

2 open source packages ship an affected version, including yajl-ruby. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `yajl-ruby` | RubyGems | All versions | 1.4.3 |
| `yajl-ruby` | RubyGems | All versions | 1.4.3 |
| `yajl` | AlmaLinux:8 | All versions | 2.1.0-11.el8 |
| `yajl-devel` | AlmaLinux:8 | All versions | 2.1.0-11.el8 |
| `yajl` | AlmaLinux:9 | All versions | 2.1.0-21.el9 |
| `yajl-devel` | AlmaLinux:9 | All versions | 2.1.0-21.el9 |
| `yajl` | Red Hat:enterprise_linux:8::appstream | All versions | 0:2.1.0-11.el8 |
| `yajl-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:2.1.0-11.el8 |
| `yajl-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:2.1.0-11.el8 |
| `yajl-debuginfo` | Red Hat:enterprise_linux:8::crb | All versions | 0:2.1.0-11.el8 |
| `yajl-debugsource` | Red Hat:enterprise_linux:8::crb | All versions | 0:2.1.0-11.el8 |
| `yajl-devel` | Red Hat:enterprise_linux:8::crb | All versions | 0:2.1.0-11.el8 |
| `yajl` | Red Hat:enterprise_linux:9::appstream | All versions | 0:2.1.0-21.el9 |
| `yajl-debuginfo` | Red Hat:enterprise_linux:9::appstream | All versions | 0:2.1.0-21.el9 |
| `yajl-debugsource` | Red Hat:enterprise_linux:9::appstream | All versions | 0:2.1.0-21.el9 |
| `yajl-debuginfo` | Red Hat:enterprise_linux:9::crb | All versions | 0:2.1.0-21.el9 |
| `yajl-debugsource` | Red Hat:enterprise_linux:9::crb | All versions | 0:2.1.0-21.el9 |
| `yajl-devel` | Red Hat:enterprise_linux:9::crb | All versions | 0:2.1.0-21.el9 |
| `yajl` | Rocky Linux:8 | All versions | 0:2.1.0-11.el8 |
| `yajl` | Rocky Linux:9 | All versions | 0:2.1.0-21.el9 |
| `yajl` | Rocky Linux:9 | All versions | 0:2.1.0-21.el9_0 |
| `libyajl` | SUSE:Linux Enterprise Micro 5.1 | All versions | 2.1.0-150000.4.3.1 |
| `libyajl` | SUSE:Linux Enterprise Micro 5.2 | All versions | 2.1.0-150000.4.3.1 |
| `libyajl` | SUSE:Linux Enterprise Module for Basesystem 15 SP3 | All versions | 2.1.0-150000.4.3.1 |
| `libyajl` | SUSE:Linux Enterprise Module for Basesystem 15 SP4 | All versions | 2.1.0-150000.4.3.1 |
| `libyajl` | SUSE:Linux Enterprise Server 12 SP5 | All versions | 2.0.1-18.7.1 |
| `libyajl` | SUSE:Linux Enterprise Server for SAP Applications 12 SP5 | All versions | 2.0.1-18.7.1 |
| `libyajl` | SUSE:Linux Enterprise Software Development Kit 12 SP5 | All versions | 2.0.1-18.7.1 |
| `rubygem-yajl-ruby` | SUSE:OpenStack Cloud Crowbar 8 | All versions | 1.3.1-4.6.1 |
| `rubygem-yajl-ruby` | SUSE:OpenStack Cloud Crowbar 9 | All versions | 1.3.1-4.6.1 |
| `libyajl` | openSUSE:Leap 15.3 | All versions | 2.1.0-150000.4.3.1 |
| `libyajl` | openSUSE:Leap 15.4 | All versions | 2.1.0-150000.4.3.1 |
| `libyajl` | openSUSE:Leap Micro 5.2 | All versions | 2.1.0-150000.4.3.1 |

Products: Yajl-Ruby Project Yajl-Ruby.

## How do I fix CVE-2022-24795?

Upgrade yajl-ruby to 1.4.3 or later.

## Is CVE-2022-24795 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2022-24795 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-24795 and fix it if it is affected.

What it is: CVE-2022-24795 is a medium-severity vulnerability in brianmario yajl-ruby, published on 5 Apr 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2022-24795 exists.

Affected packages and fixed versions:
- yajl-ruby (RubyGems): affected all versions; fixed in 1.4.3
- yajl-ruby (RubyGems): affected all versions; fixed in 1.4.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2022-24795/ (Markdown: https://insights.sbomify.com/CVE-2022-24795/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2022-24795
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2022-24795
- OSV: https://osv.dev/vulnerability/CVE-2022-24795

---
From sbomify Insights: https://insights.sbomify.com/CVE-2022-24795/
Summaries are generated and may contain mistakes; the official description above is the record.
