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

Scramble user apiKey in database #58

Closed
ll4strw opened this issue Jul 15, 2024 · 8 comments
Closed

Scramble user apiKey in database #58

ll4strw opened this issue Jul 15, 2024 · 8 comments
Labels
enhancement New feature or request
Milestone

Comments

@ll4strw
Copy link
Collaborator

ll4strw commented Jul 15, 2024

UserApiKey.apiKey entries in db should be possibly scrambled.

@ll4strw ll4strw added the enhancement New feature or request label Jul 15, 2024
@mKowalski256
Copy link
Contributor

Yes that's a fair request, although in current design we do allow user to view/copy their API key anytime after its creation, which means most secure scrambling mechanism based on hashes would not work in this case. We could encrypt/decrypt the keys based on a secret stored outside database, but that would only be a partial improvement.

We encourage users to revoke/regenerate their API keys on the schedule they believe is reasonable.

@mKowalski256 mKowalski256 removed their assignment Jul 19, 2024
@ll4strw
Copy link
Collaborator Author

ll4strw commented Jul 19, 2024

Fair enough. I do understand the motivations behind this design choice. My concerns are mainly the following

  • Should the db get compromised, the platform would be compromised. API keys let a bearer perform operations, on behalf of a user, that normally would have required MFA - at least in our case.
  • Privacy. sysadmins would have access to all API keys and impersonate users outside the impersonations scheme provided by the GUI app itself.

@mKowalski256
Copy link
Contributor

Privacy. sysadmins would have access to all API keys and impersonate users outside the impersonations scheme provided by the GUI app itself

Hmm, I've checked that and I believe you mean that 'operate as' functionality currently let sysadmin see the API key of the user? That's a bug/oversight, the API key shouldn't be displayed for sysadmin, I'll raise it as a separate issue.

@mKowalski256
Copy link
Contributor

I see that outside of 'operate as' scenario there is an API endpoint allowing sysadmin to retrieve API keys. The issue #73 will cover both cases.

@ll4strw
Copy link
Collaborator Author

ll4strw commented Aug 12, 2024

Thanks for quickly completing #73. Could we open another issue just to do some brainstorming on how to avoid storing cleartext API keys in the db? Cheers, L.

@mKowalski256
Copy link
Contributor

mKowalski256 commented Aug 13, 2024

Hi Leonardo, after internal discussion we've prioritized this ticket, and we're targeting the fix for 2.3/1.103 release (end of September 2024). We plan to go with solution where user see the API key only once, at the moment of creation, after which RSpace stores just a hashed value of the key.

@mKowalski256 mKowalski256 added this to the RSpace 2.3.0 milestone Sep 9, 2024
@rs-nicof
Copy link
Contributor

I can confirm this has been handled by the JIRA ticket https://researchspace.atlassian.net/browse/RSDEV-310 and will be released in the RSpace version 1.103.

@mKowalski256 not sure if this github issue needs to be closed now

@mKowalski256
Copy link
Contributor

This change is merged and part of 2.3.0 open-source release (and in 1.103.0 supported release) - API keys are now stored hashed with SHA256, and only visible to the user immediately after creation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants