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

Rotating hashing key for access token #1170

Open
minzcmu opened this issue Jul 6, 2018 · 1 comment
Open

Rotating hashing key for access token #1170

minzcmu opened this issue Jul 6, 2018 · 1 comment

Comments

@minzcmu
Copy link
Member

minzcmu commented Jul 6, 2018

Context

With our current code logic, it's impossible to rotate the one way hashing key/salt for access tokens without invalidating current tokens.

https://github.com/screwdriver-cd/models/blob/master/lib/generateToken.js#L35

Possible solution

  • Inform users, rotate the hashing key and ask users to refresh it
  • Double/triple encryption: maintain a map of hashing keys, encrypt current hash value with new key, and when trying to fetch: encrypt with all keys in the map and then compare
  • Switch to Bcrypt: bcrypt will generate a random salt for every token. We don't need a hashing key going forward. But need to change the access token interface to ask users to use it with pipelineId/userID, e.g. pipeline123:tokenvalue. So that we can look up the tokens for pipeline 123, and compare the hash values.
@FenrirUnbound
Copy link
Collaborator

I guess what's missing in the context is the "why do we want to rotate the salt". The stance we took was that the access token was treated like a password-alternative, and just like passwords, changing it has to be intended by the user.

Of course, long-lived passwords is a potential security threat (e.g., a common IT policy is to rotate your password every n days). Our solution was to put a TTL on the token. This touches on your 2nd bullet point, and also limits the number of salts you need to maintain. Once a salt has reached it's TTL, you can treat all the access tokens created with it to be considered invalid.

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

No branches or pull requests

3 participants