Small projects get attacked too, usually by automated scripts looking for easy wins. The good news: a short checklist removes most of the easy wins.
Authentication
- Hash passwords with a slow algorithm (bcrypt or argon2).
- Require two-factor authentication for admin accounts.
- Rate-limit login attempts and lock accounts after repeated failures.
- Use
HttpOnly,SecureandSameSitecookies.
Input and output
Never trust input. Validate everything on the server, even if the browser already did:
const schema = z.object({
email: z.email(),
message: z.string().min(10).max(5000),
});
And escape or sanitize anything you render, especially user-generated Markdown or HTML.
Headers
A strict Content-Security-Policy, X-Content-Type-Options: nosniff and frame-ancestors 'none' block whole classes of attacks for almost no effort.
Secrets and infrastructure
- Keep secrets in environment variables, never in the repository.
- Don't expose your database to the internet.
- Run containers as a non-root user.
- Keep dependencies updated.
Backups
Security also means recovering from mistakes. Automate backups and test a restore at least once.
None of this is glamorous, but it's the difference between a quiet week and a very bad one.
