What is Broken Authentication? Ways to Exploit, Examples and Impact

Discover how broken authentication works, explore technical exploit examples like session hijacking, and learn how to secure your app against identity attacks.

What is Broken Authentication? Ways to Exploit, Examples and Impact

Authentication is the digital equivalent of a security guard checking IDs at the entrance of a high-security facility. When this process is flawed, unauthorized individuals can bypass security controls, hijack user sessions, and gain access to sensitive data. In this guide, we will explore the technical intricacies of Broken Authentication, how it is exploited, and the steps you can take to secure your infrastructure.

What is Broken Authentication?

Broken Authentication, recently rebranded as "Identification and Authentication Failures" in the OWASP Top 10 (A07:2021), refers to a suite of vulnerabilities that allow attackers to compromise passwords, keys, or session tokens. These flaws occur when an application improperly implements functions related to user identity, allowing attackers to assume the identities of legitimate users.

In a technical sense, authentication is the process of verifying that a user is who they claim to be. This is typically done through something the user knows (password), something they have (token), or something they are (biometrics). If any part of this verification pipeline—from the login page to the session management logic—is weak, the application is vulnerable. Jsmon helps security teams identify these exposed entry points by mapping the external attack surface where authentication endpoints reside.

Common Causes of Broken Authentication

Several factors contribute to authentication failures. Understanding these is the first step toward building a resilient system.

1. Weak Session Management

Session management involves tracking a user's state after they have logged in. If an application uses predictable session IDs or fails to invalidate sessions after logout, an attacker can easily hijack a user's account. For example, if a session ID is simply an incremental integer, an attacker can guess the next ID and impersonate the next user who logs in.

2. Lack of Multi-Factor Authentication (MFA)

In the modern threat landscape, relying solely on a username and password is a significant risk. If an application does not support or enforce MFA, a single leaked credential can lead to a full account takeover.

3. Insecure Password Storage

Storing passwords in plaintext or using weak hashing algorithms like MD5 or SHA1 is a recipe for disaster. If the database is breached, attackers can instantly recover user credentials. Modern standards require salted, slow hashing algorithms like Argon2 or Bcrypt.

How to Exploit Broken Authentication: Technical Examples

Attackers use various techniques to exploit these flaws. Below are technical breakdowns of common exploit vectors.

Credential Stuffing and Brute Forcing

Credential stuffing involves using large lists of leaked usernames and passwords from previous data breaches to gain access to accounts on a different platform. This works because many users reuse passwords across multiple sites.

Below is a conceptual Python snippet illustrating how an attacker might automate a credential stuffing attack against a vulnerable login endpoint:

import requests

url = "https://example.com/api/login"
credentials_list = [("admin", "password123"), ("user1", "qwerty"), ("dev", "admin123")]

for username, password in credentials_list:
    payload = {"user": username, "pass": password}
    response = requests.post(url, json=payload)
    
    if "success" in response.text.lower():
        print(f"[+] Success: {username}:{password}")
    else:
        print(f"[-] Failed: {username}")

Session Hijacking via Predictable Tokens

If an application generates session tokens that follow a pattern, an attacker can perform a brute-force attack on the token itself. Consider a session cookie that looks like this:

Set-Cookie: session_id=user123_1715000000

An attacker can see that the token consists of the username and a Unix timestamp. By iterating through timestamps around the time a user logged in, the attacker can forge a valid session cookie.

Exploiting JWT Misconfigurations

JSON Web Tokens (JWT) are widely used for stateless authentication. However, they are often misconfigured. One classic exploit is the "None" algorithm attack. An attacker modifies the JWT header to specify "alg": "none", effectively telling the server not to verify the signature.

Original Header:

{
  "alg": "HS256",
  "typ": "JWT"
}

Malicious Header:

{
  "alg": "none",
  "typ": "JWT"
}

If the backend library is not configured to explicitly reject the "none" algorithm, the attacker can modify the payload (e.g., changing user_id to admin) and gain unauthorized access.

Real-World Impact of Authentication Failures

The impact of broken authentication is almost always severe. Because authentication is the gateway to user data and administrative functions, a failure here can lead to:

  • Full Account Takeover: Attackers gain complete control over user accounts, leading to identity theft.
  • Data Breaches: Unauthorized access to databases containing sensitive PII (Personally Identifiable Information).
  • Financial Loss: For fintech or e-commerce apps, attackers can drain balances or make unauthorized purchases.
  • Reputational Damage: Users lose trust in a platform that cannot protect their identity.

In many cases, broken authentication serves as the initial foothold for a larger lateral movement within a corporate network. By gaining access to a single employee's account, an attacker can probe internal systems that are not exposed to the public internet.

How to Prevent Broken Authentication

Securing your authentication mechanism requires a multi-layered approach. Here are the technical best practices every developer should follow.

1. Implement Multi-Factor Authentication (MFA)

MFA is the single most effective defense against credential stuffing and brute-force attacks. Even if a password is compromised, the attacker cannot gain access without the second factor (TOTP, SMS, or Hardware Key).

2. Use Secure Session Management

Ensure that session IDs are long, random, and generated using a cryptographically secure random number generator. Always set the following flags on your cookies:

  • HttpOnly: Prevents JavaScript from accessing the cookie, mitigating XSS-based session theft.
  • Secure: Ensures the cookie is only sent over HTTPS.
  • SameSite=Strict: Helps prevent Cross-Site Request Forgery (CSRF).

3. Enforce Strong Password Policies

Require a minimum length (e.g., 12 characters) and check passwords against lists of common/pwned passwords. Use modern hashing algorithms like Argon2 with a high work factor to protect the user database.

4. Implement Rate Limiting and Lockouts

To prevent automated brute-force attacks, implement rate limiting on all authentication endpoints. For example, block an IP address or lock an account after five failed attempts within a minute.

// Simple Express.js rate limiting example
const rateLimit = require("express-rate-limit");

const loginLimiter = rateLimit({
  windowMs: 15 * 60 * 1000, // 15 minutes
  max: 5, // Limit each IP to 5 login requests per window
  message: "Too many login attempts, please try again later."
});

app.post("/api/login", loginLimiter, (req, res) => {
  // Login logic here
});

The Role of Infrastructure Reconnaissance

Broken authentication often hides in forgotten subdomains, staging environments, or legacy APIs that lack the security controls of the main application. Attackers look for these "weak links" in your external attack surface. This is where continuous monitoring becomes essential. By maintaining a real-time inventory of your infrastructure, you can ensure that every login portal and API endpoint adheres to your security standards.

Conclusion

Broken authentication remains a top threat because it targets the most fundamental aspect of web security: identity. Whether through credential stuffing, session hijacking, or misconfigured tokens, the goal of the attacker is always the same—to bypass the gatekeeper. By implementing MFA, securing session cookies, and hardening your password storage, you can significantly reduce your risk profile.

To proactively monitor your organization's external attack surface and catch exposures before attackers do, try Jsmon. Our platform helps you discover unmanaged assets and forgotten endpoints where broken authentication vulnerabilities often hide.