Summary
The refresh token is stored in an httpOnly cookie. However, the /auth/refresh and /auth/logout endpoints do not verify a CSRF token. A malicious page on another origin can trigger a cross-site POST that causes the browser to send the httpOnly cookie automatically, allowing:
- Forced logout (CSRF on
/logout)
- Unauthorized token refresh if the response leaks the new access token in a CORS-permitted response
Impact
- Denial-of-service via forced logout.
- Potential token leakage if CORS
Access-Control-Allow-Origin is overly permissive.
Suggested Fix
Add SameSite=Strict (or Lax) to the refresh token cookie, and additionally validate a X-CSRF-Token header on state-changing endpoints:
res.cookie('refreshToken', token, {
httpOnly: true,
secure: true,
sameSite: 'Strict',
});
Summary
The refresh token is stored in an
httpOnlycookie. However, the/auth/refreshand/auth/logoutendpoints do not verify a CSRF token. A malicious page on another origin can trigger a cross-site POST that causes the browser to send the httpOnly cookie automatically, allowing:/logout)Impact
Access-Control-Allow-Originis overly permissive.Suggested Fix
Add
SameSite=Strict(orLax) to the refresh token cookie, and additionally validate aX-CSRF-Tokenheader on state-changing endpoints: