问答
发起
提问
文章
攻防
活动
Toggle navigation
首页
(current)
问答
商城
实战攻防技术
漏洞分析与复现
NEW
活动
摸鱼办
搜索
登录
注册
Apache HertzBeat反序列化
漏洞分析
Apache HertzBeat 是开源的实时监控工具,受影响版本中未对用户可控的 Yaml 文件有效过滤,经过身份验证的攻击者可构造恶意 Yaml 文件远程执行任意代码。
### 简介 [Apache HertzBeat](https://gitee.com/link?target=https%3A%2F%2Fgithub.com%2Fapache%2Fhertzbeat) (incubating)是一个易用友好的开源实时监控告警系统,无需 Agent,高性能集群,兼容 Prometheus,提供强大的自定义监控和状态页构建能力。 ### 漏洞描述 Apache HertzBeat 是开源的实时监控工具。受影响版本中由于使用漏洞版本的 SnakeYAML v1.32解析用户可控的 yaml 文件,经过身份验证的攻击者可通过 /api/monitors/import、/api/alert/defines/import 接口新增监控类型时配置恶意的 yaml 脚本远程执行任意代码。 ### 影响版本 1.6.0版本之前 ### 环境搭建 下载源码:<https://github.com/apache/hertzbeat/archive/refs/tags/v1.4.4.zip> 环境要求: 后端:maven3+, java17, lombok 前端:nodejs npm angular-cli 解压之后找到manager目录下的Manager启动后端代码:  启动前端: 在web-app目录下安装依赖  运行ng serve --open 启动前端页面  访问:<http://localhost:4200/dashboard>,默认密码admin/hertzbeat  ### 漏洞分析 首先看/api/monitors/import接口,定位到MonitorsController#export,调用MonitorService#importConfig方法处理传入的文件  调用MonitorServiceImpl#importConfig处理文件,根据文件名后缀,判断文件类型,根据不同的文件类型调用不同的函数处理。如果上传yaml格式的文件,则获取YamlImExportServiceImpl的type,然后根据type获取imExportServiceMap中对应的imExportService  那么imExportServiceMap是在哪赋值的?追溯可以发现是构造函数初始化了imExportServiceMap,将 imExportServiceList 中的每个服务按照其类型存入imExportServiceMap中。  在Spring 中会自动扫描并注入所有实现了 ImExportService 接口的 Bean 并将其作为参数传递给构造函数。这样imExportServiceMap 会在 Bean 初始化时自动填充,查看所有实现ImExportService 的接口:  接着调用imExportService.importConfig方法,此时imExportService为YamlImExportServiceImpl,并且YamlImExportServiceImpl继承AbstractImExportServiceImpl类  所以查看AbstractImExportServiceImpl#importConfig方法,在该方法中调用parseImport方法处理上传的文件  跟进到YamlImExportServiceImpl#parseImport方法,经典的SnakeYaml反序列。  查看组件版本也是符合反序列化条件的  ### 漏洞复现 访问<http://localhost:4200/>,admin/hertzbeat登录后台,选择任何监控点击导入监控  修改上传yaml文件中的value值:  成功执行代码  ### 参考 <https://github.com/apache/hertzbeat/commit/88a843612d0702bd82729526aa28d784874c37c9#diff-8e8715de7d4daf4470f78dbaf8eaf67ad803ddd7c74ccfadfe6b1d799ff8721bR96>
发表于 2024-10-23 10:00:01
阅读 ( 7933 )
分类:
Web应用
1 推荐
收藏
0 条评论
请先
登录
后评论
买橘子
3 篇文章
×
发送私信
请先
登录
后发送私信
×
举报此文章
垃圾广告信息:
广告、推广、测试等内容
违规内容:
色情、暴力、血腥、敏感信息等内容
不友善内容:
人身攻击、挑衅辱骂、恶意行为
其他原因:
请补充说明
举报原因:
×
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!