Skip to main content
Module 4 · Lesson 1 of 412/42 in the course~16 min
Module lessons (1/4)

Cookies (HttpOnly/SameSite), CORS & CSRF

Lesson preview6 hands-on exercises readyApplication & Web Security · Module 4 — Authentication, Sessions, JWT & Access Control

Simulate cookie theft and cross-site requests, bypass suffix-based origin checks, and enforce exact Origin allowlists.

What you'll learn in this lesson

  • Explain how browser cookies (HttpOnly, Secure, SameSite), CORS, and CSRF interact across origins.
  • Exploit broken .endsWith() and .includes() CORS origin filters using lookalike domains.
  • Enforce exact new URL(origin).origin CORS allowlists, hardened Set-Cookie flags, and fail-closed CSRF + origin verification on state-changing routes.

Overview

Authentication cookies live in the browser's shared cookie jar, which creates two distinct cross-origin attack vectors: Cross-Site Request Forgery (CSRF) (a third-party site triggers a browser request that carries cookies automatically) and Permissive CORS (a server reflects an untrusted Origin header with credentials, letting another site read…

Inspect four security patterns at the HTTP trust boundary:

Sections covered in this lesson

  1. 11. Cookie Flags, CORS Origin Parsing & CSRF Guards
  2. 22. Interactive Explorer: HTTP Cookies, CORS & CSRF
  3. 33. Progressive Labs: Warm-Up → Attack → Defend → Harden
  4. 44. Checkpoints & Code Review
Pro Lesson · Module 4 — Authentication, Sessions, JWT & Access Control

Unlock "Cookies (HttpOnly/SameSite), CORS & CSRF" and the full Application & Web Security curriculum

Simulate cookie theft and cross-site requests, bypass suffix-based origin checks, and enforce exact Origin allowlists.

Unlock all 6 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Application & Web Security plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.