CVE-2021-41766
📋 TL;DR
Apache Karaf's JMX implementation is vulnerable to Java deserialization attacks, allowing remote code execution on affected systems. This affects Apache Karaf installations with JMX enabled, particularly those exposed to untrusted networks. The vulnerability exists because Karaf's JMX server doesn't properly validate serialized objects like the default Java implementation does.
💻 Affected Systems
- Apache Karaf
📦 What is this software?
Karaf by Apache
⚠️ Risk & Real-World Impact
Worst Case
Remote unauthenticated attacker gains full control of the Karaf server and underlying system, potentially leading to data theft, system compromise, or lateral movement within the network.
Likely Case
Attacker with network access to JMX port executes arbitrary code within the Karaf JVM context, potentially compromising the Karaf instance and any deployed applications.
If Mitigated
With proper network segmentation and JMX authentication, impact is limited to authenticated users who could still exploit the vulnerability if they have JMX access.
🎯 Exploit Status
Java deserialization exploits are well-documented and tooling exists. Exploit success depends on available classes in classpath.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Apache Karaf 4.2.15 and 4.3.6
Vendor Advisory: https://karaf.apache.org/security/cve-2021-41766.txt
Restart Required: Yes
Instructions:
1. Download patched version from Apache Karaf website. 2. Backup current installation. 3. Stop Karaf instance. 4. Replace with patched version. 5. Restart Karaf instance.
🔧 Temporary Workarounds
Disable JMX
allDisable JMX completely to prevent exploitation
Edit etc/org.apache.karaf.management.cfg and set rmiRegistryPort = 0
Edit etc/org.apache.karaf.management.cfg and set rmiServerPort = 0
Enable JMX Authentication
allConfigure JMX authentication to require credentials
Edit etc/org.apache.karaf.management.cfg and set jmxAuthenticator = jaas
Configure JAAS realm in etc/org.apache.karaf.jaas.cfg
🧯 If You Can't Patch
- Restrict network access to JMX port (default 1099) using firewall rules
- Implement network segmentation to isolate Karaf instances from untrusted networks
🔍 How to Verify
Check if Vulnerable:
Check Karaf version: if version < 4.2.15 (for 4.2.x) or < 4.3.6 (for 4.3.x) and JMX is enabled, system is vulnerable
Check Version:
karaf version
Verify Fix Applied:
Verify Karaf version is >= 4.2.15 or >= 4.3.6 and check JMX configuration
📡 Detection & Monitoring
Log Indicators:
- Unexpected deserialization errors in Karaf logs
- Unusual JMX connections from unknown sources
- Stack traces containing deserialization-related classes
Network Indicators:
- Unusual traffic to JMX port (default 1099)
- Java RMI protocol anomalies
- Serialized object payloads in network traffic
SIEM Query:
source="karaf.log" AND ("deserialization" OR "ClassNotFoundException" OR "InvalidClassException")