Apache Kafka 反序列化漏洞分析

Apache Kafka 反序列化漏洞分析

1.背景概述

Apache Kafka 是用于构建实时数据流水线和流媒体的应用服务。它具有水平可扩展性,容错性,目前有数千家公司使用其产品。

2017 年 7 月 19 日曝出,Apache kafka connect-api,在执行 FileOffsetBackingStore 类可实现一个反序列化漏洞,这将导致远程代码执行。

其代码开源于 Apache 官方 Github:https://github.com/apache/kafka/

2.原理分析

2.1漏洞简析

Apache Kafka 0.11.0.0 中,org.apache.kafka.connect.storage.FileOffsetBackingStore 这个 class 主要实现了将数据保存到本地文件功能。同时也提供了一个反序列化接口。

查看 FileOffsetBackingStore.java 源码:

这里写图片描述

通过 configure(WorkerConfig config) 函数读取文件

这里写图片描述

随后文件在 load() 函数利用 ObjectInputStream 类加载,随后调用 readObject() 方法进行反序列化。

发现 FileOffsetBackingStore 在反序列化过程中,直接调用了 java.io.ObjectInputStream 类的 readObject() 方法,没有对传入参数进行验证。这将允许攻击者构造反序列化对象并执行恶意代码。

2.2漏洞复现

对于此类反序列化漏洞的利用方式有很多,可以先使用较简单的方式复现,以便分析:

首先,查阅Java官方文档

发现对于 readObject()方法有以下描述:

Read an object from the ObjectInputStream. The class of the object, the signature of the class, and the values of the non-transient and non-static fields of the class and all of its supertypes are read. Default deserializing for a class can be overriden using the writeObject and readObject methods. Objects referenced by this object are read transitively so that a complete equivalent graph of objects is reconstructed by readObject.

The root object is completely restored when all of its fields and the objects it references are completely restored. At this point the object validation callbacks are executed in order based on their registered priorities. The callbacks are registered by objects (in the readObject special methods) as they ar

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值