← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

Session Riding

Security CWE-352 OWASP A1:2021 CVSS 8.1 PHP 5.0+ Intermediate
debt(d5/e3/b3/t5)
d5 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'specialist tool catches it' (d5), because detection_hints.tools lists owasp-zap and semgrep — both specialist SAST/DAST tools. The absence of a CSRF token or missing SameSite attribute won't be caught by a compiler or default linter; it requires running one of these dedicated security scanners against the codebase or a live application.

e3 Effort Remediation debt — work required to fix once spotted

Closest to 'simple parameterised fix' (e3), grounded in the quick_fix: add synchronizer CSRF tokens to state-changing forms/endpoints plus set SameSite cookie attributes. This is a small but deliberate fix that may touch several form templates and session configuration, but it is a well-understood, repeatable pattern rather than a multi-file architectural refactor.

b3 Burden Structural debt — long-term weight of choosing wrong

Closest to 'localised tax' (b3), because the mitigation (CSRF tokens, SameSite cookies) is scoped to web/api form-submission and session configuration contexts. It imposes a recurring but bounded tax — developers must remember to include tokens on state-changing endpoints — without reshaping the broader architecture or affecting unrelated subsystems.

t5 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'notable trap' (t5), directly grounded in the misconception field: developers commonly believe session riding and CSRF are distinct attacks and may treat them separately or not recognise one from the other. Additionally, common_mistakes show that developers frequently add a CSRF token but skip server-side validation or reuse the same token across all users, revealing that the 'obvious' partial implementation is still exploitable.

About DEBT scoring →

Also Known As

CSRF session riding attack cross-site request forgery via session

TL;DR

An alternative term for CSRF — the attacker 'rides' the victim's authenticated session to perform actions on their behalf.

Explanation

Session riding emphasises the mechanism of CSRF: the attacker's request piggybacks on the victim's existing browser session. Unlike session hijacking (which steals the session token), session riding leaves the token with the legitimate user — it simply abuses the browser's automatic cookie inclusion in cross-origin requests. The term is used interchangeably with CSRF in some literature. Defences are identical: SameSite cookies, synchronised CSRF tokens, and Origin/Referer header validation.

Common Misconception

Session riding and CSRF are different attacks. They are the same attack described from different angles — session riding emphasises the attacker hijacking the authenticated session; CSRF emphasises forging the cross-site request.

Why It Matters

Session riding (CSRF) exploits the browser's automatic cookie sending — a forged request from a malicious page uses the victim's authenticated session to perform actions they did not initiate.

Common Mistakes

  • No CSRF token on state-changing forms and API endpoints.
  • CSRF tokens that are not rotated per session or per request.
  • Same CSRF token for all users — a leaked token compromises all users.
  • Not validating the CSRF token server-side — client-side validation only is bypassable.

Code Examples

✗ Vulnerable
// No CSRF protection — any site can submit this form on behalf of the user:
<form method="POST" action="/transfer">
    <input name="to" value="attacker">
    <input name="amount" value="1000">
</form>
// Attacker hosts: <form id='f' ...></form><script>f.submit()</script>
// Victim visits attacker page → transfer executes using victim's session
✓ Fixed
// Session riding = CSRF exploiting the session cookie

// 1. SameSite=Strict — blocks cross-site cookie submission
ini_set('session.cookie_samesite', 'Strict');

// 2. CSRF token in every state-changing form
$_SESSION['csrf'] = bin2hex(random_bytes(32));
// <input type="hidden" name="_csrf" value="<?= $_SESSION['csrf'] ?>">
if (!hash_equals($_SESSION['csrf'], $_POST['_csrf'] ?? '')) abort(403);

// 3. Verify Origin header for AJAX
$origin = $_SERVER['HTTP_ORIGIN'] ?? '';
if (parse_url($origin, PHP_URL_HOST) !== 'yourapp.com') abort(403);

// 4. Re-authenticate for sensitive actions (transfers, email change, delete)

Added 15 Mar 2026
Edited 22 Mar 2026
Views 45
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 0 pings W 1 ping T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 1 ping T 0 pings F 0 pings S 0 pings S 1 ping M 1 ping T 0 pings W 0 pings T 1 ping F 0 pings S 0 pings S 1 ping M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 1 ping M 0 pings T 0 pings W
No pings yet today
No pings yesterday
Amazonbot 6 SEMrush 5 Perplexity 4 Google 3 Ahrefs 3 Scrapy 3 Unknown AI 2 Claude 2 Bing 1 Meta AI 1 PetalBot 1
crawler 27 crawler_json 3 pre-tracking 1
DEV INTEL Tools & Severity
🔴 Critical ⚙ Fix effort: Medium
⚡ Quick Fix
Session riding is another term for CSRF — an attacker 'rides' the victim's authenticated session to perform actions; the fix is the same: synchronizer CSRF tokens plus SameSite cookies
📦 Applies To
PHP 5.0+ web api
🔗 Prerequisites
🔍 Detection Hints
State-changing requests without CSRF token; session cookie without SameSite attribute; GET endpoint with side effects
Auto-detectable: ✓ Yes owasp-zap semgrep
⚠ Related Problems
🤖 AI Agent
Confidence: High False Positives: Low ✗ Manual fix Fix: Medium Context: File Tests: Update
CWE-352


✓ schema.org compliant