Skip to content

Client-Side Route Guard and Identity Bypass via LocalStorage Manipulation (Security Vulnerability) #746

Description

@Adithyakp86

[BUG / SECURITY]: Client-side Route Guard and Identity Bypass via LocalStorage Manipulation

Description

The application relies on localStorage values (userType and userId) for client-side routing access control and to dynamically fetch user data. A user can easily bypass route-guards and impersonate other users/roles by manually modifying their local storage properties in the browser developer console.

Locations affected

  • components/Auth/AuthCheck.js
  • pages/doctor/dashboard.js
  • pages/doctor/alerts.js
  • pages/appointments.jsx

Steps to Reproduce

  1. Visit the home page (unauthenticated).
  2. Open the browser Developer Console.
  3. Run:
    localStorage.setItem("userType", "doctor");
    localStorage.setItem("userId", "impersonated-doctor-id");
    localStorage.setItem("username", "Dr. Impostor");
  4. Navigate manually to /doctor/dashboard.
  5. The AuthCheck component will allow access because it validates the existence of the userType value directly from local storage.
  6. The dashboard attempts to retrieve patients using these spoofed IDs.

Expected Behavior

Access control and authentication details should be verified on the server side using secure session claims (e.g. Clerk token or Firebase Session cookies) instead of easily modifiable local storage values.

Proposed Solution

Refactor client-side layout guards to consume the global authentication state from useUser() (Clerk) or UserContext instead of querying localStorage.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions