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

[SECURITY] SECRET_KEY is hardcoded #237

Closed
Jules-Bertholet opened this issue Apr 23, 2021 · 3 comments
Closed

[SECURITY] SECRET_KEY is hardcoded #237

Jules-Bertholet opened this issue Apr 23, 2021 · 3 comments
Assignees
Labels
Milestone

Comments

@Jules-Bertholet
Copy link

Jules-Bertholet commented Apr 23, 2021

Describe the bug
SECRET_KEY is hard-coded in web/settings.py. This is a security vulnerability.

Expected behavior
SECRET_KEY is a configurable environment variable.

@damianmoore
Copy link
Collaborator

Thanks @Jules-Bertholet. I've this in my mind for a while. As I understand it, the biggest risk for us is that session tokens could be brute forced more easily.

Do you have any recommendations on the best way to solve this? Obviously we could allow user to pass it in as an environment variable from docker-compose.yml but I'm sure lots of people would find it hard to generate a secure enough string before starting or leave it as the default.

The best I can think is that if no environment variable is set for it then autogenerate one and save it as file on a separate data volume. I'm just a bit worried it will get lost if the user wants to re-install or migrate to another server.

@damianmoore damianmoore self-assigned this Apr 24, 2021
@damianmoore damianmoore added this to the 1.0 milestone Apr 24, 2021
@damianmoore
Copy link
Collaborator

Closed as of a35c694. SECRET_KEY is now randomly generated on server start. Only downside I can see is that JWT tokens get refreshed by JS. If we need a more consistent SECRET_KEY in future then we can accept it as an optional environment variable or cache the generated value to disk volume.

@damianmoore
Copy link
Collaborator

There was a bit of a complication with the first attempt causing GraphQL JWT Error decoding signature errors. The latest commit 112fd3e hopefully solves these issues (caused by multiple Gunicorn workers each having their own secret keys). SECRET_KEY is now generated on first load and stored in Redis so all worker processes can access it. If Redis gets wiped out it will just mean users have to re-login.

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

No branches or pull requests

2 participants