Probably Are Gonna Need It: Application Security Edition
jacobian.org
jacobian.org
I think one of the hardest things to add after the fact are security headers. Once marketing is involved with an app's marketing site, it's going to be hard to add them in later. So I add them from day one, ace the Mozilla Observatory thing, and then if marketing needs something special, we can always deal with it then. Usually the result is something more secure, but sometimes turning off a flag for a single page is fine.
If it's the style of app where the backend is basically just a JSON API + workers, I like to follow JSON API[0] but I always add the `meta` and `errors` fields, even if it's just an empty dict, but usually there is something meta, like the latest versions of the client and server or a rate limit use + available combo. It makes writing clients easier. It also has knock-on effects, for example a delete request never gets a 204 NO CONTENT, since there is always content!
Once you get a consistent API the frontend just snaps together. Every now and then you may have to deviate a bit for performance or third-party reasons, but it's fine.
[0] jsonapi.org
It's so, so easy for PII and other sensitive data to end up copied to a staging environment, which has a higher chance of shipping a security vulnerability than the production environment does (plus exposes data to staff within an organization).
Strictly allow-listing columns from the start seems like a great way to minimize accidental leaks.
This way we only need to restore the insensitive schema to staging areas, and have different backup policies, keeping the insensitive far longer.
The best advice I’ve seen on this: https://research.nccgroup.com/2020/04/21/code-patterns-for-a...
Basically, one guide that explains all the security features, how they work, when they should be used, associated configuration settings, what defaults are, what other possible values are, known gotchas, how to verify security features are working correctly, which ports and protocols are used and when they're used (so that a firewall admin can setup accordingly), etc.
pbkdf2_sha256$260000$theHashDataGoesHere
The algorithm comes first, then the number of iterations, then finally the hash value.This makes it possible to increase iterations or even switch algorithms upgrade and re-hash existing passwords automatically later on when users sign in. Django handles this for you.
Another good reason to use a mature, extensively tested mechanism for authentication rather than rolling your own from scratch.
This also means you have a chance to crack any improper salt/secret storage, such as provisioning into memory only.
You will still need to do a password upgrade on login, but you at least have now made it a requirement that an attacker not only grab your database, but also a memory snapshot or disk snapshot.
I have been building websites professionally for nearly two decades. In that time I have seen major attacks against a number of sites I worked on. They were ALL exploits in up to date frameworks/applications found by bots scanning for known vulnerabilities. In order of severity Wordpress, Django, osCommerce; Django was actually the most recent.
I’ve never had a custom built app compromised. Unless you’re some major player, no one wants to take the time to find flaws in your snowflake (outside query injection and the other common things you should know to protect against with experience). They find a flaw in a framework or library and then try to apply the known flaw everywhere.
Should every site be a snowflake? Surely not, not every developer is competent enough to build safe applications. Does it come with major upsides? Absolutely.
That you are aware of.
... why?
Twitter allows anyone to reply-to or quote-tweet anyone else, for example. That has a huge impact on how abuse works on that service.
The abusive-ex persona Jacob describes is super-useful for avoiding making bad design decisions early on that end up being too hard to fix.