漏洞介绍
Apache APISIX Dashboard是一个用于管理Apache APISIX的前端面板。CVE-2021-45232是一个身份验证绕过漏洞,攻击者可以在未授权的情况下访问某些API接口,从而导出或导入配置,甚至执行远程代码。
漏洞范围
2.7.0 < APISIX Dashboard< 2.10.1
漏洞靶场
使用vulhub的靶场:
vulhub-master/apisix/CVE-2021-45232
1 | docker-compose up -d |
漏洞原理
Apache APISIX Dashboard github 地址
https://github.com/apache/apisix-dashboard
找到commits 进行查看
https://github.com/apache/apisix-dashboard/commits/master

更新了如下代码
具体参考:

api/internal/filter/authentication.go#L48-L54
以/apisix开头的URL,除了/apisix/admin/tool/version和/apisix/admin/user/login以外均需要认证,通过判断HTTP Header中的Authorization来完成鉴权处理
打开路由表:
1 | func SetUpRouter() *gin.Engine { |
api/internal/route.go#L52-L97
注册了如上的这些路由
授权中间件是在droplet中注册的 而导入导出的路由没有用wgin.Wraps()函数转换为droplet的路由函数

未授权的没用wgin.Wraps()进行二次包装转换
通过全局搜索r.GET

发现两个未授权的接口
1 | r.GET("/apisix/admin/migrate/export", h.ExportConfig) |
首先访问一下。这两个接口

首先看看代码导出api/internal/handler/migrate/migrate.go
1 | func (h *Handler) ExportConfig(c *gin.Context) { |
最终返回的是所有信息的结构体
1 | func newDataSet() *DataSet { |
再看看导入:
1 | func (h *Handler) ImportConfig(c *gin.Context) { |
先确定一下mode的模式。这里是分三种模式的
1 | var modeMap = map[string]migrate.ConflictMode{ |
api/internal/handler/migrate/migrate.go#L52-L133
然后是取最后的4位看看是和前面的计算出来的值是否相等。如果相等 就根据模式的不同的对 上面的那个全局的一个配置结构体进行修改
1 | func Import(ctx context.Context, data []byte, mode ConflictMode) (*DataSet, error) { |
api/internal/core/migrate/migrate.go#L63-L99
漏洞复现
访问http://127.0.0.1:9080/进入靶场页面

exp使用
https://github.com/wuppp/apisix_dashboard_rce下载exp
1 | python apisix_dashboard_rce.py http://127.0.0.1:9000 |

burp抓取页面的数据包,并修改路径为工具返回出来的


成功执行命令
参考
https://blog.csdn.net/2301_78721909/article/details/145891066
https://blog.csdn.net/weixin_44411509/article/details/122292459