-
Notifications
You must be signed in to change notification settings - Fork 24
fix: hide access_token and refresh_token details in the web console #1789
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
base: main
Are you sure you want to change the base?
Conversation
b52e784 to
d9225e1
Compare
| logger.debug(`User Loaded`, { | ||
| ...(user.access_token && { | ||
| 'access_token (sha256)': sha256(Buffer.from(user.access_token)).slice(0, 8) | ||
| }), | ||
| ...(user.refresh_token && { | ||
| 'refresh_token (sha256)': sha256(Buffer.from(user.refresh_token)).slice(0, 8) | ||
| }) | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I'm not sure if hashing the tokens has any value because you can't decode them. Why not print them as they are since we're only doing this in dev mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log can be overwritten which could leak the token to the outside, also services like sentry or similar can access the data:
https://skillstuff.com/if-you-store-tokens-like-this-youre-already-vulnerable/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh I didn't know, thanks for the info!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but why are we logging anything at all then? what benefit does a hashed token bring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but why are we logging anything at all then? what benefit does a hashed token bring?
I wasn't sure why we log the token either; the only case I can think of is to see that the token refresh is working, that the token is new, and possibly to compare the hash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO you can remove it entirely 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO you can remove it entirely 🙈
+1, what do you think, should we keep the logger, I prefer it over the native console.*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the impression that it's a bit over-engineered to be honest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the impression that it's a bit over-engineered to be honest
Ok, maybe … 😂, let’s keep the pr open till after my vacation, or just remove the token logs and call it a day 🤗
JammingBen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM, needs a rebase though to make CI happy.
Description
Removes logging of access and refresh tokens to prevent them from potentially leaking through browser extensions, addons, or .... Replaces token logs with hashed fingerprints.
Also introduces a logger that only logs messages when the appropriate log level is set.
Related Issue
How Has This Been Tested?
Types of changes