# [Kafka Connect] [JdbcSinkConnector][HttpSinkConnector] RCE by leveraging file upload via SQLite JDBC driver and SSRF to internal Jolokia

SQLite JDBC driver file upload plus HTTP sink SSRF to localhost Jolokia jvmtiAgentLoad executed an embedded JVM agent JAR from a SQLite BLOB, yielding RCE on Kafka Connect.

- Payout: $5,000
- Severity: critical
- Program: Aiven Ltd
- Found by: jarij
- Disclosed: 2022-11-08
- Write-up quality: 9/10
- Original: https://hackerone.com/reports/1547877
- Library page: https://bugbountylibrary.com/r/h1%3A1547877
- Tags: area:cloud domain:cloud domain:infra impact:internal-access impact:rce kind:bounty platform:hackerone sev:critical tech:java tech:linux technique:chained vuln:file-upload vuln:rce vuln:ssrf

**Target:** Aiven for Apache Kafka managed service (Kafka Connect JDBC/HTTP sink connectors, Jolokia on localhost:6725)
**Root cause:** JDBC sink connector bundles SQLite JDBC driver allowing arbitrary file upload to server, and HTTP sink connector permits requests to localhost where unprotected Jolokia exposes DiagnosticCommand MBean with jvmtiAgentLoad.
**Steps:**
1. Deploy JDBC sink connector using SQLite JDBC driver to write a crafted SQLite DB file containing a JVM agent JAR as a BLOB field onto the server filesystem.
2. Deploy HTTP sink connector configured to send requests to `http://localhost:6725` (Jolokia).
3. POST to Jolokia `/exec/com.sun.management:type=DiagnosticCommand/jvmtiAgentLoad` with the path to the uploaded SQLite file as the agent argument.
4. JVM loads the embedded agent JAR from the SQLite BLOB, executing attacker code.
5. Agent opens reverse shell to attacker `nc -nlvp 4446` listener.
**How found:** Recognized SQLite JDBC driver enables file writes, noticed HTTP sink can reach localhost, discovered unprotected Jolokia on port 6725 exposing DiagnosticCommand MBean, and identified jvmtiAgentLoad as an agent-loading primitive; combined by embedding agent JAR in SQLite BLOB.
**Exploitation:** Attacker with connector-creation rights uploads a SQLite DB containing a JVM agent JAR via JDBC sink, then uses HTTP sink SSRF to reach localhost Jolokia and invoke jvmtiAgentLoad pointing at the uploaded file, achieving code execution and reverse shell on the Kafka Connect server.
**Escalation:** Chained two connector features (file upload + SSRF) to reach an internal-only Jolokia endpoint and abuse a JMX MBean operation for RCE.
**Insight:** When a managed service lets you pick JDBC drivers and sink connectors, treat driver file-write capabilities and localhost SSRF as a combined primitive; internal Jolokia/JMX DiagnosticCommand MBeans (jvmtiAgentLoad) are a reliable RCE sink reachable only via SSRF.

