Live data from Hacker News

Web Developer Security Checklist

simplesecurity.sensedeep.com

71–80 of 249 posts

Re: Web Developer Security Checklist

#71

Besides the bad SQL tips most of it is okay. Sounds like the author has little experience with ORM's or SQL abstraction layers with parameterization like ADO.NET, SQLAlchemy, or JDBC. Besides the SQL stuff mentioned elsewhere, Regex is rarely a safe whitelist. It's better to use specific escapes for HTML or URI or whatever. Most of XSS is finding bad input that isn't filtered. Hardly anyone is stupid enough to not fi…

Thanks for the tips. Can you say which SQL tip is bad, someone has already picked up the Stored procedure comment -- really meant prepared statements. Regarding regexp. You can do very precise regexp for many patterns. I agree some are harder, but I wouldn't say "rarely" in our experience. The point about port 22 is that if you have it open, many people tend to use it more than they should. Effective automation shoul…

A lot of Regex is a hint that you shouldn't be using regex. Regex is a bad parser and poor sanitizer.

I would wager that more than 50% of XSS vulnerabilities are due to bad regex when you should be using HTML or URI escape

Re: Web Developer Security Checklist

#72
post #67

Earlier quoted context omitted.

Yes it does that and that will rule it out for some apps. An option for many sites is to configure CloudFlare in pass-through mode (no MITM) and then just switch it on when you are being DOS'd.

Is that even an option? Where is that setting?

That is the cloud icon. Make it gray and it is just a DNS. i.e. DOS protection armed and ready, but not active until you need it. That is how we use it.

Re: Web Developer Security Checklist

#73
post #53

Earlier quoted context omitted.

Your data is in the clear within Cloudflare, and may even be in the clear between Cloudflare and the real host if you choose that option. You're trusting Cloudflare's security and Cloudflare's internal certificate authority. Hundreds or thousands of sites would be compromised if Cloudflare had a security breach. Like the one they had three months ago.[1] [1] https://techcrunch.com/2017/02/23/major-cloudflare-bug-leak…

Data is only 'in the clear' inside a machine. All machine to machine communication in Cloudflare is encrypted with mutually authenticated TLS. If a user chooses to not encrypt the back haul from Cloudflare to their origin then, sure, that's not encrypted, but we offer free certificates for origin machines so there's no reason to use that option. If you don't like Cloudflare's Origin CA then use Let's Encrypt on the o…

Thanks so much for clarifying. We use your service - would recommend in a heartbeat.

Re: Web Developer Security Checklist

#74
post #14

While it means well, I think some of this advice is pretty bad, or at least unbalanced. From the very first section: > Encrypt all data at rest in the database ALL data? How are you supposed to query against it then? What does "at rest" even mean in the context of an always-on database? An encrypted partition or something? I'm not even sure what this is supposed to mean and it is certainly not common practise. > Use…

> ALL data? How are you supposed to query against it then? What does "at rest" even mean in the context of an always-on database? An encrypted partition or something?

Data at rest means data on the disk. (so basically LUKS or similar partition / FDE) In virtualised environments it may not obvious, but the disk you're running on can still be accessed in various ways. Here are some examples (not a complete list):

- VM breakout allows someone to read others' volumes

- logic issue allows others to snapshot your volumes

- disk is marked as bad, then discarded without full erase / physical destruction, then found in the dump

> So two layers of encryption!? Again, how is one supposed to look up an access token or email address if it is encrypted?

You don't have to encrypt the things you index. It's more to do with PII, addresses, etc. which you don't want to accidentally expose, and don't have to access too often outside of systems like billing.

It may also prevent you from storing a copy by accident. For example if you serialise a whole record to the output due to type/variable mistake. Or by revealing it in an error message. Of course these shouldn't happen anyway, but it's a good protection in practice.

> And it strikes me that if you don't trust the first level of encryption, the solution is to fix that, not add another one.

Nobody writes ideal code. There will be bugs. You prepare for that using defence in depth. This may mean separate minimal services handing out the sensitive data with extra audit steps. It may mean encrypting the data with a password not stored in the database, so that a trivial dump doesn't give access to them. "fix that" is not simple, otherwise we'd just "fix" all software :)

> That is an extraordinarily inefficient and costly way to develop.

It's the most trivial way to avoid all SQL injections. It's used in lots of projects. As long as you don't need to use parameters where they're not allowed in your database (for example table names), it's not a bad idea at all.

But if you have an ORM and want to use it - great. Most likely your ORM, or framework you use already takes advantage of prepared statements. If it doesn't you end up like Drupal recently (please correct me if I got the framework wrong) which did their own escaping because of prefixed table names and was broken at the framework level.

> be cautious about what you allow into queries.

This is what's extraordinarily inefficient. People make mistakes. Given big enough project, if you allow text queries, or try to be clever with own escaping systems, someone will make a mistake one day. Prepared queries (and good, tested ORMs) get rid of the whole class of issues here and are much more common solution than you suggest.

Re: Web Developer Security Checklist

#75
post #68
post #53

Earlier quoted context omitted.

Your data is in the clear within Cloudflare, and may even be in the clear between Cloudflare and the real host if you choose that option. You're trusting Cloudflare's security and Cloudflare's internal certificate authority. Hundreds or thousands of sites would be compromised if Cloudflare had a security breach. Like the one they had three months ago.[1] [1] https://techcrunch.com/2017/02/23/major-cloudflare-bug-leak…

> Your data is in the clear within Cloudflare Just a heads up you're telling Cloudflare's CTO how Cloudflare works

You never know... I might learn something :-)

Re: Web Developer Security Checklist

#77

This list could just as well be called "List of security stuff I learned about when making my product". Some of the stuff is just Draconian, certainly not applicable for any arbitrary web developer.

There are rarely any checklists applicable everywhere in the same way. Why not treat it as: list of ideas to evaluate and prioritise/ignore into your own checklist for future/current project? It's not like it's all invalid because it's not fully applicable.

Re: Web Developer Security Checklist

#78
post #68
post #53

Earlier quoted context omitted.

Your data is in the clear within Cloudflare, and may even be in the clear between Cloudflare and the real host if you choose that option. You're trusting Cloudflare's security and Cloudflare's internal certificate authority. Hundreds or thousands of sites would be compromised if Cloudflare had a security breach. Like the one they had three months ago.[1] [1] https://techcrunch.com/2017/02/23/major-cloudflare-bug-leak…

> Your data is in the clear within Cloudflare Just a heads up you're telling Cloudflare's CTO how Cloudflare works

Just a heads up - it's the inventor of Nagle algorithm telling Cloudflare's CTO how Cloudflare works. This could be very interesting ;) (also stuff like that happens quite a lot on HN, I recommend using some user tagger extension)

Re: Web Developer Security Checklist

#79
post #67

Earlier quoted context omitted.

Is that even an option? Where is that setting?

That is the cloud icon. Make it gray and it is just a DNS. i.e. DOS protection armed and ready, but not active until you need it. That is how we use it.

Ah I see, I thought there might be a setting I'd missed that just forwards your traffic through without cache etc

Re: Web Developer Security Checklist

#80
post #68

Earlier quoted context omitted.

> Your data is in the clear within Cloudflare Just a heads up you're telling Cloudflare's CTO how Cloudflare works

You never know... I might learn something :-)

Oh for sure - I wasn't saying it to shut the conversation down, more to point out you're speaking with the knowledge of how the innards work :)

I could have worded it to say that better but was dashing out of the house

Post reply on HN