Vulnerability
Token leakage occurs when a session identifier ends up somewhere it was never intended to be exposed not because an attacker actively steals it, but because the application itself handles the credential in an unsafe way.
A session token is a credential. Anyone who obtains a valid token may be able to replay it and take over the session it represents. The danger, therefore, is not limited to direct attacks such as malware or cookie theft. A token can also be exposed simply because the application places it somewhere that gets copied, logged, cached, or forwarded as part of normal operation.
One of the most common examples is a session identifier appearing in a URL.
Session identifier ends up in a URL
(either intentionally, or because session data is
accidentally included in an unrelated parameter)
↓
The URL can now propagate into places the application
never intended the credential to reach:
→ Server access logs
→ Proxy, cache, or monitoring infrastructure
→ Browser history
→ Bookmarks and shared links
→ Potentially the Referer header when the browser
loads third-party resources or navigates elsewhere
The Referer case is particularly important because the application may not explicitly send the token anywhere. If the site's referrer policy allows the relevant URL information to be included, the browser can automatically send it as part of an ordinary request to another destination.
For example, a page containing a session ID in its URL might load an analytics script, embedded content, or another external resource. Depending on the referrer policy and the relationship between the two origins, information from the current URL may be included in the request to that external service.
The problem is not that the third party necessarily did anything malicious. The credential was placed in a location designed to be propagated.
Other forms of token leakage are less visible but follow the same pattern:
Other common leakage sources:
Verbose error or debug pages that expose
request headers or authentication data
↓
General request logging that records session
or authorization values without redaction
↓
Support tickets, bug reports, or diagnostic exports
containing "the full request"
↓
A live session credential is copied into a system
where it was never intended to exist
In all of these cases, there may be no active attacker involved at the moment the leak occurs. The application or its surrounding infrastructure creates the exposure first. An attacker only needs to discover, access, or obtain the leaked credential later.
Defending Against Token Leakage:
Session identifiers should never appear in URLs:
A session ID should be transported using the session cookie rather than being embedded in query parameters, paths, links, redirects, or other locations likely to be logged or shared.
Applications must also treat session tokens and authorization credentials as sensitive data throughout their operational infrastructure.
Defense:
Keep the session ID in a cookie
+
Never place session credentials in URLs
+
Apply Secure / HttpOnly / appropriate SameSite
protections to the session cookie
+
Redact session IDs, cookies, Authorization headers,
and other credentials before they enter:
→ Logs
→ Error reports
→ Monitoring systems
→ Analytics pipelines
→ Support tickets
→ Diagnostic exports
↓
✓ Significantly reduced token leakage surface
The broader principle is:
A session token is a credential, not ordinary application data.
Any location where it can be copied, logged, cached, displayed, forwarded, exported, or retained should be treated as a potential credential-exposure boundary.