Cross-Site Request Forgery (CSRF) is an attack that forces an authenticated user to execute unintended actions on a web application. The attack succeeds when an application relies solely on information automatically provided by the browser (such as cookies or HTTP-based authentication like Basic Auth) to identify a session, without requiring additional proof of intent from the user.
Core Requirements for CSRF:
- Browser Behavior: The browser automatically sends session-related information (cookies, HTTP auth) with requests to the target site.
- Attacker Knowledge: The attacker knows valid URLs, parameters, or functional endpoints of the application.
- Session Management Flaw: The application relies exclusively on browser-managed credentials for authentication/authorization.
- Trigger Mechanism: The existence of HTML tags (like
<img>) or links that trigger automatic HTTP requests.