-
Notifications
You must be signed in to change notification settings - Fork 437
Description
Overview
Our project currently uses Apache Commons Lang 2.x, which has an active CVE reported against the ClassUtils.getClass() API. This vulnerability exposes the project to potential security risks related to uncontrolled or unsafe class loading. To ensure the security posture of the application, we aim to upgrade to Apache Commons Lang 3.x, where these issues have been addressed.
However, this migration is not straightforward, as Commons Lang 3 introduces major breaking changes, including package restructures (org.apache.commons.lang → org.apache.commons.lang3), method deprecations, behavioral changes, and API incompatibility.
This task involves refactoring the codebase to support Commons Lang 3.x while ensuring functional parity.
Current version: Apache Commons Lang 2.x
Vulnerable API: ClassUtils.getClass()
Reported issue: Vulnerability in class-loading mechanism within Lang 2.x
Required action: Upgrade dependency to Lang 3.x
🛑 Why Direct Upgrade Is Not Possible
Apache Commons Lang 3 is not a drop-in replacement. Key differences:
- Package Structure Changes
Old: org.apache.commons.lang.*
New: org.apache.commons.lang3.*
This requires updating import statements across the entire codebase.
2. API Changes and Removals
Certain APIs have been:
Renamed
Moved
Behaviorally changed
Removed entirely
Example:
ClassUtils.getClass() in Lang 2.x has different overloads and exception handling behavior in Lang 3.x.
3. Utility Classes Restructured
Some utilities have been:
Split into specialized classes
Modified to avoid ambiguous or unsafe functionality
🎯 Goal of This Task
Refactor the project to fully support Apache Commons Lang 3.x while preserving all current functionality and ensuring compatibility.
🧩 Scope of Work
A contributor picking up this task will need to:
-
Upgrade Dependency
Modify build files (Maven/Gradle/etc.) to use:
org.apache.commons:commons-lang3 -
Update All Import Statements
Replace all:
org.apache.commons.lang.*
with:
org.apache.commons.lang3.*
- Refactor Code for API Differences
Review and update incompatible APIs, including:
ClassUtils
StringUtils
ObjectUtils
ArrayUtils
NumberUtils
Any deprecated/unavailable methods
Document changes in code comments where behavior is not identical.
4. Replace or Rewrite Unsafe Patterns
Especially those involving:
Reflection
Class loading
Serialization utilities
- Add Unit Tests for Affected Areas
Ensure existing behavior is preserved by:
Running all existing tests
Adding new tests where API changes affect logic
- Perform End‑to‑End Validation
Verify application startup, runtime flows, and integration points.
📝 Acceptance Criteria
A successful contribution must meet all the following:
Project builds successfully with Apache Commons Lang 3.x
All imports updated to org.apache.commons.lang3
All incompatible APIs refactored with equivalent logic
No regressions in behavior (validated through tests)
Build passes all unit and integration tests
No usage of deprecated or unsafe reflection methods
Documentation updated for:
Migration notes
API differences encountered
Any non-trivial refactoring
Issue Priority
Priority: 2
Issue Component
Component: Other