Hunt: OAuth / SAML / Federation (golden-image rework)
Turn a federation surface into evidence-carrying CANDIDATES for OAuth and SAML attack: redirect_uri handling, signature validation gaps, XSW wrapping, state CSRF, client-secret leakage. This skill produces candidates, never verdicts - findings leave ONLY through the G1 proof gate (triage).
Current emphasis (update on wiki harvest): redirect_uri handling and signature-coverage gaps (stripping, comment injection) over the full XSW1-8 matrix - the newest harvested technique leads until superseded.
Assumes hunt-core for the scope gate, two-account rule,
confirmation gate, enumeration limits, stop conditions, wiki protocol,
FIND output, and Deadends. Do not re-derive any of that here.
Wiki
Hub: [[web-moc]] - Primary page: [[oauth-attacks]] - Payload arsenal:
wiki/payloads/oauth-saml.md
Anchors: [[saml-attacks]], [[jwt-attacks]]
REFS: [[oauth-attacks]], wiki/payloads/oauth-saml.md
mcp__wiki-search__query (lex) "OAuth SAML federation redirect_uri bypass XSW signature stripping state CSRF" via wiki-search MCP - ONLY on a concrete hint the map above does not cover; not a blanket first step.
Shared bypass arsenal (blocked implies research, but walk this first): skills/exploit/hunt/hunt-federation/references/bypass-arsenal.md - JWT test order (alg none -> jwk/jku -> kid -> confusion), sig2n pubkey derivation from 2 tokens, DCR logo_uri/jwks_uri/request_uri SSRF, WebFinger enumeration.
Paths (binding - define once at the top of the run notes)
# seat side (wsl) - engagement tree is DOUBLE-NESTED in VMshare:
ENG_DIR=/mnt/c/Users/Lenovo/Desktop/VMshare/<eng>/<eng>
RUN=$ENG_DIR/hunt/federation/<host>
# VM side (WHERE tools run, same tree through the VMware share):
ENG_DIR=/mnt/VMshare/<eng>/<eng>
RUN=$ENG_DIR/hunt/federation/<host>
Corpus and probes live in the VMshare tree; the VM runs tools against the /mnt/VMshare spelling as user tz; the seat reads the same bytes at the /mnt/c/Users/Lenovo/Desktop/VMshare spelling. The repo tree targets/ is admin/ingest only - probe artifacts NEVER land there.
Transport
Every VM-native command block ships through ONE documented transport:
cd /mnt/c/Users/Lenovo/Documents/ObisidianVaults/ZTorch/ZTorch && bash scripts/vm-ssh.sh '<command>'
- vm-ssh lands as user tz (NOT root): no root-only paths, no sudo.
- vm-ssh.sh takes the command as ONE argument; quotes ship as base64
(
echo <b64> | base64 -d | bashinside the vm-ssh argument). - Non-login shells do NOT source profile.d: target-facing fetches MUST use /opt/scope-shim/bin/{curl,httpx} by absolute path.
- Shim verdict semantics (verified live): out-of-scope dies rc 126 (never work around); in-scope passes; UNKNOWN gets an ADVISORY - not approval; verify against scope.md and self-deny.
- Flow capture + SAML Raider run seat-side in Burp; the VM loop only decodes/encodes assertions and fetches metadata documents.
Entry gate
All four must pass; each is falsifiable:
Active engagement exists (repo tree targets//active.md) and is on targets//scope.md in-scope. Scope-guard is the deny. (targets/ is the repo admin tree; $ENG_DIR holds corpus and run artifacts only - see Paths.)
hunt-core loaded (skills/exploit/hunt/hunt-core/SKILL.md).
Producer verified - at least ONE of: (a) $ENG_DIR/state.md asset table has >= 1 oauth/saml/sso endpoint row for (/oauth/, /saml/, /auth/callback, ?redirect_uri=, ?next=);
(b) a caido/burp baseline captured an SSO flow for ;
(c) $ENG_DIR/js//findings/endpoints.jsonl parses and names oauth/saml/well-known paths;
(d) kickoff seeded $RUN/raw/fed-map.md. None = dispatch the surface lane first.Toolchain preflight (fails LOUD):
for t in /usr/bin/jq /usr/bin/python3 \ /opt/scope-shim/bin/curl; do [ -x "$t" ] || { echo "MISSING TOOL: $t"; exit 1; } done command -v xmllint >/dev/null || { sudo apt-get install -y xmllint 2>/dev/null || sudo apt-get install -y libxml2-utils 2>/dev/null; } || echo "N/A: xmllint absent on VM (install failed - needs apt/sudo)" # python lxml fallback # seat-side: Burp + SAML Raider (hunt-burp owns install)
Checklist (mandatory)
Copy checklist.md (this skill's dir) to
$ENG_DIR/hunt/federation/<host>/federation-checklist.md at run
start. Unchecked at stop = UNCHECKED lane, re-run from the first
unchecked step. The SKILL.md text and the checklist header agree
byte-for-byte on that copy target.
Nudge
Review-skill re-injection text (pinned; NOTE: completion-gate emits its own generic nudge - both mean: resume at the first unchecked box):
Your work was just reviewed by the review skill and it was found
that you either missed a step of analysis, or didn't generate an
artifact of sufficient proof. Look at the markdown based checklist
and the output for each step, find what you missed, and complete
that step.
Confirmation gate
NOT confirmation: a redirect carrying a code or token in its URL; an IdP or SP returning 200 on a modified SAMLResponse; the assertion "accepted"; the flow completing with state removed; any error, even a revealing one. None of these prove you hold another account.
IS confirmation: a token or authenticated session FOR ANOTHER ACCOUNT, obtained through the flaw - an authorization code stolen via an attacker-controlled redirect_uri and exchanged for that account's token, or a forged/XSW/signature-stripped assertion that logs you in AS THE VICTIM (admin session reached). Then exercise the session, and reproduce from scratch in a clean browser profile with no cached SSO state (per hunt-core). If the session vanishes in a clean profile, you replayed your own login.
Methodology
Setup: two accounts per hunt-core - a victim SSO identity and an attacker identity/client, in separate browser profiles so SSO cookies never cross.
Rank before testing - most federation payouts come from the top:
- redirect_uri handling (where the code/token is DELIVERED; a permissive match leaks it to an attacker origin -> ATO).
- Signature validation (is the assertion signature checked at all, and does it cover exactly what the parser reads - stripping and comment injection live here).
- XSW1-XSW8 matrix (signature covers a signed element, the SP trusts a wrapper assertion - automate the eight variants with SAML Raider).
- state / CSRF (missing or client-only state on the callback enables login-CSRF and attacker-to-victim account linking).
- OIDC metadata and client leakage (.well-known/ openid-configuration, JS bundles, APK resources: leaked client_secret, extra grant types, unadvertised endpoints).
Entry points: /oauth/authorize /oauth/token /oauth/callback /auth/callback /saml/ /saml/acs /sso/saml /auth/saml/callback /login?redirect_uri= /signin?next=
Step 1 - Federation map
All OAuth/SAML entry points + flow shape (authorization-code, implicit,
PKCE presence, IdP-initiated vs SP-initiated). Row schema entry | protocol | flow shape | evidence @ $RUN/raw/fed-map.md.
Step 2 - Capture + decode a valid assertion
Capture a valid SAMLResponse via Burp; decode Base64, inspect XML:
echo "BASE64_SAML" | base64 -d | xmllint --format - > "$RUN"/saml.xml
@ $RUN/raw/saml-decoded/ (the assertion pair: original + working copy).
Step 3 - SAML battery
XSW (Signature Wrapping): inject an evil assertion before the signed one; the SP reads the unsigned wrapper's NameID:
<saml:Response> <saml:Assertion ID="evil"> <NameID>admin@company.com</NameID> </saml:Assertion> <saml:Assertion ID="legit"> <NameID>user@company.com</NameID> <ds:Signature><!-- Valid, covers ID=legit --></ds:Signature> </saml:Assertion> </saml:Response>Automate XSW1-XSW8 with SAML Raider. When XSW1/2 fail, walk XSW3-8 (each moves the wrapper relative to the signed element and the Response-vs-Assertion boundary) before declaring signatures enforced.
Signature stripping: decode, delete the entire Signature element, change NameID, re-encode (base64 -w0), POST - if the server does not verify = critical ATO.
Comment injection:
<NameID>admin<!---->@company.com</NameID>- the signature covers the commented form but the parser sees admin@company.com.XXE in assertion: DOCTYPE entity in the assertion (file read / OOB; hunt-injection owns depth):
<!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]> <saml:Assertion><NameID>&xxe;</NameID></saml:Assertion>
@ $RUN/probes/saml.jsonl.
Step 4 - OAuth battery
redirect_uri variations (highest yield):
redirect_uri=https://legit.com.evil.com redirect_uri=https://legit.com/callback/../../../evil redirect_uri=https://legit.com&redirect_uri=https://evil.com encoded chars %2F %40 %23state removal: drop state entirely - does the flow complete? Is it validated server-side or client-only?
Nonce replay / Referer leak: do on-page resources receive the full Referer containing the access token/code in the URL? Language switchers, analytics, social-share buttons loaded post-auth are the common culprits.
@ $RUN/probes/oauth.jsonl.
Step 5 - OIDC metadata + client leakage
.well-known/openid-configuration (extra grant types, unadvertised endpoints); client_secret in JS bundles (consume js-parser findings) or APK resources. @ $RUN/probes/oidc.jsonl.
Step 6 - Impact verification
Demonstrate ATO or privilege escalation on the test account per the confirmation gate (clean profile, victim session exercised). @ $RUN/probes/impact.jsonl.
Step 7 - Exit artifact (candidates)
candidates.md every class section present; pointer $ENG_DIR/hunt-federation-.md:
FEDERATION-HUNT-DONE redirect=<n> signature=<n> xsw=<n> state=<n>
oidc=<n>
Plus _requests.md rows (lane = hunt-federation), state.md asset rows, Deadends rows with the WHY (variants tried). Every probe JSONL row: {class, host, endpoint, method, evidence, observed, confidence}; pairs under probes/raw/ (sha256 filenames).
Chaining and evasion
Chain: a permissive redirect_uri (host confusion, path traversal, param pollution, post-auth Referer leak) -> steal the authorization code -> exchange at /oauth/token -> full ATO. A trusted NameID / sub from a stripped or XSW assertion is itself an auth bypass; hand the resulting session to hunt-auth for reset-poisoning and session follow-through.
Evasion when rejected: cycle the remaining redirect_uri encodings before calling it validated; walk the full XSW matrix with SAML Raider before declaring signatures enforced.
Validation
- Proof = an assertion YOU forged being accepted (session for B from your crafted SAML/token), or an IdP token honored by an RP outside its audience. Replay the minted session and read data; a decoded token is not proof.
- Negative control: same assertion minus the flaw (valid Audience, signed) behaves; clock-skew pair for timing claims.
False Positives
- Certificate rollover mismatch (transient ops window, not a flaw).
- Unsigned-by-design IdP-initiated SSO flows (signed at exchange).
- Multi-audience app: token valid for two RPs by product design.
- kid confusion blocked by pinned keys / JWKS allowlist.
Cross-routing
- hunt-auth for downstream session fixation/ATO mechanics.
- hunt-m365 for Entra-specific token flows and Conditional Access.
- hunt-api for bearer scope enforcement on the RP's APIs.
- Not this skill: password-based login flaws (hunt-auth).
Severity
Rated on the session actually obtained, not what the server merely accepted.
| Outcome | Typical |
|---|---|
| Forged / XSW / stripped assertion logs in as admin (SAML auth bypass) | critical - direct ATO |
| redirect_uri bypass yields a victim's code/token, exchanged to a session | critical / high - ATO |
| Login-CSRF via missing state (attacker session linked to victim) | medium / high |
| Leaked client_secret / OIDC misconfig, no cross-account session | low - enables other attacks |
Unauthenticated ATO outranks one needing victim interaction. An assertion the SP accepts that yields no other-account session is not a finding - it is a Deadend.
Deadends
Append: - [ ] SAML/OAuth on <host> -- XSW1-8 + strip + comment
rejected, signature covers NameID; redirect_uri strictly validated
(no encoding/host/traversal/pollution bypass); state enforced
Record which variants you tried - the next pass needs the boundary.
N/A escapes
- "N/A: no OAuth surface"
- "N/A: no SAML surface"
- "N/A: xmllint absent on VM (install failed - needs apt/sudo)" (python lxml fallback used) An N/A tick is a claim with a reason, never a silent pass. Identical strings in SKILL.md and checklist.md.
Bitter-pill variant
Freehand run: skip checklist + numbered steps, one freehand pass over the fed map, output ONLY $RUN/analysis/bitter-pill.md (tried/found/ dismissed, every claim carries evidence). The other-account-session gate survives freehand. Declare with a _requests.md row (lane = hunt-federation-bitterpill).
Depth walk (mandatory)
Walk EVERY applicable row of the payload arsenal page cited above.
Record each row in $RUN/coverage-depth.md as a table
| row | state | evidence | where state is probed, blocked, or
N/A, and evidence is a probe-pair path or a Deadends.md line. A bare
probed with no evidence reference fails the completion gate
(NEEDS-REVIEW). N/A rows cite why (surface shape forbids it).
Blocked implies research: before any Deadend is claimable on a blocked
row, (a) walk the arsenal page's bypass-ladder rows for that control
class, and (b) run one wiki query AND one mcp__wigolo__search for the
specific tech-plus-control bypass. Results, or a genuine null, land in
coverage-depth.md. "No research tried" is not a claimable state.
Exit artifact + handoff
ONE exit artifact set: $RUN/candidates.jsonl + candidates.md + $ENG_DIR/hunt-federation-.md (pointer with FEDERATION-HUNT-DONE
- counts). Consumer (triage) finds at $RUN: raw/fed-map.md,
raw/saml-decoded/, probes/*.jsonl, probes/raw/, candidates.{jsonl,md}.
Findings leave ONLY through G1. Distill:
python3 scripts/wiki-stage.py --kind technique --slug <slug> --target-page techniques/web/oauth-attacks.md(SAML findings: --target-page techniques/web/saml-attacks.md).
Stop conditions
Terminal states complete; nothing written into skill dirs; no unchecked boxes above REVIEW; hunt-core stop conditions fire unchanged.
Attack surface
APPROACH: Rank redirect_uri handling first (steal the code/token -> exchange -> ATO), then signature validation (stripping, comment injection), the XSW1-8 wrapper matrix via SAML Raider, missing state, and leaked OIDC client secrets.
AVOID: A redirect carrying a code/token, a 200 on a modified SAMLResponse, the assertion "accepted", or the flow completing with state removed is NOT confirmation - you must hold an authenticated session for ANOTHER account in a clean profile.