Zero Trust
Zero Trust means “never trust, always verify.” In practice: treat all user input as untrusted, validate it strictly, and sanitize/encode on output. This lesson keeps it practical for your first feature.
The OWASP Top 10 is a community‑maintained list of the most common and serious web application risks. Think of it as a practical safety checklist for web apps. One of the biggest items is Cross‑Site Scripting (XSS) – exactly what Zero Trust helps prevent by default. (Injection, another big one, becomes relevant once you add a database in the next level – we'll flag where it fits.)
1. What goes wrong without validation and sanitization
In human terms: if your app accepts text and shows it to others (comments, names, messages), attackers can sneak in scripts or special characters that run code in your users’ browsers. That’s XSS – the risk that’s real right now, before you even have a database.
Examples you might encounter:
- XSS (Cross‑Site Scripting):
- Harmless‑looking input like
<script>alert('xss')</script>or<img src=x onerror=alert(1)>ends up rendered as HTML and runs JavaScript in someone else’s browser. - Impact: pop‑ups are the demo; real attacks can steal cookies, tokens, and session data.
- Harmless‑looking input like
Key technical ideas alongside the plain language:
- “Validate”: ensure input has the right type/shape/length (e.g., via Zod schemas) before accepting it.
- “Sanitize/encode”: strip or neutralize dangerous characters before output (e.g., encode HTML), and never render raw HTML unless sanitized.
When you add a database in the next level, a second risk shows up: injection (e.g., SQL injection), where input like ' OR 1=1 -- tries to change a query instead of being treated as data. The same never‑trust‑input rule applies – Claude will use parameterized queries (prepared statements) so user input can’t become a command. You don’t need to do anything about it yet; just know the principle carries straight over.
Outcome: You can explain XSS in plain language, name the essential defenses, and know that the same principle will cover injection once you have a database.
2. Harden your first feature (prompts + updates + commit)
Assume your first feature includes a form submission. We’ll guide Claude to find inputs, add validation, and sanitize/encode outputs. Then we’ll review and commit.
Zod is a lightweight TypeScript‑first schema library for runtime validation. Define a schema once and use it on client (forms) and server (API routes/server actions) so only valid data gets through. See Zod docs.
Outcome: Your feature validates inputs and encodes outputs so user text can’t run as code.
3. Try common attack payloads (manual smoke test)
Manually test a few classic payloads in your form to verify defenses.
Outcome: Inputs that previously could be dangerous are now rejected or rendered safely as plain text.
4. Ship the secured feature
Your defenses are in and tested – ship them. Since you're working on main, committing and pushing sends the hardened feature live.
Outcome: Your hardened feature is live.