# CVE-2022-42920: Apache Commons BCEL prior to 6.6.0 allows producing arbitrary bytecode via out-of-bounds writing

> An out-of-bounds write in Apache Commons BCEL allows attackers to produce arbitrary bytecode, potentially leading to code execution in applications processing untrusted data.

- **Severity:** Critical 9.8 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/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:** 7 Nov 2022
- **Updated:** 3 Aug 2024
- **Also known as:** ALSA-2023:0005, AZL-109475, DEBIAN-CVE-2022-42920, GHSA-97xg-phpr-rg8q, RHSA-2022:8958, RHSA-2022:8959, RHSA-2023:0004, RHSA-2023:0005, RLSA-2023:0005, SUSE-SU-2022:4306-1, SUSE-SU-2022:4331-1, UBUNTU-CVE-2022-42920, USN-7208-1, openSUSE-SU-2024:12498-1, openSUSE-SU-2024:12530-1

## What is CVE-2022-42920?

CVE-2022-42920 is a critical memory corruption vulnerability in Fedoraproject Fedora, published on 7 Nov 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Apache Commons BCEL has a number of APIs that would normally only allow changing specific class characteristics. However, due to an out-of-bounds writing issue, these APIs can be used to produce arbitrary bytecode. This could be abused in applications that pass attacker-controllable data to those APIs, giving the attacker more control over the resulting bytecode than otherwise expected. Update to Apache Commons BCEL 6.6.0.

Weakness: CWE-787 (Out-of-bounds Write)

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

2 open source packages ship an affected version, including org.apache.bcel:bcel. It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `org.apache.bcel:bcel` | Maven | All versions | 6.6.0 |
| `org.apache.bcel:bcel` | Maven | All versions | 6.6.0 |
| `bcel` | AlmaLinux:9 | All versions | 6.4.1-9.el9_1 |
| `bcel` | Red Hat:enterprise_linux:7::client | All versions | 0:5.2-19.el7_9 |
| `bcel-javadoc` | Red Hat:enterprise_linux:7::client | All versions | 0:5.2-19.el7_9 |
| `bcel` | Red Hat:enterprise_linux:7::computenode | All versions | 0:5.2-19.el7_9 |
| `bcel-javadoc` | Red Hat:enterprise_linux:7::computenode | All versions | 0:5.2-19.el7_9 |
| `bcel` | Red Hat:enterprise_linux:7::server | All versions | 0:5.2-19.el7_9 |
| `bcel-javadoc` | Red Hat:enterprise_linux:7::server | All versions | 0:5.2-19.el7_9 |
| `bcel` | Red Hat:enterprise_linux:7::workstation | All versions | 0:5.2-19.el7_9 |
| `bcel-javadoc` | Red Hat:enterprise_linux:7::workstation | All versions | 0:5.2-19.el7_9 |
| `bcel` | Red Hat:enterprise_linux:9::appstream | All versions | 0:6.4.1-9.el9_1 |
| `bcel` | Red Hat:rhel_eus:9.0::appstream | All versions | 0:6.4.1-9.el9_0 |
| `rh-maven36-bcel` | Red Hat:rhel_software_collections:3::el7 | All versions | 0:6.3.1-2.3.el7 |
| `rh-maven36-bcel-javadoc` | Red Hat:rhel_software_collections:3::el7 | All versions | 0:6.3.1-2.3.el7 |
| `bcel` | Rocky Linux:9 | All versions | 0:6.4.1-9.el9_1 |
| `bcel` | SUSE:Linux Enterprise Module for Basesystem 15 SP3 | All versions | 5.2-150200.11.3.1 |
| `bcel` | SUSE:Linux Enterprise Module for Basesystem 15 SP4 | All versions | 5.2-150200.11.3.1 |
| `bcel` | SUSE:Linux Enterprise Server 12 SP5 | All versions | 5.2-28.3.1 |
| `bcel` | SUSE:Linux Enterprise Server for SAP Applications 12 SP5 | All versions | 5.2-28.3.1 |
| `bcel` | openSUSE:Leap 15.3 | All versions | 5.2-150200.11.3.1 |
| `bcel` | openSUSE:Leap 15.4 | All versions | 5.2-150200.11.3.1 |
| `bcel` | openSUSE:Tumbleweed | All versions | 5.2-37.1 |

Products: Apache Commons Bcel, Fedoraproject Fedora.

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

Upgrade org.apache.bcel:bcel to 6.6.0 or later.

## Is CVE-2022-42920 being exploited?

There is no known exploitation of CVE-2022-42920 in the wild and no public exploit code.

## Fix prompt for AI coding agents

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

What it is: CVE-2022-42920 is a critical memory corruption vulnerability in Fedoraproject Fedora, published on 7 Nov 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2022-42920 in the wild and no public exploit code.

Affected packages and fixed versions:
- org.apache.bcel:bcel (Maven): affected all versions; fixed in 6.6.0
- org.apache.bcel:bcel (Maven): affected all versions; fixed in 6.6.0

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-42920/ (Markdown: https://insights.sbomify.com/CVE-2022-42920/index.md)
```

## Sources

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

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