Building Real Things
Don't Get Burned: Security Basics
You do not need to be a security expert — you need to not make the five classic mistakes that turn a weekend project into a very bad month.
Security sounds like an advanced topic. It is not — it is a beginner topic, because the worst breaches of small projects come from beginner mistakes, and AI-generated code makes several of them by default unless you know to ask. A few rules, learned once, prevent almost all of it.
The rules that prevent most disasters
- Secrets never go in frontend code — remember, the frontend is PUBLIC. API keys pasted "just to test" get scraped by bots within hours and can rack up real bills. Secrets live server-side, in environment variables, always.
- Never trust input from users — anything a person can type will eventually contain something hostile. Validate on the SERVER (frontend checks are politeness, not protection).
- Don't build your own login — use a proven auth service or framework feature. Hand-rolled password systems are how databases end up dumped online.
- The backend enforces the rules — hiding a button in the frontend is not security; the request it made can be sent by anyone directly. Every permission check belongs on the server.
- Keep secrets out of code-sharing too — a key committed to a public repository is compromised the moment it lands, even if you delete it after.
When you use AI to build, add one habit: ask it "what are the security problems with this code?" — it is genuinely good at auditing its own output, but only when asked. Generated code optimizes for working, not for safe; the review step is yours.
That is the whole beginner curriculum: secrets server-side, validate input, rent your auth, enforce on the backend, ask AI to audit. Five habits, learned in an afternoon, that separate builders from cautionary tales.
Key takeaways
This is one lesson of 541.
The whole Foundation is free — 16 subjects, beginner to advanced. Sign in to track what you have read, take the end-of-module quizzes, and use the terminal.