hacktricks/pentesting-web/2fa-bypass.md

146 lines
6.9 KiB
Markdown
Raw Normal View History

# 2FA/OTP Bypass
2022-04-28 16:01:33 +00:00
<details>
2023-12-31 01:24:39 +00:00
<summary><strong>Learn AWS hacking from zero to hero with</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2023-12-31 01:24:39 +00:00
Other ways to support HackTricks:
* If you want to see your **company advertised in HackTricks** or **download HackTricks in PDF** Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
2023-12-31 01:24:39 +00:00
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
2024-02-09 07:15:24 +00:00
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
2023-12-31 01:24:39 +00:00
* **Share your hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>
2024-02-06 03:10:38 +00:00
## **Enhanced Two-Factor Authentication Bypass Techniques**
2022-04-28 16:01:33 +00:00
2024-02-06 03:10:38 +00:00
### **Direct Endpoint Access**
2024-02-06 03:10:38 +00:00
To bypass 2FA, access the subsequent endpoint directly, knowing the path is crucial. If unsuccessful, alter the **Referrer header** to mimic navigation from the 2FA verification page.
2024-02-06 03:10:38 +00:00
### **Token Reuse**
2024-02-06 03:10:38 +00:00
Reutilizing previously used tokens for authentication within an account can be effective.
2024-02-06 03:10:38 +00:00
### **Utilization of Unused Tokens**
2024-02-06 03:10:38 +00:00
Extracting a token from one's own account to bypass 2FA in another account can be attempted.
2024-02-06 03:10:38 +00:00
### **Exposure of Token**
2024-02-06 03:10:38 +00:00
Investigate whether the token is disclosed in a response from the web application.
2024-02-06 03:10:38 +00:00
### **Verification Link Exploitation**
2024-02-06 03:10:38 +00:00
Using the **email verification link sent upon account creation** can allow profile access without 2FA, as highlighted in a detailed [post](https://srahulceh.medium.com/behind-the-scenes-of-a-security-bug-the-perils-of-2fa-cookie-generation-496d9519771b).
2024-02-06 03:10:38 +00:00
### **Session Manipulation**
2024-02-06 03:10:38 +00:00
Initiating sessions for both the user's and a victim's account, and completing 2FA for the user's account without proceeding, allows an attempt to access the next step in the victim's account flow, exploiting backend session management limitations.
2024-02-06 03:10:38 +00:00
### **Password Reset Mechanism**
2024-02-06 03:10:38 +00:00
Investigating the password reset function, which logs a user into the application post-reset, for its potential to allow multiple resets using the same link is crucial. Logging in with the newly reset credentials might bypass 2FA.
2024-02-06 03:10:38 +00:00
### **OAuth Platform Compromise**
2024-02-06 03:10:38 +00:00
Compromising a user's account on a trusted **OAuth** platform (e.g., Google, Facebook) can offer a route to bypass 2FA.
2024-02-06 03:10:38 +00:00
### **Brute Force Attacks**
2024-02-06 03:10:38 +00:00
#### **Rate Limit Absence**
2024-02-06 03:10:38 +00:00
The lack of a limit on the number of code attempts allows for brute force attacks, though potential silent rate limiting should be considered.
2024-02-06 03:10:38 +00:00
#### **Slow Brute Force**
2024-02-06 03:10:38 +00:00
A slow brute force attack is viable where flow rate limits exist without an overarching rate limit.
2024-02-06 03:10:38 +00:00
#### **Code Resend Limit Reset**
2024-02-06 03:10:38 +00:00
Resending the code resets the rate limit, facilitating continued brute force attempts.
2024-02-06 03:10:38 +00:00
#### **Client-Side Rate Limit Circumvention**
2024-02-06 03:10:38 +00:00
A document details techniques for bypassing client-side rate limiting.
2024-02-06 03:10:38 +00:00
#### **Internal Actions Lack Rate Limit**
2024-02-06 03:10:38 +00:00
Rate limits may protect login attempts but not internal account actions.
2024-02-06 03:10:38 +00:00
#### **SMS Code Resend Costs**
2024-02-06 03:10:38 +00:00
Excessive resending of codes via SMS incurs costs to the company, though it does not bypass 2FA.
2024-02-06 03:10:38 +00:00
#### **Infinite OTP Regeneration**
2024-02-06 03:10:38 +00:00
Endless OTP generation with simple codes allows brute force by retrying a small set of codes.
2024-02-06 03:10:38 +00:00
### **Race Condition Exploitation**
2024-02-06 03:10:38 +00:00
Exploiting race conditions for 2FA bypass can be found in a specific document.
2024-02-06 03:10:38 +00:00
### **CSRF/Clickjacking Vulnerabilities**
2024-02-06 03:10:38 +00:00
Exploring CSRF or Clickjacking vulnerabilities to disable 2FA is a viable strategy.
2024-02-06 03:10:38 +00:00
### **"Remember Me" Feature Exploits**
2024-02-06 03:10:38 +00:00
#### **Predictable Cookie Values**
2024-02-06 03:10:38 +00:00
Guessing the "remember me" cookie value can bypass restrictions.
2024-02-06 03:10:38 +00:00
#### **IP Address Impersonation**
2024-02-06 03:10:38 +00:00
Impersonating the victim's IP address through the **X-Forwarded-For** header can bypass restrictions.
2024-02-06 03:10:38 +00:00
### **Utilizing Older Versions**
2024-02-06 03:10:38 +00:00
#### **Subdomains**
2024-02-06 03:10:38 +00:00
Testing subdomains may use outdated versions lacking 2FA support or contain vulnerable 2FA implementations.
2024-02-06 03:10:38 +00:00
#### **API Endpoints**
2024-02-06 03:10:38 +00:00
Older API versions, indicated by /v\*/ directory paths, may be vulnerable to 2FA bypass methods.
2024-02-06 03:10:38 +00:00
### **Handling of Previous Sessions**
2024-02-06 03:10:38 +00:00
Terminating existing sessions upon 2FA activation secures accounts against unauthorized access from compromised sessions.
2024-02-06 03:10:38 +00:00
### **Access Control Flaws with Backup Codes**
2024-02-06 03:10:38 +00:00
Immediate generation and potential unauthorized retrieval of backup codes upon 2FA activation, especially with CORS misconfigurations/XSS vulnerabilities, poses a risk.
2024-02-06 03:10:38 +00:00
### **Information Disclosure on 2FA Page**
2024-02-06 03:10:38 +00:00
Sensitive information disclosure (e.g., phone number) on the 2FA verification page is a concern.
2024-02-06 03:10:38 +00:00
### **Password Reset Disabling 2FA**
2024-02-06 03:10:38 +00:00
A process demonstrating a potential bypass method involves account creation, 2FA activation, password reset, and subsequent login without the 2FA requirement.
2024-02-06 03:10:38 +00:00
### **Decoy Requests**
2021-10-07 09:43:36 +00:00
2024-02-06 03:10:38 +00:00
Utilizing decoy requests to obfuscate brute force attempts or mislead rate limiting mechanisms adds another layer to bypass strategies. Crafting such requests requires a nuanced understanding of the application's security measures and rate limiting behaviors.
## References
2024-02-06 03:10:38 +00:00
* [https://medium.com/@iSecMax/two-factor-authentication-security-testing-and-possible-bypasses-f65650412b35]("https://medium.com/@iSecMax/two-factor-authentication-security-testing-and-possible-bypasses-f65650412b35")
* [https://azwi.medium.com/2-factor-authentication-bypass-3b2bbd907718](https://azwi.medium.com/2-factor-authentication-bypass-3b2bbd907718)
2022-04-28 16:01:33 +00:00
<details>
2023-12-31 01:24:39 +00:00
<summary><strong>Learn AWS hacking from zero to hero with</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2023-12-31 01:24:39 +00:00
Other ways to support HackTricks:
* If you want to see your **company advertised in HackTricks** or **download HackTricks in PDF** Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
2023-12-31 01:24:39 +00:00
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
2024-02-09 07:15:24 +00:00
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
2023-12-31 01:24:39 +00:00
* **Share your hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>