Arbitrary Bytecode Generation Vulnerability in Apache Commons BCEL

bcel Updated 02 Oct 2025

Summary

07/11/2022
N/A
Yes i
Critical
9.8

CVE-2022-42920: Apache Commons BCEL has a number of APIs that would normally only allow changing specific class characteristics. Affects bcel across 2 version ranges.

< 6.5.0-1+deb11u1 < cf520ef45064c8fa4f43717ecc789d5a4f6b0d57

Fixed in 6.5.0-1+deb11u1. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

Apache Commons BCEL (Byte Code Engineering Library) is a Java library that allows developers to analyze, create, and manipulate Java bytecode. It provides a range of APIs that enable users to modify class files and generate new bytecode dynamically. However, due to a critical vulnerability, certain APIs can be exploited to produce arbitrary bytecode, posing significant security risks to applications that utilize this library.

Vulnerability Detail

The vulnerability identified as CVE-2022-42920 arises from an out-of-bounds writing issue in Apache Commons BCEL. This flaw allows attackers to manipulate specific class characteristics through the library's APIs, leading to the potential generation of arbitrary bytecode. If an application passes attacker-controllable data to these APIs, it can result in severe consequences, including unauthorized access, data corruption, or execution of malicious code. The CVSS score for this vulnerability is 9.8, indicating a critical level of severity.

How To Fix

Minimum fixed version

6.5.0-1+deb11u1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade bcel

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If immediate updating is not feasible, consider implementing input validation to sanitize any data passed to the BCEL APIs. This can help mitigate the risk of exploitation until a proper update can be applied. For example, you can add checks to ensure that the input data conforms to expected formats and ranges before processing it with BCEL.

Conclusion

The CVE-2022-42920 vulnerability in Apache Commons BCEL poses a significant risk due to its potential for arbitrary bytecode generation. It is crucial for developers using this library to update to the latest version to protect their applications from exploitation. Implementing input validation can serve as a temporary measure while transitioning to the updated library.

See every vulnerability recorded for bcel →

Share this vulnerability

FAQ

CVE-2022-42920 is a vulnerability in Apache Commons BCEL that allows for arbitrary bytecode generation due to an out-of-bounds writing issue.

If your application uses Apache Commons BCEL and passes untrusted data to its APIs, an attacker could exploit this vulnerability to execute arbitrary code or manipulate bytecode.

It is recommended to update to Apache Commons BCEL version 6.6.0 or later to mitigate this vulnerability.

Implementing input validation to sanitize data before it is passed to BCEL APIs can serve as a temporary workaround until an update is applied.

You can use tools like Vulert, which monitors and alerts for open-source vulnerabilities in your software using just a manifest file like package-lock.json. You can also check your application against known vulnerabilities using the Vulert playground.

Related vulnerabilities

Recent vulnerabilities recorded for bcel.

How To Fix

Minimum fixed version

6.5.0-1+deb11u1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade bcel

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback