Should every tutorial be an entire 200-page course on all web security practices? Of course not.
But should every tutorial that inserts a user-provided value into a SQL statement ensure it's escaped? Of course. There's essentially literally never a situation where you shouldn't do that. It's not just to be "production-ready" -- it's so basic as just to make sure the query will still even parse if the user includes a quote character in their input.
So why on earth are you defending this mistake?
That might not be true for other security issues but I think tutorial writers should be fine saying "here is a bit of magic that fixes a problem called csrf. We won't cover that in this course but leave this in here"
Oh, that unicorn that everybody takes about, yet nobody does anything with it
So, how do you sanitize input?
you save in database escaped strings?
allow only "english" letters?
>- HTML injection
>- XSS
those two belong to
>- Escaping output
don't they?
>- Various timing attacks (eg password hashing)
>- How to store passwords
just use state of art auth/login handling libs?
>- DDoS and other resource exhaustion attacks
I don't think I'd add it there, isn't it handled by firewall / infrastructure than app directly?
Although most DDoS attacks happen on the layers 3, 4, and 6 of the OSI model, your application still has to be hardened against resource exhaustion and other DDoS attacks.
For example, if you have a REST endpoint that starts a complex query which might return a large result given some specific query parameters (e.g. your limit parameter is not bound, so I can set limit=1000000), running 10000 requests against it from different hosts (malicious or not) may bring down your database server.
The tutorials don't even need to talk about security: just tech secure by default APIs. If the programmer later needs more flexibility (which should be understood as an advanced topic), they ought to learn that you must sanitize user input in raw queries.
Those stupidly bad PHP tutorials that show you how to concatenate a URL parameter to an SQL string were easy to understand, and taught me about everything from writing PHP/SQL, setting up a MySQL server, networking/opening ports, designing database tables, designing an application, and much more. The motivation I got from learning so much in so little time led me to keep learning new things, including learning and understanding why all that code I wrote when I was younger was so bad.
If those shitty tutorials get copy and pasted into production codebases, that's the company's fault for hiring a lazy/bad developer, and for not catching the vulnerability.
So here's a partial list of issues you'd need to deal with:
- sanitizing input
- Escaping output
- SQL injection
- HTML injection
- XSS
- CSRF
- CORS
- Clickjacking
- DDoS and other resource exhaustion attacks
- Various timing attacks (eg password hashing)
- How to store passwords
- Depending on language, buffer overflows
That's... a lot. You can take this even further: you should assume you're going to get compromised at some point. What are you going to do to detect a breach? Or an active attempt to find a breach? What's your strategy for handling a breach?
Here's an analogy: we can tell you how to treat Poison Ivy without having to add a disclaimer that you're not qualified to be an attending dermatologist.