Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh Token being issued even if the Access Token/Refresh Token is tampered and fails to get verified #17

Open
dimple1024 opened this issue Feb 7, 2021 · 1 comment

Comments

@dimple1024
Copy link

dimple1024 commented Feb 7, 2021

In index.js at Line 29 of branch - https://github.com/benawad/graphql-express-template/tree/8_refresh_token:
const addUser = async (req, res, next) => {
const token = req.headers['x-token'];
if (token) {
try {
const { user } = jwt.verify(token, SECRET);
req.user = user;
} catch (err) {
const refreshToken = req.headers['x-refresh-token'];

Here , consider a scenario if the tokens were compromised and one of them , lets say access token is now tampered , it will fail the verification and hence will enter the catch block and will generate a pair of new token.
There should be an explicit check if the JWT verification fails and only if it is due to expiration of token then generate new pair of tokens.

@dimple1024
Copy link
Author

Pardon me if I am wrong :)

@dimple1024 dimple1024 changed the title Refresh Token being issued even if the Access Token/Token is tampered and fails to get verified Refresh Token being issued even if the Access Token/Refresh Token is tampered and fails to get verified Feb 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant