Session Token in URL

Session identifiers or authentication tokens are placed in URLs, where they leak into logs, browser history and Referer headers.

SeverityMedium
CVSS 3.16.8 CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N Open in the calculator
CVSS 4.07.6 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N Open in the calculator
CWECWE-598: Use of GET Request Method With Sensitive Query Strings
OWASP Top 10A06:2025 Insecure Design
MITRE ATT&CKT1550.004 Web Session Cookie
CategoryInformation Disclosure

Description

The application passes the session identifier or another authentication token in the URL: as a query string parameter, as a path parameter such as ;jsessionid= added by URL rewriting, or within links generated for the user. URLs are not treated as secret. They are recorded in browser history and bookmarks, and in web server, proxy, load balancer and analytics logs, and are sent to other sites in the Referer header when a page loads external resources or the user follows a link. Users also share URLs by copying them into emails and chat messages.

Anyone with access to a place where the URL has been recorded or sent, including a third-party site that receives the Referer header or a shared computer's history, can obtain a valid token and take over the user's session while it remains active, so the risk depends on how long tokens stay valid and how widely URLs are logged or shared. Tokens in URLs also make session fixation easier, because a crafted link can carry an identifier chosen by the attacker.

The finding is identified by reviewing authenticated traffic for tokens in request URLs and in links within responses, and by checking whether a session identifier supplied in the URL is accepted in place of the cookie. Scanners commonly report it as a session token in the URL or as cross-domain Referer leakage. Variants include single sign-on and emailed sign-in links that leave a long-lived token in the address bar, access tokens added to WebSocket or file download URLs, and applications that fall back to URL-based sessions when cookies are disabled.

Remediation

  • Carry session identifiers only in cookies with the Secure, HttpOnly and SameSite attributes, or for APIs in the Authorization header, and never in URLs.
  • Disable URL rewriting in the application server, for example by setting <tracking-mode>COOKIE</tracking-mode> in the session configuration of a Java web.xml, and reject session identifiers supplied in URLs.
  • Where a token must appear in a URL, such as a one-time sign-in link or a download link, make it single use and short-lived, exchange it immediately for a session cookie, and redirect to a URL without it.
  • Set a Referrer-Policy of no-referrer or strict-origin-when-cross-origin to limit what is sent to other sites.
  • Invalidate sessions whose tokens may already have been logged, and remove tokens from existing logs where practical.

Confirm the fix by reviewing authenticated traffic and generated links for tokens, and by confirming that a session identifier supplied in the URL is not accepted.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More Authentication and Sessions Findings

Every Authentication and Sessions finding