Generate Authentication and Authorization Bypass Tests
Returns a structured suite of authentication and authorization bypass test cases, IDOR, JWT algorithm confusion, session fixation, MFA bypass, brute-force resistance, broken object-level authz, with payloads, CWE numbers, and the detection signal that confirms vulnerability vs secure behavior.
When to use it
- Pen-testing an authentication system before going live.
- Auditing existing auth after a security incident or near-miss.
- Documenting auth security testing for compliance (SOC 2 access controls).
- Reviewing third-party SSO / OAuth implementations.
The prompt
<role>You are an offensive security tester specializing in IAM (Identity and Access Management). You know JWT pitfalls, OAuth flow bugs, IDOR patterns, and the difference between authentication failures and authorization failures.</role> <context>Auth attack surface:- **Authentication**: Can I prove I'm SOMEONE without being them? (Brute force, JWT forge, session fixation, MFA bypass.)- **Authorization**: Can I access resources I shouldn't, given I'm authenticated as someone? (IDOR, role escalation, broken object-level authz.) Each test specifies: payload, expected secure behavior, CWE number for filing, detection signal (specific server response or behavior that confirms the bypass).</context> <task>For the auth setup below, generate test cases across these classes:1. **Authentication bypass**: JWT forge / confuse / replay, session fixation, brute force, MFA bypass2. **Authorization bypass**: IDOR (numeric / GUID), forced browsing, parameter tampering3. **Object-level authz**: Different user's resource access via direct ID4. **Role / privilege escalation**: Lower role attempts higher-role operations5. **OAuth flow attacks**: State parameter missing, redirect URI manipulation, scope escalation Each case: payload + expected secure behavior + CWE + detection signal.</task> <input>Auth setup (JWT / session cookie / OAuth / SAML, role model, MFA scheme): {auth}Application stack: {stack}</input> <constraints>- Group by ATTACK CLASS, not by endpoint.- Each case cites the CWE number (e.g., CWE-639 for IDOR).- Payloads are CONCRETE strings, not "manipulate the token".- Detection signal must be observable (specific status code + body content, not vague "fails").- For each MFA bypass scenario, the expected secure behavior must include "rate limit, audit log entry, and notification to user".</constraints> <output_format>Markdown document with H2 per attack class, each containing a table: Test name | Payload / Steps | Expected secure behavior | CWE | Detection signal. Followed by 2-3 high-level "Hardening recommendations" bullets.</output_format> <approach>Before writing, identify which attack classes are most acute for the specific auth setup (e.g., JWT-based systems are vulnerable to algorithm confusion; OAuth-based ones to redirect URI manipulation).</approach>## RoleOffensive security tester specializing in IAM. JWT, OAuth, IDOR. ## ContextAuthentication = "prove I'm someone I'm not". Authorization = "access resources I shouldn't". Each test specifies: payload + expected secure behavior + CWE + detection signal. ## TaskFor the auth setup, test cases across:1. Authentication bypass (JWT forge/confuse/replay, session fixation, brute force, MFA bypass)2. Authorization bypass (IDOR, forced browsing, param tampering)3. Object-level authz (other user's resource access)4. Role / privilege escalation5. OAuth flow attacks (state, redirect URI, scope escalation) ## Input- Auth setup: {auth}- Stack: {stack} ## Constraints- Group by ATTACK CLASS, not endpoint.- CWE number cited per case.- CONCRETE payloads.- Detection signal observable (specific status + body).- MFA bypass: include "rate limit + audit log + user notification". ## Output formatH2 per attack class, table per class: Test name | Payload/Steps | Expected secure behavior | CWE | Detection signal. End with 2-3 Hardening recommendations. ## ApproachIdentify most acute attack classes for THIS auth setup.Example
Input
Auth setup: JWT bearer tokens (signed RS256). Refresh tokens stored httpOnly. TOTP-based MFA optional for users, required for admins. RBAC with roles: guest, member, admin. Application stack: Node.js API + React frontend.
Output
# Authentication and Authorization Bypass Tests, JWT + TOTP MFA + RBAC
## 1. Authentication Bypass
| Test name | Payload / Steps | Expected secure behavior | CWE | Detection signal |
|-----------|-----------------|--------------------------|-----|------------------|
| JWT algorithm confusion (alg: none) | Forge JWT with header `{"alg": "none", "typ": "JWT"}` and empty signature | Reject token | CWE-345 | 401 with WWW-Authenticate: Bearer |
| JWT algorithm confusion (alg: HS256 with RSA pub key) | Take RS256 pub key, use it as HS256 signing key | Reject token | CWE-347 | 401 |
| JWT without signature | Send `<header>.<payload>.` (empty signature) | Reject token | CWE-347 | 401 |
| Expired JWT (clock skew test) | Send JWT with `exp` = (now - 5s) | Reject token | CWE-613 | 401 with "token expired" |
| Refresh token replay after rotation | Use refresh token after rotating once | Reject second use; revoke all derived tokens | CWE-352 | 401 + email notification to user |
| Brute force on /login | Send 100 wrong passwords in 60s | Block after 5-10 attempts; CAPTCHA or lockout | CWE-307 | 429 after threshold + audit log |
| Session fixation | Set session ID before login, then login | Server rotates session ID on auth | CWE-384 | New session cookie returned post-login |
| MFA bypass, request without TOTP after login | First step (password) succeeds, skip TOTP, request /api/expenses | Reject, MFA required for admin | CWE-287 | 403 with "MFA required" |
| MFA TOTP brute force | Try TOTP codes 000000 - 999999 within window | Rate limit after 5 attempts; audit log; user notification | CWE-307 | 429 + audit log entry + email |
## 2. Authorization Bypass: IDOR
| Test name | Payload / Steps | Expected secure behavior | CWE | Detection signal |
|-----------|-----------------|--------------------------|-----|------------------|
| Numeric IDOR: other user's expense | As user A, `GET /api/expenses/<userB_expense_id>` (numeric ID) | Reject (403, NOT 404: implies existence) | CWE-639 | 403 with "not found" or "forbidden" |
| GUID IDOR: predictable | If GUIDs are sequential, request the next/previous one | Reject | CWE-639 | 403 |
| Parameter tampering: Tenant ID in body | As user in tenant A, send `PATCH /api/expenses/123` with `{"tenantId": "tenantB", ...}` | Server uses JWT-derived tenant, not body | CWE-639 | Update succeeds with no tenant change (or 400) |
| URL manipulation: admin endpoint | As member, visit /admin/users (frontend route) | 403 / redirect to login | CWE-284 | 403 or redirect; no admin UI rendered |
| Forced browsing: internal endpoint | Probe undocumented endpoints (e.g., /api/internal/users) | 404 or 401 (not 200 leaking response) | CWE-284 | 404 / 401 |
## 3. Object-Level Authorization
| Test name | Payload / Steps | Expected secure behavior | CWE | Detection signal |
|-----------|-----------------|--------------------------|-----|------------------|
| Read other tenant's data | As user in tenant A, `GET /api/reports/<report_id_in_tenantB>` | 403 | CWE-639 | 403 with "forbidden" |
| Update other tenant's data | As user in tenant A, `PATCH /api/expenses/<expense_in_tenantB>` | 403 (and update NOT applied) | CWE-639 | 403; verify by re-fetching as tenantB user: data unchanged |
| Delete other tenant's data | As user in tenant A, `DELETE /api/expenses/<id_in_tenantB>` | 403 (and delete NOT applied) | CWE-639 | 403; verify by re-fetching: record still exists |
## 4. Role / Privilege Escalation
| Test name | Payload / Steps | Expected secure behavior | CWE | Detection signal |
|-----------|-----------------|--------------------------|-----|------------------|
| Self-promote via PATCH | As member, `PATCH /api/users/self` with `{"role": "admin"}` | Server rejects role field from non-admin | CWE-269 | 400 / 403; role unchanged on re-fetch |
| Promote another user | As member, `PATCH /api/users/<id>` with `{"role": "admin"}` | 403 | CWE-269 | 403 |
| Admin endpoint as member | As member, `POST /api/admin/users` | 403 | CWE-284 | 403 |
| Token reuse across role change | As member, get JWT, get promoted to admin, then try admin endpoint with OLD JWT | Old token rejected (forced refresh after role change) | CWE-613 | 401 forcing re-auth |
## 5. OAuth Flow Attacks (if SSO is integrated)
| Test name | Payload / Steps | Expected secure behavior | CWE | Detection signal |
|-----------|-----------------|--------------------------|-----|------------------|
| State parameter missing | Initiate OAuth flow; remove `state` from authorize URL | Reject callback (CSRF protection requires state) | CWE-352 | Error page; no token issued |
| Redirect URI manipulation | Append `?redirect_uri=https://attacker.com` | Reject (only whitelisted redirect URIs allowed) | CWE-601 | Error or redirect to error page |
| Scope escalation | Request OAuth flow with `scope=admin,read,write` when consent screen offered `scope=read` | Reject elevated scope OR re-show consent for new scope | CWE-269 | New scope NOT granted |
| Authorization code reuse | Use same OAuth code twice | Reject second use; revoke previously issued token | CWE-294 | 400 with "code already used" |
## Hardening recommendations
- **Centralize authorization in middleware**: every endpoint checks authz BEFORE business logic. No per-controller authz checks; they're inconsistent.
- **Multi-tenant test suite in CI**: automated tests for cross-tenant data access must run on every PR. Catches IDOR regressions before merge.
- **MFA enforcement audit**: quarterly check that all admin-required endpoints actually enforce MFA at the gateway, not at the application.Common pitfalls
- Model mixes authentication and authorization tests: group explicitly.
- Detection signals get vague ('the test fails'); demand specific status + body content.
- CWE numbers get omitted; tests can't be filed as bugs without them.
- MFA bypass scenarios skip the rate-limit / audit-log / user-notification triple: those are the secure-behavior baseline.
Tips
- Run these against staging in a controlled session (record Burp project): replayable evidence of pass/fail.
- Pair with `security-test-checklist` for coverage of the ASVS controls; this prompt covers attack patterns.
- Test MFA on actual user accounts, not just admin: admin bypass is publicized but member bypass slips by.
- Document the SECURE BEHAVIOR column in your internal wiki; it becomes the spec for the auth system.
FAQ
Should I test these in production?
No. Test in staging with realistic data shape. Production-bound testing for auth bypass risks creating audit-log noise and customer-visible artifacts. Production validation belongs in synthetic monitoring with safe payloads.
Responsible disclosure when finding a bug?
If you're a customer/user finding the bug in someone else's product, follow their disclosure policy (security.txt, /security page). Don't exploit further. If you're an internal tester, file via internal tracker with restricted access until patched.
Is JWT alg=none still a real risk in 2026?
Most libraries now reject by default, but older versions still ship in production and some custom implementations forget. Test it. It's the single fastest test to run; if it succeeds, you have a critical vulnerability.
What's the difference between authentication and authorization bugs?
Authentication failures let attackers be SOMEONE (often someone they aren't). Authorization failures let them DO things (access resources they shouldn't). Both are critical; they have different root causes and remediations.