赏金猎人系列-如何测试sso相关的漏洞

admin 2022年10月25日08:45:37评论64 views字数 2481阅读8分16秒阅读模式

赏金猎人系列-如何测试sso相关的漏洞

声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由用户承担全部法律及连带责任,文章作者不承担任何法律及连带责任。

前言

前面写过一篇有关sso绕过的相关文章:你所不知道的sso绕过tips,而本文主要总结的是sso漏洞相对比较系统的的测试方法,限于篇幅,这里会分为两篇来叙述,今天为第一篇;

正文

第一种情况

SSO 重定向可能具有欺骗性,在重定向之前尝试扫描 SSO 接口:

如果子域名(eg:internal.company.com )重定向至SSO(eg:auth.company.com ).请尝试模糊测试:

例如:

root@mine:~#ffuf -w wordlist.txt -u https://www.company.com/FUZZ -fc 302,404

在bugcrowd上面的P1级别的漏洞:(考虑删除???)

https://host =>403 forbidden

https://host/app =>Redirect to corporate SSO

https://host/app/main.js =>IP:8005 和 Api_key

https://IP:8005/ => https://IP:8005/swagger/ui/index#/Admin

Use key in swagger=> 信息泄露

第二种情况

如果子域名(eg:internal.company.com )重定向至SSO(eg:auth.company.com ).请尝试暴力破解:

例如: sub.domain.../sub/fuzz

GET /internal/FUZZ HTTP/1.1 
Host: internal.company.com
User-Agent: Mozilla/5.0
Referer: https://previous.com/path
Origin: https://internal.company.com

第三种情况

如果company.com/internal重定向到SSO,比如:谷歌登录,尝试在internal之前插入public,例如company.com/public/internal获得访问内部的权限

测试步骤:

 company.com/internal  重定向至  Google登陆

利用public来实现破解绕过:

company.com/public/internal

第四种情况

在Burp Suite中安装SAMLRaider这个插件:

测试步骤:

1.安装SAMLRaider

2.打开你的终端

3.输入以下命令产生 X.509 Certificate

openssl req -x509 -newkey rsa:4096 -keyout /tmp/key.pem -out cert.pem -days 365 -nodes

4.将cert.pem导入至SAML Raider插件

5.保存然后自行登陆

第五种情况

尝试用令牌制作SAML请求并将其发送到服务器,并弄清楚服务器如何与之交互

测试步骤:

1.利用令牌创建在文件中的SAML请求,例如File.xml

2.创建一个Bash脚本,这里设为pwn.sh

#!/bin/sh
xml=`base64 file.xml`
curl -v 'https://www.company.com/sso' --data "RelayState=/path"
--data-urlencode "SAMLResponse=$xml"

3.打开打开你的终端

4.输入命令:

Chmod +x pwn.sh && ./pwn.sh

第六种情况

如果在令牌请求中有AssertionConsumerServiceURL,请尝试插入域名,例如http://me.com作为值来窃取令牌

测试步骤:

1.使用Burp Suite来拦截SAML 请求

2.发现存在 AssertionConsumerServiceURL

3.有参数接受URL作为值

4.插 http://me.com作为值

第七种情况

如果令牌请求中有AssertionConsumerServiceURL,尝试对AssertionConsumerServiceURL的值做模糊测试(如果它与Origin不类似)

测试步骤:

1.使用Burp Suite来拦截SAML 请求

2.发现存在 AssertionConsumerServiceURL

3.假设你的源请求是 auth.comapny.com,但是AssertionConsumerServiceURL的值是internal.company.com

4.尝试在internal.company.com上面做模糊测试

root@mine:~#ffuf -w wordlist.txt -u https://www.company.com/FUZZ -fc 302,404

参考

https://epi052.gitlab.io/notes-to-self/blog/2019-03-13-how-to-test-saml-a-methodology-part-two/

https://github.com/CompassSecurity/SAMLRaider

https://mishresec.wordpress.com/2017/10/13/uber-bug-bounty-gaining-access-to-an-internal-chat-system/

https://web.archive.org/web/20170910200953/http://www.economyofmechanism.com/

https://web-in-security.blogspot.com/2015/04/on-security-of-saml-based-identity.html

https://blog.fadyothman.com/how-i-discovered-xss-that-affects-over-20-uber-subdomains/


原文始发于微信公众号(迪哥讲事):赏金猎人系列-如何测试sso相关的漏洞

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年10月25日08:45:37
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   赏金猎人系列-如何测试sso相关的漏洞https://cn-sec.com/archives/1369948.html

发表评论

匿名网友 填写信息