Skip to content

Auth tokens stored in localStorage #8

Description

@Shreyy2002

Severity

Critical

Description

The JWT access token is actively being stored in localStorage inside the AuthContext component. This exposes the authentication token to client-side scripts.

Affected Files

  • src/context/AuthContext.jsx

Evidence

const user_token = window.localStorage.getItem("user_token");
// ...
window.localStorage.setItem("user_token", access_token);

Impact

Storing JWTs or session tokens in localStorage makes the application highly vulnerable to Cross-Site Scripting (XSS) attacks. If a malicious script runs on the page, it can read localStorage, extract the token, and perform full account takeover on behalf of the user.

Suggested Resolution

Refactor authentication to use httpOnly and Secure cookies set directly by the backend API. The frontend application should rely on the browser automatically sending cookies and no longer manage or store the raw JWT token in JavaScript memory or localStorage.

References

  • OWASP Session Management Cheat Sheet

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions