CVE-2022-42920 Overview
Apache Commons BCEL (Byte Code Engineering Library) contains a critical out-of-bounds writing vulnerability that allows attackers to produce arbitrary bytecode through APIs that would normally only permit specific class characteristic modifications. This vulnerability affects applications that pass attacker-controllable data to the affected BCEL APIs, enabling attackers to gain significantly more control over resulting bytecode than intended.
Critical Impact
Attackers can exploit the out-of-bounds write flaw to generate arbitrary Java bytecode, potentially leading to remote code execution in applications that process untrusted input through BCEL APIs.
Affected Products
- Apache Commons BCEL (versions prior to 6.6.0)
- Fedora 35
- Fedora 36
- Fedora 37
Discovery Timeline
- 2022-11-07 - CVE-2022-42920 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2022-42920
Vulnerability Analysis
This vulnerability stems from an out-of-bounds write condition (CWE-787) within Apache Commons BCEL, a widely-used library for analyzing, creating, and manipulating Java class files. BCEL provides APIs that are designed to modify specific characteristics of Java class files in a controlled manner. However, due to improper bounds checking, these APIs can be abused to write data beyond intended memory boundaries.
When exploited, this flaw allows an attacker to craft malicious input that, when processed by BCEL's class manipulation APIs, results in arbitrary bytecode generation. This is particularly dangerous because Java bytecode executes within the JVM, meaning successful exploitation could lead to arbitrary code execution within the context of the target application.
The vulnerability is exploitable remotely without requiring authentication or user interaction, making it accessible to unauthenticated attackers who can supply crafted input to applications using BCEL.
Root Cause
The root cause is an out-of-bounds write vulnerability in the BCEL library's class manipulation functionality. The library fails to properly validate array boundaries when modifying class file structures, allowing write operations to exceed allocated buffer sizes. This memory corruption can be leveraged to inject malicious bytecode instructions into generated class files.
Attack Vector
The attack vector is network-based, targeting applications that use Apache Commons BCEL to process untrusted or attacker-controlled data. An attacker can exploit this vulnerability by:
- Identifying an application that uses BCEL for bytecode manipulation
- Crafting malicious input designed to trigger the out-of-bounds write condition
- Supplying the crafted input to the target application's BCEL-processing functionality
- The out-of-bounds write corrupts memory boundaries during class manipulation
- Arbitrary bytecode is generated and potentially executed within the JVM
Applications particularly at risk include those that dynamically generate or modify Java classes based on external input, such as certain application servers, dynamic proxy generators, and code analysis tools.
Detection Methods for CVE-2022-42920
Indicators of Compromise
- Unexpected Java class files appearing in application directories with unusual bytecode patterns
- Application crashes or memory corruption errors related to BCEL library operations
- Anomalous JVM behavior following class loading operations
- Log entries indicating malformed class file processing or bytecode verification failures
Detection Strategies
- Implement Software Composition Analysis (SCA) to identify applications using vulnerable versions of Apache Commons BCEL (versions prior to 6.6.0)
- Monitor for unusual bytecode generation patterns or class loading activities
- Deploy runtime application self-protection (RASP) solutions to detect bytecode manipulation attempts
- Scan application dependencies using tools like OWASP Dependency-Check or Snyk
Monitoring Recommendations
- Enable verbose logging for applications utilizing BCEL library functionality
- Monitor JVM class loading events for unexpected or malformed class definitions
- Implement file integrity monitoring on directories where dynamically generated classes are stored
- Configure alerts for bytecode verification errors in application logs
How to Mitigate CVE-2022-42920
Immediate Actions Required
- Upgrade Apache Commons BCEL to version 6.6.0 or later immediately
- Audit applications to identify all instances of BCEL library usage
- Review and restrict input sources that feed into BCEL APIs
- Consider implementing input validation layers before data reaches BCEL processing functions
Patch Information
Apache has released version 6.6.0 of Commons BCEL to address this vulnerability. Organizations should update their BCEL dependencies to this version or later. For Maven-based projects, update the dependency version in pom.xml. For Gradle projects, update the dependency in build.gradle.
Fedora users should apply the security updates available through the standard package management system. Refer to the Apache Thread Discussion for official vendor guidance. Additional security advisories are available from the Openwall Security Mailing List and Gentoo GLSA 202401-25.
Workarounds
- If immediate patching is not possible, restrict network access to applications using BCEL
- Implement strict input validation to sanitize data before it reaches BCEL APIs
- Isolate applications using BCEL in sandboxed environments with limited privileges
- Consider disabling or removing BCEL functionality if not essential to application operations
# Maven: Update pom.xml dependency to patched version
# Change version to 6.6.0 or later in your Maven configuration:
# <dependency>
# <groupId>org.apache.bcel</groupId>
# <artifactId>bcel</artifactId>
# <version>6.6.0</version>
# </dependency>
# Fedora: Apply security updates
sudo dnf update bcel --refresh
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

