(English) 🚨 2FA Bypass | How Attackers Still Break Multi-Factor Authentication 🔓🔐
Overview of common 2FA bypass techniques, including flawed verification logic, clickjacking on 2FA disable functionality, and response manipulation.
2FA BYPASS
Bypassing two-factor authentication
[] Flawed two-factor verification logic
Sometimes flawed logic in two-factor authentication means that after a user has completed the initial login step, the website does not adequately verify that the same user is completing the second step.
For example, the user logs in with their normal credentials in the first step:
1
2
3
4
POST /login-steps/first HTTP/1.1
Host: vulnerable-website.com
...
username=carlos&password=qwerty
They are then assigned a cookie that relates to their account, before being taken to the second step of the login process:
1
2
3
4
5
HTTP/1.1 200 OK
Set-Cookie: account=carlos
GET /login-steps/second HTTP/1.1
Cookie: account=carlos
When submitting the verification code, the request uses this cookie to determine which account the user is trying to access:
1
2
3
4
5
POST /login-steps/second HTTP/1.1
Host: vulnerable-website.com
Cookie: account=carlos
...
verification-code=123456
In this case, an attacker could log in using their own credentials but then change the value of the account cookie to any arbitrary username when submitting the verification code.
1
2
3
4
5
POST /login-steps/second HTTP/1.1
Host: vulnerable-website.com
Cookie: account=victim-user
...
verification-code=123456
[] Clickjacking on 2FA Disable Feature
- Try to iframe the page where the application allows a user to disable 2FA.
- If iframe is successful, try to perform a social engineering attack to manipulate victim to click.
[] Response Manipulation
- Check response of the 2FA request.
- If you observe
"Success": false. - Change this to
"Success": trueand see if it bypasses the 2FA.
[] Status Code Manipulation
- If the Response Status Code is 4XX like 401, 402, etc.
- Change the Response Status Code to “200 OK” and see if it bypasses the 2FA
[] 2FA Code Reusability
- Request a 2FA code and use it
- Now, Re-use the 2FA code and if it is used successfully that’s an issue
- Also, try requesting multiple 2FA codes and see if previously requested codes expire or not when a new one is generated. (Only the latest code should be valid; older ones should be invalidated.)
- Also, try to re-use the previously used code after a long time duration, say 1 day or more. That code should already be expired and must not be accepted.
[] CSRF on 2FA Disable Feature
- Request a 2FA code and use it
- Now, Re-use the 2FA code and if it is used successfully that’s an issue 3.Also, try requesting multiple 2FA codes and see if previously requested codes expire or not when a new code is requested 4.Also, try to re-use the previously used code after long time duration (say 1 day or more). That will be a potential issue as 1 day is enough duration to crack and guess a 6-digit 2FA code
[] Backup Code Abuse
Apply same techniques used on 2FA such as Response/Status Code Manipulation, Brute-force, etc. to bypass Backup Codes and disable/reset 2FA
[] Enabling 2FA Doesn’t Expire Previous Session
- Login to the application in two different browsers and enable 2FA from 1st session
- Use 2nd session and if it is not expired, it could be an issue if there is an insufficient session expiration issue. In this scenario if an attacker hijacks an active session before 2FA, it is possible to carry out all functions without a need for 2FA
[] 2FA Refer Check Bypass
- Directly navigate to the page which comes after 2FA or any other authenticated page of the application
- If there is no success, change the refer header to the 2FA page URL. This may fool application to pretend as if the request came after satisfying 2FA condition
[] 2FA Code Leakage in Response
- At 2FA Code Triggering Request, such as Send OTP functionality, capture the Request
- See the Response of this request and analyze if the 2FA Code is leaked
[] JS File Analysis
- While triggering the 2FA Code Request
- Analyze all the JS Files that are referred in the Response
