Detection
Cookie Analysis
Detection
The first step in testing session security is often the simplest: inspect the session cookie the browser actually received.
Do not rely solely on the application's source code or configuration and assume the resulting cookie has the attributes you intended. Open the browser's developer tools after authentication, navigate to the Application or Storage section, and inspect the session cookie directly.
The browser is the final recipient of the Set-Cookie header. What appears in its cookie storage is what actually matters.
Log in to the application
↓
Open Browser Developer Tools
↓
Application / Storage
↓
Cookies
↓
Inspect the active session cookie directlyCheck the following attributes.
Secure:
Confirm that the Secure attribute is present.
A session cookie without Secure may be sent by the browser over an unencrypted HTTP connection if the cookie's other scope rules allow it.
Session cookie
Secure: ✓
↓
Browser will only send the cookie
over HTTPSHttpOnly:
Confirm that HttpOnly is present.
This prevents ordinary client-side JavaScript from reading the session cookie through APIs such as document.cookie, reducing the risk of direct cookie theft through XSS.
Session cookie
HttpOnly: ✓
↓
document.cookie does not expose
the session credentialAs discussed earlier, this does not fix an XSS vulnerability or prevent malicious script from making requests through the victim's authenticated browser. It specifically protects the raw cookie value from ordinary script access.
SameSite:
Check that SameSite is explicitly configured and that the chosen value matches the application's requirements.
For many applications, Lax or Strict is preferable to None.
SameSite: Strict
OR
SameSite: Lax
↓
Cross-site cookie behavior is restrictedSameSite=None should be used only when the application genuinely requires cross-site cookie behavior and the security implications are understood.
Domain:
Check whether the cookie has a Domain attribute and, if so, whether it is broader than necessary.
If the application does not need the session cookie to be shared across subdomains, the Domain attribute generally should not be set.
example.com
│
├── app.example.com
├── admin.example.com
└── other.example.comA broadly scoped cookie can potentially be sent to more hosts than necessary. Limiting the cookie's scope reduces the number of systems that can receive or potentially influence it.
__Host- Prefixed Cookies:
If the application uses a cookie name beginning with __Host-, verify that the browser actually accepts and stores it.
The __Host- prefix imposes specific requirements on the cookie's configuration. If those requirements are not met, the browser may reject the cookie rather than silently accepting a weaker version.
That makes browser inspection useful for catching configuration mistakes that may not be obvious from the application's source code alone.
Test Every Session Entry Point:
Do not perform this check only after the main username-and-password login.
Different authentication flows may create or modify sessions through separate code paths, and those paths may not apply identical cookie settings.
Test every entry point that can establish, restore, or replace an authenticated session:
Authentication entry points
├── Username / password login
├── OAuth or SSO callback
├── "Remember me" auto-login
├── Magic-link authentication
├── Password reset followed by auto-login
└── Any other session restoration flow
↓
Inspect the resulting session cookie
for each pathFor every flow, confirm that the resulting session cookie has the expected security attributes and scope.
This is particularly important when authentication mechanisms were implemented separately. The main login flow may correctly issue a Secure, HttpOnly, appropriately scoped cookie, while a less frequently used path silently creates the same session with weaker attributes.
Do not test what the code appears to do. Test what the browser actually receives.