News for hackers. Stuff that matters.
Re:Web Developer Security Checklist by aeronautic on Tuesday May 16, 2017 @03:49AM (#14348030)
If the hacker gets access to the database due to a network config error, then they will be able to query the database, but only get records with some sensitive fields encrypted.

Given the number of email addresses that have been hacked and stolen (3.75 billion in Troy Hunt's haveibeenpwned alone), I believe doing one little extra bit of encryption on email addresses is worthwhile. We push that into our ORM layer and can easily flag any field in the database to be encrypted.

On very, very high volume accessed tables, you may not want to do that. But for user logon details -- for us it was a no brainer.

Re:Web Developer Security Checklist by creepydata on Tuesday May 16, 2017 @11:06AM (#14350155)
Psst, I really hate to break it to you but you are "stealing" and "hacking" your users email addresses ever time you send them an email!

https://www.troyhunt.com/im-sorry-but-your-email-address-is-...

Re:Web Developer Security Checklist by stephenr on Tuesday May 16, 2017 @04:04AM (#14348073)
Wait, so you encrypt the user's email before it's inserted into the table?

Are you using a different field for 'username' on logins, or do you have to jump through some hoops to find an encrypted email to do a login check against the pw hash?

Re:Web Developer Security Checklist by k__ on Tuesday May 16, 2017 @05:25AM (#14348363)
Can't you encrypt the entered email and search with that?
Re:Web Developer Security Checklist by aeronautic on Tuesday May 16, 2017 @05:34AM (#14348395)
Password hashes are handled separately using bcrypt - another story.

For the User.email field, we crypt/decrypt in the ORM/DB layer. So we search with the encrypted value that is stored in the db. App code provides plain-text email, ORM encrypts and searches with that value. Symmetric encryption of short strings is pretty fast and this is not a high volume API.

We use rate limiting on the API to protect against DOS on this API.

Re:Web Developer Security Checklist by arjie on Tuesday May 16, 2017 @05:46AM (#14348437)
If it's symmetric, then doesn't an app vulnerability make it possible for you to leak your key? Then the app also contains access credentials to the DB, so vulnerabilities in the app will still lead to real access to the DB, right?
Re:Web Developer Security Checklist by aeronautic on Tuesday May 16, 2017 @05:54AM (#14348456)
Yes, we're not protecting against the app being attacked, the key being jacked and then the attacker getting access to the db. Rather, we're protecting the database against being accessed directly. That could happen due to an error in configuring network access to the database or another service could be compromised that has access to the same database -- as has happened to many mongo databases over this year.
Re:Web Developer Security Checklist by stephenr on Tuesday May 16, 2017 @06:29AM (#14348563)
So your solution to fixing a basic ops problem 'software package A was exposed to the internet with(out|effectively no) auth' is: encrypt shit in an ORM layer and destroy your ability to do anything beyond absolute string comparison queries.

No thanks.

Re:Web Developer Security Checklist by aeronautic on Tuesday May 16, 2017 @06:37AM (#14348586)
No, we don't encrypt indiscriminately. We selectively pick fields to encrypt - fields that are highly sensitive.

And you are right, we do this because an ops error can easily make a mistake sometime in the future and probably will one day. We all make mistakes and defense in depth is all about that.

Re:Web Developer Security Checklist by swsieber on Tuesday May 16, 2017 @08:53AM (#14349138)
It does seem like emails are a good fit for encryption. I can't see wanting to do anything more than simple equality checks.
Re:Web Developer Security Checklist by thatwebdude on Tuesday May 16, 2017 @11:15AM (#14350217)
I could see a use case to see which emails are from what TLD.

For instance, all @gmail, all @yahoo, all @aol.

Maybe you want to do the cool "hey we noticed your email on haveibeenpwnd, you should change you password here just in case". In which case, anything other than plain text could prevent that from happening.

Hashing an email in that sense gets much more difficult, no?

Re:Web Developer Security Checklist by eropple on Tuesday May 16, 2017 @11:41AM (#14350421)
If you have enough emails that you can't SELECT * FROM users and do that query in memory, you're probably in a spot where you should not be picking security advice from a blog like this.

(That's not a negative as to this blog, it's really good and I've recommended it to multiple clients already, but that level of acumen should already be assumed at that scale. If you don't have it, this blog post is insufficient.)

Re:Web Developer Security Checklist by edraferi on Tuesday May 16, 2017 @08:16AM (#14348946)
This is an interesting solution, thanks for sharing. This would be a cool feature to build into open source ORMs.
Re:Web Developer Security Checklist by EGreg on Tuesday May 16, 2017 @08:40AM (#14349077)
This is a good idea, but only for fields which can never be used in range based index lookups.
Re:Web Developer Security Checklist by arjie on Tuesday May 16, 2017 @09:48AM (#14349519)
I see. Makes sense. Thanks for sharing this approach.
Re:Web Developer Security Checklist by ams6110 on Tuesday May 16, 2017 @09:59AM (#14349610)
Never mind that email addresses are sent in the clear all over the internet every day in normal SMTP traffic?
Re:Web Developer Security Checklist by wglb on Tuesday May 16, 2017 @08:32PM (#14354605)
I am wondering if you are clear on exactly what database encryption protects you against.

Hint: not much at all.