-
Notifications
You must be signed in to change notification settings - Fork 80
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
Store token in a more secure manner , support pairs of tokens #808
Comments
You should be able to pass the token using the HCLOUD_TOKEN env var, without storing it in any configuration file, for example: export HCLOUD_TOKEN="$(get-hcloud-token)"
hcloud server list
I think this is a good idea, not sure if a library already offers a way to do this on all the platforms that we support. An alternative would be to provide a
The ideal solution would be to have fine-grained permissions on the tokens (per operations/per resources), but we are limited by what the API supports. You should already be able to store the read only token in a context, and use env var for the read/write tokens. |
Not a good idea to store secrets in environment, since environments can be read from other processes. |
Thanks for the suggestion. Do you have any tools where you like how this is implemented? |
e.g. mutt as a mail client or aws-cli for the Amazon Cloud do allow to configure to use the output of a subcommand as a credential https://docs.aws.amazon.com/cli/v1/userguide/cli-chap-configure.html Better solutions would require to modify the Hetzner API itself, e.g. use FIDO tokens or a TLS client certificate in a PKCS#11-Token or TPM for authentication. There would be a lightweight solution which would not require to change the API, which is used by latest version of ssh client: Store the credential (here the API token) encrypted with gpg or a FIDO token in a file, and use gpg or the FIDO token to decrypt the credential inside the process, then use it as a regular token. This way you don't need to change the API, since all magic happens inside the client, but I am not really sure, how secure this is at the end of the day (and still depends on the client cli programm has not been tampered with). https://developers.yubico.com/SSH/Securing_SSH_with_FIDO2.html https://fido.ftsafe.com/open-ssh-with-fido-keys/ https://swjm.blog/the-complete-guide-to-ssh-with-fido2-security-keys-841063a04252 Maybe also have a look at Clevis/Tang and how they do store their secrets. So there's mainly two options:
Just calling some external program to fetch and output the token on stdout and read it from there might be by far the most flexible and easiest to implement way, because it allows to use any wallet or token, leaving it as the external program's problem how to do it. |
Unfortunately, although I would love to see some changes on how authentication and project management is handled in the API, we have to work with what we have right now. |
This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs. |
TL;DR
hcloud stores the tokens in plaintext in ~/.config/hcloud/cli.toml , where any other process, including any which reads from or includes files from random paths, making it too easy to steal the tokens.
Since hcloud enforces the use of these contexts stored in that file, and does not allow to pass the token per command (like, e.g. terraform/opentofu does) to the process without storing it, this is highly insecure and puts the tokens into high risk of beeing stolen, rendering the 2FA for the login to the Hetzner web console effectively useless.
Expected behavior
More secure handling of tokens, e.g.
The text was updated successfully, but these errors were encountered: