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
Severity
Critical
Description
The JWT access token is actively being stored in
localStorageinside theAuthContextcomponent. This exposes the authentication token to client-side scripts.Affected Files
src/context/AuthContext.jsxEvidence
Impact
Storing JWTs or session tokens in
localStoragemakes the application highly vulnerable to Cross-Site Scripting (XSS) attacks. If a malicious script runs on the page, it can readlocalStorage, extract the token, and perform full account takeover on behalf of the user.Suggested Resolution
Refactor authentication to use
httpOnlyandSecurecookies 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 orlocalStorage.References