Koding Siber Logo
Koding Siber
Academy CatalogAPI SecurityAuthentication and Token Security
Intermediate Level40 minsFree Preview Module
Category: Authentication and Token Security

Broken Authentication

Learn about authentication weaknesses specific to API implementations.

EXPLORERINTERACTIVE
Broken Authentication
HTTP
INFO:GET /api/v2/customers/1092/private_records [Auth: Bob]
API Consumer (Bob)(192.168.1.10)
Legitimate authenticated mobile client or developer terminal. Possesses a valid JWT token for User Bob, but tampers with URI IDs to request other users' records.
SIMULATION CONTROLSStep 1 of 5
Simulation Speed:
Simulation paused (click Play Flow or Next Step)
STEP 1 OF 5

TAMPER OBJECT IDENTIFIER

Client substitutes foreign resource ID

User 'Bob' observes legitimate endpoint structure and tampers with the object ID parameter, requesting data belonging to User 'Alice' to test for Broken Authentication.

Payload / Code Inspector
GET /api/v2/customers/1092/private_records HTTP/1.1
Host: api.gateway.corp
Authorization: Bearer <Bob_Valid_JWT>
Defensive Mitigation
Implement object-level access control checks (validating that req.user.id === record.ownerId) on every single resource retrieval and update.

PACKET FLOW (WIRESHARK INSPECTOR)

