Cross-Site Request Forgery (CSRF)

Overview

How CSRF Works

Example Attack: Password Change

External JavaScript Example

"><script src=//www.example.com/exploit.js></script>

Risks

Prevention

Input Controls

Type Description
Sanitization Remove special/non-standard characters from user input.
Validation Ensure input matches expected formats (e.g., emails, usernames).

Browser and Server-Level Defenses

Modern Defenses (and Limitations)

Despite all protections, no solution is 100% foolproof. Developers must design applications with layered security and secure coding best practices.

Additional Resources