|
1 | | -### Theory |
2 | | -<h4>Overview of Broken Authentication</h4> |
3 | | -Broken Authentication occurs when an application does not properly manage session or authentication credentials. This can allow an attacker to exploit vulnerabilities in session handling to gain unauthorized access to accounts or functionality, such as an administrative dashboard. |
| 1 | +### Theory |
4 | 2 |
|
| 3 | +#### Overview of Broken Authentication |
| 4 | +**Broken Authentication** occurs when an application fails to correctly implement authentication or session management. This can allow attackers to bypass login mechanisms, hijack sessions, or gain access to sensitive accounts or functionality (like administrative dashboards). |
5 | 5 |
|
6 | | -<li><b>Session Management:</b> Proper handling of session identifiers to ensure they cannot be easily guessed or manipulated.</li> |
7 | | -<li><b>Authentication:</b> Verifying the identity of a user or system to ensure they have access to certain resources or data.</li> |
8 | | -<li><b>Authorization:</b> Determining whether a user has the right to access a particular resource or perform an action.</li> |
| 6 | +Common causes include: |
| 7 | +- Weak or guessable passwords |
| 8 | +- Exposed session IDs |
| 9 | +- Reuse of credentials across multiple accounts |
| 10 | +- Poorly implemented login mechanisms (e.g., no rate limiting) |
9 | 11 |
|
10 | | -<h4>Cookie-Based Authentication</h4> |
11 | | -Cookies are often used to store session information on the client-side. When a user logs into a web application, the server typically creates a session and stores the session ID in a cookie. This cookie is then sent with each request to authenticate and maintain the session. |
| 12 | +##### Key Concepts |
| 13 | +1. **Session Management** |
| 14 | + - Refers to how applications handle user sessions after a successful login. |
| 15 | + - Proper session management ensures that session IDs are unique, randomly generated, expire after inactivity, and are protected from interception or tampering. |
| 16 | + - Example of poor session management: using predictable session IDs like `user123` or `session1`. |
12 | 17 |
|
13 | | -<li><b>Session Cookie:</b> A cookie that stores the session identifier which is used to maintain user state and session between requests.</li> |
14 | | -<li><b>Base64 Encoding:</b> A method to encode binary data into an ASCII string format using a set of 64 printable characters. This is often used for transmitting data in a readable format but does not inherently secure the data.</li> |
| 18 | +2. **Authentication** |
| 19 | + - The process of verifying a user’s identity. |
| 20 | + - Methods include passwords, multi-factor authentication (MFA), and biometric verification. |
| 21 | + - Weak authentication mechanisms make it easier for attackers to impersonate legitimate users. |
| 22 | + |
| 23 | +3. **Authorization** |
| 24 | + - Determines what resources a user can access once authenticated. |
| 25 | + - Broken authorization can allow normal users to perform administrative actions or access confidential data. |
| 26 | + |
| 27 | + |
| 28 | +#### Cookie-Based Authentication |
| 29 | +Cookies are commonly used to manage user sessions in web applications. When a user logs in: |
| 30 | +1. The server creates a session and generates a unique **session ID**. |
| 31 | +2. The session ID is stored in a **cookie** on the client-side. |
| 32 | +3. Every time the client makes a request, the cookie is sent to the server to validate the session. |
| 33 | + |
| 34 | +##### Key Points |
| 35 | +- **Session Cookie** |
| 36 | + - Stores the session ID to maintain continuity between requests. |
| 37 | + - Should be set with secure flags like `HttpOnly` and `Secure` to prevent theft via XSS or network interception. |
| 38 | + |
| 39 | +- **Base64 Encoding** |
| 40 | + - Converts binary data (like session tokens) into ASCII strings for safe transmission. |
| 41 | + - Important: Base64 is *not encryption*—it does not protect sensitive information from attackers. If an attacker captures a Base64-encoded session ID, they can still use it to impersonate the user. |
| 42 | + |
| 43 | + |
| 44 | +#### Additional Considerations |
| 45 | +- **Session Expiration:** Sessions should automatically expire after a certain period of inactivity. |
| 46 | +- **Logout Mechanism:** Users must be able to log out, which should invalidate the session on the server. |
| 47 | +- **MFA Integration:** Using multi-factor authentication adds an extra layer of security, reducing the impact of credential theft. |
| 48 | +- **Monitoring:** Detect suspicious login attempts, unusual session activity, and repeated failed login attempts. |
0 commit comments