Skip to main content
HighContentOWASP A02:2021CWE-598

How to fix: Session ID Exposed in URL

A session identifier (session_id, sid, PHPSESSID, JSESSIONID, or ASP.NET_SessionId) appears as a URL query parameter in the page, carrying a value with the shape of a real session token. A short numeric id, a templated placeholder, or a documentation example such as ?session_id=YOUR_SESSION_ID is not reported.

Why it matters

Session IDs in URLs are logged by servers, proxies, and browser history, and leak via the Referer header to any linked third party -- letting anyone who obtains the URL hijack the session.

Session identifiers belong exclusively in HttpOnly cookies. A session ID that also appears as a URL parameter is exposed everywhere URLs are recorded, and enables session fixation if the server accepts an attacker-supplied ID.

How to fix it

  1. 1Never pass session identifiers as URL query parameters.
  2. 2Rely solely on HttpOnly, Secure, SameSite cookies for session state.

Code examples

Remove session IDs from URLs and response bodies

TypeScript
// BAD: session ID in URL, logged by servers, proxies, and browsers
// /dashboard?session=abc123

// GOOD: session ID in HttpOnly cookie only
res.setHeader("Set-Cookie",
  `session=${sessionId}; HttpOnly; Secure; SameSite=Strict; Path=/`
);

// Also: never include session IDs in JSON response bodies

References

Detected automatically by VulnRadar. The check id is exposed-session-id, stable across every scan so you can filter or diff on it.

See every content check

Questions

How severe is Session ID Exposed in URL?
VulnRadar rates this high severity in the content category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id exposed-session-id, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Session ID Exposed in URL map to?
It maps to CWE-598. In the OWASP Top 10 it falls under A02:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for session id exposed in url

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: Session ID Exposed in URL | VulnRadar