3 ms·
In most cases, encrypting sensitive information like e-mail addresses with a memory-resident key (e.g. injected using tools like Vault) in the application layer
by ThePhysicist 6y ago
In most cases, encrypting sensitive information like e-mail addresses with a memory-resident key (e.g. injected using tools like Vault) in the application layer is a better strategy, at least if you need asynchronous access to that information (e.g. to send out weekly update e-mails). Most of the data leaks in the past were caused by compromised or misconfigured databases, not by compromised application server code.
Also, within the EU I need to be able to proactively reach my users (e.g. to notify them about a data loss), so only storing hashes of e-mail addresses and hoping users will log in so that I can send them an e-mail won't work.
- aitchnyu 6y agoIs that generalizaion true for other forms of data theft too? I feel that way about some wrongly public s3 buckets and document leaks.
- ThePhysicist 6y agoSure if you encrypt with an application-level key it makes it harder for any adversary to use your data, as he/she will need to not only get access to your data but also obtain the encryption key to do anything with it. Encrypting data like this is easy and can drastically reduce your attack surface.
- franky47 6y agoThis kind of encryption-at-rest scheme becomes an absolute necessity when cryptographic secrets have to be stored, such as 2FA TOTP secret keys or recovery codes. Encrypting the email addresses and any Personally Identifiable Information on your users may also be a good practice, to limit which eyes can actually see the plaintext data (database provider, former developers without rotated credentials, an old backup left over..). One issue with this though could be the inability to use the encrypted field for queries (eg: select * from users where email = 'foo@bar.com'), but OP's solution of hashing can help here: store the email encrypted, its hash in clear text, and do a query on the hash.
- Znafon 6y agoYou could also use convergent encryption (https://www.vaultproject.io/docs/secrets/transit#convergent-encryption https://www.vaultproject.io/docs/secrets/transit#convergent-...) to do this with only one field.
- gfauchart 6y agoyou need to reach your users in case of data breach, but what if you have zero “Personal Data” ? you could still hash the email I imagine
- renewiltord 6y agoWell the hashed email is Personal Data. https://www.google.com/url?sa=t&source=web&rct=j&url=https://ec.europa.eu/justice/article-29/documentation/opinion-recommendation/files/2014/wp216_en.pdf&ved=2ahUKEwjy__vgn-TsAhXMup4KHZCACEIQFjAAegQIEBAB&usg=AOvVaw0WnSkyDWQZ9IXWo1b3k6rM https://www.google.com/url?sa=t&source=web&rct=j&url=https:/... Sorry for the Google link, I can't figure out how to copy the direct link on Android Chrome.
- GoblinSlayer 6y agoClick the link, then copy the address from address bar, if it still exists.