mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-12-04 04:43:59 +01:00
security: move session token to handshake auth and rotate on resume
The anonymous session token is a bearer credential that was sent in the Socket.IO handshake query string, where it leaks into proxy/access/referer logs and is easily observed. Anyone holding it becomes that user (credits, payout address, pending payments). - Client now sends the token in the handshake `auth` payload instead of the query string. Server reads `auth` first and falls back to the query string for backward compatibility during rollout. - The token is rotated on every successful resume, so a leaked/observed token is invalidated the next time the legitimate owner reconnects. The client already persists the token returned in `session_resumed`. Adds a security test asserting resume returns a new token and the old token no longer resumes. Full suite: 12 suites / 116 tests.
This commit is contained in:
+5
-1
@@ -20,7 +20,11 @@
|
||||
window._localStorageAvailable = true;
|
||||
const existing = localStorage.getItem('wownerogue_token');
|
||||
if (existing) {
|
||||
opts.query = { resumeToken: existing };
|
||||
// Send the session token in the handshake `auth` payload, NOT the URL
|
||||
// query string. Query strings leak into proxy/access/referer logs;
|
||||
// auth is carried in the connection body. (Server keeps a query-string
|
||||
// fallback for older clients during rollout.)
|
||||
opts.auth = { resumeToken: existing };
|
||||
}
|
||||
} catch(_) {
|
||||
window._localStorageAvailable = false;
|
||||
|
||||
Reference in New Issue
Block a user