Common web security mistakes beginners make (and how to avoid them)
Most web vulnerabilities come from a small set of recurring mistakes. Knowing them covers a lot of ground.
- Trusting user input. Anything from the browser can be forged. Validate on the server, not just in the form.
- SQL injection. Building queries with string concatenation lets attackers rewrite them. Use parameterized queries or a trusted query builder.
- Cross-site scripting (XSS). Inserting user content into pages without escaping lets attackers run scripts. Modern frameworks escape by default; be careful with features that bypass that, like raw HTML injection.
- Weak authentication. Store passwords with a slow hashing algorithm such as bcrypt, scrypt or Argon2, never plain text or fast hashes. Consider using a proven auth provider.
- Broken access control. Checking that a user is logged in is not enough. Check they are allowed to access that specific record.
- Secrets in the frontend or repo. API keys in client-side code are public. Keep secrets on the server and out of version control.
- Missing security headers. Content Security Policy, HSTS and proper cookie flags (
HttpOnly,Secure,SameSite) add strong defenses. - Outdated dependencies. Known vulnerabilities in packages are an easy target; automate updates and audits.
The OWASP Top 10 is a good free reference for going deeper.
Which of these have you seen in real projects? What security practice would you make mandatory for every new web developer?
Comments · 2
Rolling your own auth is high on my list. The business risk of a breach dwarfs whatever time you saved.
Error messages that leak internals are a UX failing too. Users don't need a stack trace.