Session Manager Exposes Tokens: Plain JSON in localStorage Creates XSS Backdoor
A critical security flaw has been identified in a session management service, where authentication tokens, including sensitive refresh tokens, are being stored as plain JSON in the browser's localStorage. This practice creates a direct pathway for token theft if any cross-site scripting (XSS) vulnerability exists on the page, as localStorage is fully accessible to any JavaScript executing in the same origin. The code, located in `src/services/sessionManager.ts`, explicitly serializes the session object before storage, leaving the keys in the clear.
The specific implementation uses `localStorage.setItem(key, JSON.stringify(session));`, a method that prioritizes developer convenience over security. While the current context notes that the service appears unused and that Supabase handles its own sessions securely, the dormant code represents a latent risk. If this manager is ever activated or integrated into a live authentication flow, it would instantly introduce a severe token leakage vector, bypassing more secure session management protocols.
This pattern violates fundamental security principles for web applications. Refresh tokens, which grant long-term access, should never be stored client-side in an accessible manner. The presence of such code, even if inactive, signals a potential architectural oversight and increases the attack surface. The risk is not theoretical; it is a concrete vulnerability waiting to be exploited, making the codebase's security posture contingent on this service remaining permanently disabled—a fragile guarantee.