Click any row to jump to step
NO.TIMESOURCEDESTINATIONPROTOCOLINFOSIZE
10.000s192.168.1.10api.gateway.corpHTTPGET /api/v2/customers/1092/private_records [Auth: Bob]162 B
20.015sapi.gateway.corp10.0.1.25JSONRPC: Forwarding request to Account Microservice198 B
30.028s10.0.1.2510.0.2.90SQLQUERY: SELECT * FROM customers WHERE id = 1092174 B
40.041s10.0.2.9010.0.1.25SQLDATA: [id=1092, owner=Alice, balance=$92k]270 B
50.056s10.0.1.25192.168.1.10HTTPHTTP/1.1 200 OK [Alice's Confidential Data returned to Bob]356 B
Payload Inspector
STEP 1
API Consumer (Bob)➔API Gateway
HTTP
Transmitted Data
162 B
GET /api/v2/customers/1092/private_records HTTP/1.1
Host: api.gateway.corp
Authorization: Bearer <Bob_Valid_JWT>
Client substitutes foreign resource IDINSPECTED
Vulnerability Overview

What is Broken Authentication?

Learn about authentication weaknesses specific to API implementations.
Impact
Accounts can be compromised through credential stuffing, password guessing or default accounts.
Severity
HIGH
Technical Mechanism & Code Flaw

Root Cause Analysis

The vulnerability exists because user-controlled data is interpreted as commands or code rather than plain data.
Vulnerable Implementation (Anti-Pattern)UNSAFE
// BAD: Untrusted execution or unhardened configuration
const config = { debug: true, allowUnauthenticated: true };
app.use('/api', createService(config));
Secure Implementation (Hardened)SECURED

// GOOD: Strict hardening and defense-in-depth
const config = { debug: false, allowUnauthenticated: false, authRequired: true };
app.use('/api', authenticate, createService(config));
Detection & Penetration Testing Methodology

Detection & Penetration Testing Methodology

Broken Authentication covers a cluster of related weaknesses: the platform still uses default vendor credentials nobody changed, the login endpoint has no meaningful limit on failed attempts, and/or the password policy is weak enough that common passwords succeed. Any one of these alone can be enough for an attacker to get in without needing any other vulnerability at all.

Tools Used in This Manual

Tool Purpose
Nmap + http-default-accounts script Automatically detects and tests default credentials for known platforms
WPScan WordPress-specific default creds, user enumeration, weak password checks
Hydra Rate-limited brute force / credential stuffing
Burp Suite Intruder Visual, controlled brute force with built-in throttling and response analysis
ffuf Fast, flexible login testing with filtering on response size/status/time
Pwned Passwords API (via curl, one-liner) Breached password policy checks

Step 1 -- Default and Vendor Credentials

Goal: Let a tool fingerprint the platform and automatically try its known default credentials -- no manual list-building needed.

1.1 Fingerprint + test default creds in one pass (Nmap)

nmap -p 80,443,8080,8443 --script http-default-accounts target.com

This script already ships with a database of default credentials for dozens of platforms (Tomcat, Jenkins, phpMyAdmin, routers, etc.) and reports which ones worked -- no need to maintain your own list.

1.2 WordPress-specific (if the site is WordPress)

wpscan --url https://target.com --enumerate u --plugins-detection aggressive

Then test discovered usernames against common passwords in the same tool:

wpscan --url https://target.com --usernames discovered_users.txt --passwords /usr/share/wordlists/rockyou.txt --max-threads 1

1.3 General CMS/platform identification (if not WordPress)

whatweb https://target.com

This tells you exactly what platform/CMS/framework is running, so you know which default-credential database applies -- feed that into Nmap's script library or a platform-specific scanner (e.g. droopescan for Drupal/Joomla/SilverStripe).

Step 2 -- Lockout / CAPTCHA / Delay Detection

Goal: Use Burp Suite Intruder instead of a manual loop -- it already handles sending repeated requests, shows response time/length/status per attempt in a sortable table, and lets you visually spot when something changes.

2.1 Capture the login request in Burp

Log in once with a wrong password, let Burp's proxy capture it, then send it to Intruder.

2.2 Set up the attack

Mark the password field value as the injection point (highlight it, click "Add §")

Attack type: Sniper

Payload list: a short list of ~15-20 dummy passwords (WrongPass1, WrongPass2, ... -- the actual values don't matter here, you're testing the response pattern, not guessing a real password)

2.3 Add a delay/throttle in Intruder's resource pool settings

Under Resource Pool, set "Maximum concurrent requests" to 1 and add a delay (e.g. 1000ms) between requests -- this keeps the test controlled rather than hammering the server.

2.4 Run it and read the results table

Burp's Intruder results grid shows, per attempt: HTTP status, response length, and response time -- all in one sortable view. Look for:

Response length changing (a CAPTCHA or lockout message is usually a different page size)

Response time climbing steadily (exponential backoff)

This replaces the entire manual bash loop from before -- same test, but with a built-in results table instead of scrolling terminal output.

2.5 Check for IP-based lockout bypass

In the same Intruder attack, add a second payload position on the X-Forwarded-For header (switch to Cluster bomb or Pitchfork attack type), cycling through a few fake IPs alongside the password attempts -- if the lockout resets when the header changes, Burp's results will show successful-looking responses continuing past the point where lockout should have kicked in.

2.6 Check API endpoints separately

Repeat the same Intruder attack against any /api/login or mobile API endpoint you found -- just change the target URL in Intruder's target tab and keep the same attack configuration.

Step 3 -- Rate-Limited Credential Stuffing (Disposable Account Only)

Goal: Use Hydra for this -- it's purpose-built for exactly this test and has built-in threading/delay controls, so there's no custom script to write at all.

3.1 Prepare a small password list

head -n 50 /usr/share/wordlists/seclists/Passwords/Common-Credentials/10-million-password-list-top-100.txt > small_test_list.txt

3.2 Run Hydra against the disposable test account only

hydra -l disposable.test.account@test.com -P small_test_list.txt \

-t 1 -w 3 \

target.com https-post-form \

"/login:username=^USER^&password=^PASS^:F=Invalid credentials"

Flags, briefly:

-l -- single fixed username (your disposable account)

-P -- password list

-t 1 -- one thread at a time (no concurrency)

-w 3 -- 3-second wait between attempts

F= -- the string that appears on a failed login, so Hydra knows to keep going; Hydra automatically reports when this string is absent (meaning success)

Hydra prints a clear [SUCCESS] line with the matching password if it gets in -- no need to parse response bodies yourself.

3.3 Alternative: ffuf, if the login uses a JSON API instead of a form

ffuf -u https://target.com/api/login \

-X POST \

-H "Content-Type: application/json" \

-d '{"email":"disposable.test.account@test.com","password":"FUZZ"}' \

-w small_test_list.txt \

-mc 200 \

-p 3

-mc 200 -- only show results matching HTTP 200 (adjust to whatever the target's success code actually is)

-p 3 -- 3-second delay between requests

FUZZ -- ffuf substitutes each password from the wordlist here

3.4 Monitor Hydra/ffuf's live output for any slowdown

Both tools print each attempt as it happens -- if you see response times creeping up mid-run, that's a delayed throttle kicking in; stop and note at which attempt number it started.

Step 4 -- Password Policy Enforcement

Goal: Use Burp Intruder again -- same technique as Step 2, just pointed at the registration/password-change endpoint with a payload list of intentionally weak passwords instead of random wrong ones.

4.1 Build a "weak password" test list

cat > weak_passwords.txt << 'EOF'

a

12345678

password

qwerty123

Password123!

aaaaaaaaaaaaaaaaaaaa

EOF

4.2 Run it through Intruder against the registration endpoint

Same setup as Step 2 -- capture a registration request in Burp, send to Intruder, mark the password field, load weak_passwords.txt as the payload set, and run.

4.3 Read the results

Check each response for whether registration succeeded (should reject most of these) -- Burp's results grid shows status/length per attempt, so a weak password that gets a 200 OK success response stands out immediately against ones that correctly got a 400-style rejection.

4.4 Check against known-breached passwords (Pwned Passwords API, k-anonymity model)

This one-liner checks whether a password appears in the Have I Been Pwned breach corpus, without ever sending the full password over the network (it only sends a SHA-1 prefix):

bash

PASS="Password123!"

HASH=$(echo -n "$PASS" | sha1sum | tr 'a-z' 'A-Z' | cut -c1-40)

PREFIX=${HASH:0:5}

SUFFIX=${HASH:5}

curl -s "https://api.pwnedpasswords.com/range/$PREFIX" | grep -i "$SUFFIX"

If this returns a match with a count, the password is known-breached -- now test whether the target app itself rejects it (Step 4.2's Intruder run). If the target accepts it anyway, that confirms no breached-password check is in place.

4.5 Repeat Step 4.2's Intruder run against password-change/reset endpoints

Just swap the target URL in Burp to the change-password endpoint -- same payload list, same process, confirming policy consistency across flows.

Step 5 -- Document Results

Goal: Pull the numbers directly from each tool's own output -- all four tools above already produce structured, exportable results.

5.1 Export from Nmap/WPScan

nmap -p 80,443 --script http-default-accounts target.com -oN evidence_default_creds.txt

WPScan supports -o report.json --format json for a structured export.

5.2 Export from Burp Intruder

"Save results"

5.3 Export from Hydra

Hydra's terminal output already includes a timestamped summary at the end (total attempts, time taken, and any [SUCCESS] lines) -- redirect it to a file as you run:

hydra -l disposable.test.account@test.com -P small_test_list.txt -t 1 -w 3 \

target.com https-post-form "/login:username=^USER^&password=^PASS^:F=Invalid" \

| tee evidence_credential_stuffing.log

5.4 Export from ffuf

ffuf -u https://target.com/api/login -X POST \

-H "Content-Type: application/json" \

-d '{"email":"disposable.test.account@test.com","password":"FUZZ"}' \

-w small_test_list.txt -mc 200 -p 3 \

-o evidence_ffuf_results.json -of json

Evidence Table Template (fill in from the exports above):

No. Test Area Tool Used Result Conclusion
1 Default credentials Nmap http-default-accounts admin:admin succeeded on /login Confirmed -- critical
2 Lockout/throttle Burp Intruder (15 attempts, 1s delay) No status/length change across all attempts Confirmed -- no effective control
3 Lockout bypass Burp Intruder (Cluster bomb: password × X-Forwarded-For) N/A -- no lockout existed to bypass N/A
4 Credential stuffing Hydra (50 passwords, 3s delay, disposable account) [SUCCESS] at password Password123 Confirmed -- weak password + no throttling
5 Password policy Burp Intruder on /register Accepted a, 12345678, Password123! with 200 OK Confirmed -- no length/complexity/breach checks
6 Breached password check Pwned Passwords API + Burp Intruder cross-check Password123! found in breach corpus AND accepted by target Confirmed -- no breach-list rejection

Proof of Concept

[Insert the exact request and payload that demonstrate the vulnerability, and the resulting response.]

Evidence

[Insert screenshot or HTTP request/response excerpt -- Figure F-16-1.]

Remediation

Implement progressive throttling and temporary account lockout after a defined number of failed attempts, combined with CAPTCHA or risk-based challenges.

Remove or change all default and vendor-supplied credentials before deployment.

Enforce a strong password policy (minimum length, breached-password check) using a current standard such as NIST SP 800-63B.

Require multi-factor authentication for all accounts, and mandatorily for privileged accounts.

Re-test the lockout mechanism and credential policy after remediation.

Retest Notes

[ ] Not yet retested [ ] Retested -- Resolved [ ] Retested -- Not resolved. [Retest date and tester name.]

References

CWE-307 CWE-1392 CWE-521 OWASP Top 10:2021 OWASP WSTG

Hands-on Lab Exercise

Broken Authentication Hands-on Lab

Launch your local laboratory environment to verify this vulnerability.

$ curl -X POST http://127.0.0.1:8080/api/target \ -d "probe=api-broken-authentication"
• Goal: Verify vulnerable state behavior and apply defense
• Solution: Enforce defense-in-depth and strict validation
Knowledge Check
ASSESSMENT

What is the primary, most effective defense mechanism against Broken Authentication?

Next Module in Authentication and Token Security
JWT Misconfiguration
Continue to Next Module