-
Notifications
You must be signed in to change notification settings - Fork 40
feat: add ALLOW_SUPPORT_LOGIN
to Dockerfile
#7399
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
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.
Currently1, the security of this approach heavily relies on the SECRET_KEY to be kept a secret.
If the SECRET_KEY is leaked, a malicious user could very easily compromise any user account on the system at any time without having to use the python manage.py support_login
command.
In the internal Specify Vault, I've put a video demonstrating exploiting this vulnerability: https://drive.google.com/file/d/1P7zpPiUAxYQnSvhzfXn4UyJ3UkJPpi3h/view?usp=sharing
I know the SECRET_KEY should be kept secret, but this presents a major risk to institutions.
There might be other ways to accomplish this, but I think we can make this more secure by adding a psuedo one-time salt/pad argument to the manage.py support_login
command (or we can generate a key for the user at the time they run the command).
We can then hash the token with this generated or provided key.
The user-provided or generated key would then need to be provided when logging in via the /accounts/support_login
endpoint.
That way, a malicious agent would require both the SECRET_KEY
and the key generated (or provided) when running the support_login
command to accomplish the exploit.
I can make the changes to this PR if needed.
On a couple much smaller notes:
Can we remove the following line? 😅
Or add a comment linking to documentation.
# TODO: is this in use somewhere? |
Also, there's another option that's currently accepted by the manage.py support_login
command: --list
!
specify7/specifyweb/specify/management/commands/support_login.py
Lines 20 to 26 in b45cef2
parser.add_argument( | |
'--list', | |
action='store_true', | |
dest='list', | |
default=False, | |
help='List users in database', | |
) |
It lists out all of the users, their user types, and whether they are a Specify 6 admin or not:

The output isn't very clean imo, and there's no way to view Specify 7 admins, so I'd be down to remove the option or clean it up and extend it!
Footnotes
-
This is not related to the changes in this PR, but with how the feature was initially implemented ↩
Triggered by 2d91cbd on branch refs/heads/issue-7398
This is ready for review and testing! I've made a number of improvements behind the scenes and have hopefully made this feature a little more secure. Redis Primarily we are utilizing redis as an in-memory cache to store information required to process a support login attempt.
More Specify-specific applications might include:
Cryptography Put simply, the support login process is now as follows: Currently, a symmetric encryption algorithm is used (AES-GCM with a randomly generated 256 bit key and 256 bit salt) to handle encryption and decryption. Token Generation/Encryption:
Token Parsing/Decryption:
Let me know if you have any ideas about this current implementation and setup! I'm considering using an asymmetric algorithm to handle encryption/decrpytion (the current implementation kind of follows the asymmetric approach anyways), although finding a way to secure a generated private key is notably difficult (and it may not be worth the potential performance hit). Further Improvements If we wish to make this more secure, I would suggest prompting the user for a one-time password - or generate a password for the user and write it to stdout - which will act as the key, and would be used for encryption when they are generating a token. The difference with the current implementation is that the private keys used for cryptography and verification will be strictly separated from the structure of the endpoint: they will only exist while the required message is being encrypted / decrypted after having been obtained by the user. Previously, a malicious agent really only needed to know the SECRET_KEY to compromise any SpecifyUser account. Now, the goal is that each of the following must hold true for a malicious agent to compromise a SpecifyUser account:
As such, a system administrator should generally follow the following steps to secure their instance:
|
Fixes #7398
Checklist
self-explanatory (or properly documented)
Testing instructions
https://discourse.specifysoftware.org/t/allow-support-login-documentation/2838/1
In your
.env
file, add the following:Usage steps:
docker exec -it specify7 /bin/bash
ve/bin/python manage.py support_login --username ${username}
${username}
with the desired account.SUPPORT_LOGIN_TTL
environment variable (e.g., 300 seconds).Example output:
base_url
+/accounts/support_login/?token=...
to access the user's account.