

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Authentication
incomplete
2: Stateless vs. Stateful Authentication
incomplete
3: What Are Sessions?
incomplete
4: What Are Cookies?
incomplete
5: Cookie Security
incomplete
6: Session Lifetime
incomplete
7: Password Resets
incomplete
8: Broken Password Reset Flow
incomplete
9: OAuth 2.0
incomplete
10: SAML and OIDC
incomplete
11: API Keys
incomplete
12: Reauthentication
incomplete
13: Authentication Misconceptions
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
From the server's point of view, cookies are convenient. From an attacker's point of view, session cookies are exploitable.
If an attacker steals a bearer session cookie and reuses it, the server (usually) can't tell those requests apart from the user's. Some common mistakes are:
document.cookie, injected JavaScript can steal it.Modern browsers give us tools to limit how cookies behave. The most important ones are:
HttpOnly (boolean): Prevents JavaScript from reading the cookie through document.cookie.Secure (boolean): Sends the cookie only over HTTPS (and localhost, for development).SameSite (Strict, Lax, None): Restricts when the browser sends the cookie with cross-site requests. Strict is the most restrictive. Lax also permits top-level cross-site navigations using safe methods, which many login flows need.Set cookie attributes deliberately instead of relying on framework or browser defaults!
Bearly Secure's session cookie has an explicit expiration date, but it still uses weak cookie security defaults.
Update the shared session_id cookie options so every issued session cookie includes secure attributes.
ExpiresHttpOnlySecureSameSite=LaxWith Bearly Secure still running, run and submit the CLI tests from the project root.