server icon indicating copy to clipboard operation
server copied to clipboard

smtp password stored in clear/plain text

Open cdmlb opened this issue 7 years ago • 8 comments

https://github.com/nextcloud/server/blob/master/config/config.sample.php#L409

smtp password Could we get this saved as a hash instead of clear/plain text in the config file?

cdmlb avatar Dec 15 '18 02:12 cdmlb

If I'm right we need it in plain text to authenticate against the smtp server. So how should we hash it?

violoncelloCH avatar Dec 15 '18 22:12 violoncelloCH

Good question, I was wondering that part you bring up myself. I wonder how others do it if they even do it at all when it comes to adding one email account to another email account aka adding your hotmail to your gmail, etc. I wonder how they do it, might be scary to think of it lolol.

cdmlb avatar Dec 16 '18 00:12 cdmlb

I'm thinking the encrypted password could just be:

user entered password plain text magic function to encrypt saved to config file as encrypted magic function to decrypt when using it with the smtp server

would have to be a reversible encryption nothing complicated just as long as the saved password in file is not human readable but can be decrypted on the fly when using it to connect to the server

could be as simple as an array of characters A = $ B = 0 C = A D = - etc... like sure people would see this in code since opensource but at least the file for someone that don't understand code could not just open or download the file and just say oh there's the password I can read it using my own two eyes and no brain.

cdmlb avatar Dec 16 '18 00:12 cdmlb

This site I think does something like

Saves the decrypted data in a table and the hashed data in the same record when they look up the hash as an id key maybe, they just use it to reference the original decrypted data?

https://md5hashing.net/hash/

"At md5hashing.net you can hash (encrypt) any string into 66! different hash types. As you probably know - decryption of any hash is impossible, but we offer reverse decryption via our database (~1000M records, and counting)."

cdmlb avatar Dec 16 '18 00:12 cdmlb

Maybe just as simple as storing the settings in the database instead of in a config file for the smtp info in plain text form. At least the data in a table in a db would be a layer of security than a file on the webserver.

idk I'm just brain storming stuff here my bad lololol.

cdmlb avatar Dec 16 '18 00:12 cdmlb

Of course we could use symmetric encryption, but we would need to store the key to decrypt on the same server, so from a security point of view that's quite useless. You should configure your server so that nobody (except the admin) has access to the config.php anyway (database credentials and other sensitive information have to be stored there too). What do you think @nextcloud/security ?

violoncelloCH avatar Dec 16 '18 22:12 violoncelloCH

As already said by @violoncelloCH it makes no sense. All info that is needed to decrypt it from any algorithm needs to be stored too, so everyone that has access to the config can always decrypt it.

Moving the info to the database does not help at all. "Security by obscurity" is the term to google here. It would only help if someone has access to your config, but that also contains the database password, so they can access the database too now.

nickvergessen avatar Dec 16 '18 23:12 nickvergessen

I have rainloop installed and I looked at how they save the external email account info and it's encrypted for the password not plain text so they must be doing something to decrypt it. The info is not in a database either, it's in a text file.

Location nextcloud/data/rainloop-storage/data/default/storage/cfg/--WTV--/--WTV--/accounts

Shows your email address in plain text and your encrypted account password not in plain text I added my hotmail account to it.

I have not figured out how to decrypt it, looking over db now and rest of file system.

cdmlb avatar Dec 17 '18 00:12 cdmlb