Skip to content

Conversation

@fschade
Copy link
Contributor

@fschade fschade commented Dec 23, 2025

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?

  • locally in the browser

Types of changes

  • Bugfix
  • Enhancement (a change that doesn't break existing code or deployments)
  • Breaking change (a modification that affects current functionality)
  • Technical debt (addressing code that needs refactoring or improvements)
  • Tests (adding or improving tests)
  • Documentation (updates or additions to documentation)
  • Maintenance (like dependency updates or tooling adjustments)

@fschade fschade force-pushed the fix-issue-1788-log-levels branch from b52e784 to d9225e1 Compare December 23, 2025 14:46
@fschade fschade self-assigned this Dec 23, 2025
@github-project-automation github-project-automation bot moved this to Qualification in OpenCloud Team Board Dec 23, 2025
@fschade fschade moved this from Qualification to In Progress in OpenCloud Team Board Dec 23, 2025
@fschade fschade changed the title fix: hide access_token and refresh_token refresh details in the web console fix: hide access_token and refresh_token details in the web console Dec 23, 2025
Comment on lines +164 to +171
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)
})
})
Copy link
Contributor

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?

Copy link
Contributor Author

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/

Copy link
Contributor

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!

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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 🙈

Copy link
Contributor Author

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.*

Copy link
Contributor

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

Copy link
Contributor Author

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 🤗

Copy link
Contributor

@JammingBen JammingBen left a 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.

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

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Access and Refresh tokens are visible in browser console

3 participants