admin_token in config.json shouldn't be in clear text #1250

Closed
opened 2025-10-09 17:09:02 +03:00 by OVERLORD · 11 comments
Owner

Originally created by @mgutt on GitHub.

I'm using the Vaultwarden docker container and was a little bit suprised seeing the admin token in clear text in /data/config.json:

image

Shouldn't this be a md5 hash or similar?

And of course this feature should be removed:
image

Originally created by @mgutt on GitHub. I'm using the Vaultwarden docker container and was a little bit suprised seeing the admin token in clear text in /data/config.json: ![image](https://user-images.githubusercontent.com/10757176/144743675-da9ebd4d-9359-4184-b615-34cf56bf802f.png) Shouldn't this be a md5 hash or similar? And of course this feature should be removed: ![image](https://user-images.githubusercontent.com/10757176/144744729-a3ae763b-bdc1-4f09-b119-b66d100cbccb.png)
Author
Owner

@BlackDex commented on GitHub:

To be fair, all password are stored there in clear text.
Same goes for using the env variables or using docker-compose.yml.
You should take care of the security of the server it self and not expose this items.

Also, why should you want to remove that specific feature?

And, it doesn't really matter if you change that token to an sha hash (md5 should never be used again) it won't give you that much extra security. Since if someone has access to those files, that means they have access to your server already which is probably a greater problem then that specific string of random chars being exposed.

There is a feature request already to add some extra login options to the admin, which until now hasn't been picked-up yet.

@BlackDex commented on GitHub: To be fair, all password are stored there in clear text. Same goes for using the env variables or using docker-compose.yml. You should take care of the security of the server it self and not expose this items. Also, why should you want to remove that specific feature? And, it doesn't really matter if you change that token to an sha hash (md5 should never be used again) it won't give you that much extra security. Since if someone has access to those files, that means they have access to your server already which is probably a greater problem then that specific string of random chars being exposed. There is a feature request already to add some extra login options to the admin, which until now hasn't been picked-up yet.
Author
Owner

@BlackDex commented on GitHub:

I'm specifically talking about the config.json, everything within the database is encrypted by the Bitwarden clients.

Ah okay, that reassures me 😅

Backups should be encrypted to in my opinion

Software should not have security holes. That's the problem with "should".

I agree, but that could be close to impossible sometimes. Though good design is half the job done. Same goes for backups, encrypting them and storing them off-site is half the job done on having it safe.

This reminds of an issue with Filezilla. Many years they stored the passwords in clear text. Someday (around 2009) a special trojan stole all Filezilla ftp credentials and spreaded itself through many websites. It took many years until the issue was solved. Now, all credentials are encrypted, which of course does not help if the trojan is active while Filezilla is open, but in 99% of the remaining time, they were safe and since then we never heard about similar issues.

Filezilla is using a master-password, which you either provide during startup of Filezilla or when you start the connection. Or, if I'm correct, it uses the keychain/keystore provide by the os/platform when available which unlocks when you login to your desktop account.
While this works great for interactive software on either GUI or CLI software, it isn't very helpful on server/deamonised software. Because that would need the password during startup. Something like this was the case long time ago when people though it would be good to put a password on there website keyfile, which then required you to provide a password at ever restart of Apache httpd.

In the end you need to provide a password or keyfile which is able to be used to decrypt/encrypt the secure values. And that needs user interaction or it needs the secret key to be stored as plain text somewhere. An other way would maybe be using some kind of public/private key, which then still needs to be stored near the server to be used, which gets you right back at the whole storie.

Well to be fair, you would only have access to the admin interface and while you can delete users etc you can't change there passwords or read the vault items or decrypt there attachments or anything.

Ok, good to know. But what about changing the URL to a phishing website or changing the email settings?

In theorie changing the url/domain doesn't do that much harm, it could prevent MFA to work, and attachments fail to download. Though mails could point people to a different domain which could pose a risk when people do not validate and check this.

While we could try to encrypt this, you still need to have a decryption key stored somewhere in plain text because the software needs to be able to decrypt/encrypt it

I thought the admin token is only used for accessing the admin UI, why is it needed to encrypt it?

It is only used to access the admin indeed. But if you don't want it plain text, as you probably also don't want the smtp password, hibp api key, duo secret key etc.. which are also stored in the confIg.json, then the only way is to encrypt the whole config.json file. Which then needs something to be used to encrypt and decrypt that file which needs to be available by the software, and probably you want that backed-up also.

In the end, if you do not want to have to interactivaly provide a password, you need some way to decrypt/encrypt the values stored in plain text.

PS Thank your for your detailed answers! 🤗

Sure!! No problem.

@BlackDex commented on GitHub: > > I'm specifically talking about the config.json, everything within the database is encrypted by the Bitwarden clients. > > Ah okay, that reassures me 😅 > > > Backups should be encrypted to in my opinion > > Software should not have security holes. That's the problem with "should". > I agree, but that could be close to impossible sometimes. Though good design is half the job done. Same goes for backups, encrypting them and storing them off-site is half the job done on having it safe. > This reminds of an issue with Filezilla. Many years they stored the passwords in clear text. Someday (around 2009) a special trojan stole all Filezilla ftp credentials and spreaded itself through many websites. It took many years until [the issue](https://trac.filezilla-project.org/ticket/5530) was solved. Now, all credentials are encrypted, which of course does not help if the trojan is active while Filezilla is open, but in 99% of the remaining time, they were safe and since then we never heard about similar issues. > Filezilla is using a master-password, which you either provide during startup of Filezilla or when you start the connection. Or, if I'm correct, it uses the keychain/keystore provide by the os/platform when available which unlocks when you login to your desktop account. While this works great for interactive software on either GUI or CLI software, it isn't very helpful on server/deamonised software. Because that would need the password during startup. Something like this was the case long time ago when people though it would be good to put a password on there website keyfile, which then required you to provide a password at ever restart of Apache httpd. In the end you need to provide a password or keyfile which is able to be used to decrypt/encrypt the secure values. And that needs user interaction or it needs the secret key to be stored as plain text somewhere. An other way would maybe be using some kind of public/private key, which then still needs to be stored near the server to be used, which gets you right back at the whole storie. > > Well to be fair, you would only have access to the admin interface and while you can delete users etc you can't change there passwords or read the vault items or decrypt there attachments or anything. > > Ok, good to know. But what about changing the URL to a phishing website or changing the email settings? > In theorie changing the url/domain doesn't do that much harm, it could prevent MFA to work, and attachments fail to download. Though mails could point people to a different domain which could pose a risk when people do not validate and check this. > > While we could try to encrypt this, you still need to have a decryption key stored somewhere in plain text because the software needs to be able to decrypt/encrypt it > > I thought the admin token is only used for accessing the admin UI, why is it needed to encrypt it? > It is only used to access the admin indeed. But if you don't want it plain text, as you probably also don't want the smtp password, hibp api key, duo secret key etc.. which are also stored in the confIg.json, then the only way is to encrypt the whole config.json file. Which then needs something to be used to encrypt and decrypt that file which needs to be available by the software, and probably you want that backed-up also. In the end, if you do not want to have to interactivaly provide a password, you need some way to decrypt/encrypt the values stored in plain text. > PS Thank your for your detailed answers! 🤗 Sure!! No problem.
Author
Owner

@mgutt commented on GitHub:

To be fair, all password are stored there in clear text.

Are they?! Why? I would expect AES encrypt/decrypt in the database for user passwords (de-/encrypted by user password) and a hash for the admin token.

won't give you that much extra security

If there is a security hole in the WebUI/Webserver/Linux, which allows loading specific files or direct access to the database, you wouldn't have access to the clear text passwords. Another scenario are stolen backups (which include the vaultwarden container). And no admin should have access to passwords of their users. IMHO this is obvious.

If you get access to a clear text password, then you have it. If you get access to an AES decrypted binary value, you need to bruteforce it. And depending on the strength of the user's password, this is an impossible task.

md5 should never be used again

IMHO md5 with a salt is as safe as any other hash algorithm. But nothing speaks against using SHA.

EDIT: Does not look like the user passwords are stored in clear text?!

image

@mgutt commented on GitHub: > To be fair, all password are stored there in clear text. Are they?! Why? I would expect AES encrypt/decrypt in the database for user passwords (de-/encrypted by user password) and a hash for the admin token. > won't give you that much extra security If there is a security hole in the WebUI/Webserver/Linux, which allows loading specific files or direct access to the database, you wouldn't have access to the clear text passwords. Another scenario are stolen backups (which include the vaultwarden container). And no admin should have access to passwords of their users. IMHO this is obvious. If you get access to a clear text password, then you have it. If you get access to an AES decrypted binary value, you need to bruteforce it. And depending on the strength of the user's password, this is an impossible task. > md5 should never be used again IMHO md5 with a salt is as safe as any other hash algorithm. But nothing speaks against using SHA. EDIT: Does not look like the user passwords are stored in clear text?! ![image](https://user-images.githubusercontent.com/10757176/144746488-13bbcb3e-d07b-4d80-9139-3912d4f5416e.png)
Author
Owner

@BlackDex commented on GitHub:

To be fair, all password are stored there in clear text.

Are they?! Why? I would expect AES encrypt/decrypt in the database for user passwords (de-/encrypted by user password) and a hash for the admin token.

I'm specifically talking about the config.json, everything within the database is encrypted by the Bitwarden clients.

won't give you that much extra security

If there is a security hole in the WebUI/Webserver/Linux, which allows loading specific files or direct access to the database, you wouldn't have access to the clear text passwords. Another scenario are stolen backups (which include the vaultwarden container). And no admin should have access to passwords of their users. IMHO this is obvious.

Backups should be encrypted to in my opinion.

If you get access to a clear text password, then you have it. If you get access to an AES decrypted binary value, you need to bruteforce it. And depending on the strength of the user's password, this is an impossible task.

Well to be fair, you would only have access to the admin interface and while you can delete users etc you can't change there passwords or read the vault items or decrypt there attachments or anything.

md5 should never be used again

IMHO md5 with a salt is as safe as any other hash algorithm. But nothing speaks against using SHA.
Why go for an outdated not encouraged hashing algo? In any case of hashing should be applied i would go for at least sha and not md5.

So, to be clear, all passwords and auth credentials are encrypted within the database. All items within the config.json aren't.

While we could try to encrypt this, you still need to have a decryption key stored somewhere in plain text because the software needs to be able to decrypt/encrypt it, and if that is backed-up then you are still exposing everything. It will slow down or maybe even halt ordinary people from seeing those items. But still it will not help in fully securing it

@BlackDex commented on GitHub: > > To be fair, all password are stored there in clear text. > > Are they?! Why? I would expect AES encrypt/decrypt in the database for user passwords (de-/encrypted by user password) and a hash for the admin token. > I'm specifically talking about the config.json, everything within the database is encrypted by the Bitwarden clients. > > won't give you that much extra security > > If there is a security hole in the WebUI/Webserver/Linux, which allows loading specific files or direct access to the database, you wouldn't have access to the clear text passwords. Another scenario are stolen backups (which include the vaultwarden container). And no admin should have access to passwords of their users. IMHO this is obvious. > Backups should be encrypted to in my opinion. > If you get access to a clear text password, then you have it. If you get access to an AES decrypted binary value, you need to bruteforce it. And depending on the strength of the user's password, this is an impossible task. > Well to be fair, you would only have access to the admin interface and while you can delete users etc you can't change there passwords or read the vault items or decrypt there attachments or anything. > > md5 should never be used again > > IMHO md5 with a salt is as safe as any other hash algorithm. But nothing speaks against using SHA. Why go for an outdated not encouraged hashing algo? In any case of hashing should be applied i would go for at least sha and not md5. So, to be clear, all passwords and auth credentials are encrypted within the database. All items within the config.json aren't. While we could try to encrypt this, you still need to have a decryption key stored somewhere in plain text because the software needs to be able to decrypt/encrypt it, and if that is backed-up then you are still exposing everything. It will slow down or maybe even halt ordinary people from seeing those items. But still it will not help in fully securing it
Author
Owner

@mgutt commented on GitHub:

I'm specifically talking about the config.json, everything within the database is encrypted by the Bitwarden clients.

Ah okay, that reassures me 😅

Backups should be encrypted to in my opinion

Software should not have security holes. That's the problem with "should".

This reminds of an issue with Filezilla. Many years they stored the passwords in clear text. Someday (around 2009) a special trojan stole all Filezilla ftp credentials and spreaded itself through many websites. It took many years until the issue was solved. Now, all credentials are encrypted, which of course does not help if the trojan is active while Filezilla is open, but in 99% of the remaining time, they were safe and since then we never heard about similar issues.

Well to be fair, you would only have access to the admin interface and while you can delete users etc you can't change there passwords or read the vault items or decrypt there attachments or anything.

Ok, good to know. But what about changing the URL to a phishing website or changing the email settings?

While we could try to encrypt this, you still need to have a decryption key stored somewhere in plain text because the software needs to be able to decrypt/encrypt it

I thought the admin token is only used for accessing the admin UI, why is it needed to encrypt it?

PS Thank your for your detailed answers! 🤗

@mgutt commented on GitHub: > I'm specifically talking about the config.json, everything within the database is encrypted by the Bitwarden clients. Ah okay, that reassures me 😅 > Backups should be encrypted to in my opinion Software should not have security holes. That's the problem with "should". This reminds of an issue with Filezilla. Many years they stored the passwords in clear text. Someday (around 2009) a special trojan stole all Filezilla ftp credentials and spreaded itself through many websites. It took many years until [the issue](https://trac.filezilla-project.org/ticket/5530) was solved. Now, all credentials are encrypted, which of course does not help if the trojan is active while Filezilla is open, but in 99% of the remaining time, they were safe and since then we never heard about similar issues. > Well to be fair, you would only have access to the admin interface and while you can delete users etc you can't change there passwords or read the vault items or decrypt there attachments or anything. Ok, good to know. But what about changing the URL to a phishing website or changing the email settings? > While we could try to encrypt this, you still need to have a decryption key stored somewhere in plain text because the software needs to be able to decrypt/encrypt it I thought the admin token is only used for accessing the admin UI, why is it needed to encrypt it? PS Thank your for your detailed answers! 🤗
Author
Owner

@dani-garcia commented on GitHub:

I'm not really sure if an encrypted config is workable, you'd have to provide the decryption key in an env variable if you want the server to launch automatically, and at that point you can just define the whole config in env variables (or using the _FILE variables to load the secrets from a file).

If we are to hash the admin token, I wouldn't allow the admins to pick an algorithm, I'd just use PBKDF2, which is already used for the users vaults password hashes.

@dani-garcia commented on GitHub: I'm not really sure if an encrypted config is workable, you'd have to provide the decryption key in an env variable if you want the server to launch automatically, and at that point you can just define the whole config in env variables (or using the `_FILE` variables to load the secrets from a file). If we are to hash the admin token, I wouldn't allow the admins to pick an algorithm, I'd just use PBKDF2, which is already used for the users vaults password hashes.
Author
Owner

@jjlin commented on GitHub:

I don't see admin token hashing as particularly useful, but if it were to be added, a relatively clean way could be to use password-hash to hash to PHC format. It would be easy to detect whether the token is hashed or not, so people could use either hashed or unhashed tokens transparently. Perhaps there would be an extra button on the admin page to convert an unhashed token to a hashed version and save it.

@jjlin commented on GitHub: I don't see admin token hashing as particularly useful, but if it were to be added, a relatively clean way could be to use [`password-hash`](https://users.rust-lang.org/t/announcing-the-password-hash-crate/55383) to hash to PHC format. It would be easy to detect whether the token is hashed or not, so people could use either hashed or unhashed tokens transparently. Perhaps there would be an extra button on the admin page to convert an unhashed token to a hashed version and save it.
Author
Owner

@AcidGreg commented on GitHub:

I also felt a bit uncomfortable with the admin token in plain sight on the filesystem. I think it is not unreasonable to also support storing it as a hash as well, maybe with an additional variable to define the behavior if necessary. Maybe something like ADMIN_TOKEN_SECURITY=plaintext(default)/MD5/etc..

I would be interested in giving it a go myself, if no one else prefers to tackle it. I don't think it would be too complicated and it'd be a nice exercise of some off work nerding. ;-)

@AcidGreg commented on GitHub: I also felt a bit uncomfortable with the admin token in plain sight on the filesystem. I think it is not unreasonable to also support storing it as a hash as well, maybe with an additional variable to define the behavior if necessary. Maybe something like ADMIN_TOKEN_SECURITY=plaintext(default)/MD5/etc.. I would be interested in giving it a go myself, if no one else prefers to tackle it. I don't think it would be too complicated and it'd be a nice exercise of some off work nerding. ;-)
Author
Owner

@AcidGreg commented on GitHub:

If we are to hash the admin token, I wouldn't allow the admins to pick an algorithm, I'd just use PBKDF2, which is already used for the users vaults password hashes.

If I understand correctly, the user then would need extra inputs (salt, etc.) and a mechanism (new web page of the app?) to produce the hash.

My thought was to use an algorithm without salting, which is far better than plaintext, but still allows for a quick conversion of a plaintext password to a hashed value using any appropriate online converter or command line / GUI tool. I was thinking convenience along avoiding the dread of the plaintext token. :D

That said... I am not very familiar with the security/cryptography fields, so I hope I am not suggesting silly things.

@AcidGreg commented on GitHub: > If we are to hash the admin token, I wouldn't allow the admins to pick an algorithm, I'd just use PBKDF2, which is already used for the users vaults password hashes. If I understand correctly, the user then would need extra inputs (salt, etc.) and a mechanism (new web page of the app?) to produce the hash. My thought was to use an algorithm without salting, which is far better than plaintext, but still allows for a quick conversion of a plaintext password to a hashed value using any appropriate online converter or command line / GUI tool. I was thinking convenience along avoiding the dread of the plaintext token. :D That said... I am not very familiar with the security/cryptography fields, so I hope I am not suggesting silly things.
Author
Owner

@mgutt commented on GitHub:

people could use either hashed or unhashed tokens transparently. Perhaps there would be an extra button on the admin page to convert an unhashed token to a hashed version and save it.

People could easily overwrite the value. No need to decrypt their password.

I would suggest if the config file contains a non-hased value, it is hashed on first login. By that the admin is able to reset it through the config file.

@mgutt commented on GitHub: > people could use either hashed or unhashed tokens transparently. Perhaps there would be an extra button on the admin page to convert an unhashed token to a hashed version and save it. People could easily overwrite the value. No need to decrypt their password. I would suggest if the config file contains a non-hased value, it is hashed on first login. By that the admin is able to reset it through the config file.
Author
Owner

@BlackDex commented on GitHub:

And then still you would have your mail server password in plain text within that file. It will do you no good by only hashing that specific string of text.

@BlackDex commented on GitHub: And then still you would have your mail server password in plain text within that file. It will do you no good by only hashing that specific string of text.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/vaultwarden#1250