Web Security Lab -- Educational Demo

Open this file in your browser. This lab shows safe examples and comparisons (vulnerable vs secure patterns) -- for learning only.

Password Strength & Client-side Hash

Strength: --
--
Note: Hashing on the client is just educational. Always hash + salt on server using strong parameters (bcrypt, argon2) and TLS in transit.

XSS Demo -- Vulnerable vs Safely Rendered

Vulnerable area (shows raw HTML -- do NOT do this on real sites):
Safe area (uses textContent / sanitizer):
Lesson: never directly inject untrusted HTML. Use proper escaping, Content Security Policy (CSP), and server-side input validation.

SQL Injection -- Simulation

--
This is a client-side simulation showing how string concatenation could create a dangerous query. In real servers: always use parameterized queries / ORM / prepared statements.

CSRF Token Demo

This simulates a site issuing a CSRF token and checking it on form submit.

--
Server should tie CSRF token to user's session (cookie) and verify per-request. Use SameSite cookies and double-submit cookie/token patterns.