Cross-Site Request Forgery (CSRF) happens when a web application cannot reliably tell if a user actually intended to submit a request, allowing an attacker to trick a user's browser into performing unwanted actions on their behalf.

Imagine you're logged into your bank's website in one tab. In another tab, you click a malicious link or visit a booby-trapped site. That malicious page can silently send a request to your bank's site—like a funds transfer—using your existing, logged-in session. Because your browser automatically includes your session cookies, the bank sees the request as legitimate and coming from you, even though you never intended to send it. To prevent this, applications must verify that state-changing requests (like logins, transfers, or profile updates) are deliberate. The most common and effective defense is to use anti-CSRF tokens: unique, secret values embedded in forms or requests that the server validates. Other protections include checking the `Origin` or `Referer` headers for same-origin requests, or requiring re-authentication for sensitive operations. Without these guards, attackers can exploit a user's trust in a site to perform actions without their consent.
Impact: Gain Privileges or Assume IdentityBypass Protection MechanismRead Application DataModify Application DataDoS: Crash, Exit, or Restart
The consequences will vary depending on the nature of the functionality that is vulnerable to CSRF. An attacker could trick a client into making an unintentional request to the web server via a URL, image load, XMLHttpRequest, etc., which would then be treated as an authentic request from the client - effectively performing any operations as the victim, leading to an exposure of data, unintended code execution, etc. If the victim is an administrator or privileged user, the consequences may include obtaining complete control over the web application - deleting or stealing data, uninstalling the product, or using it to launch other attacks against all of the product's users. Because the attacker has the identity of the victim, the scope of CSRF is limited only by the victim's privileges.
Strategy: Libraries or Frameworks
htmlphp
//if the session is registered to a valid user then allow update*
php
php
// read in the data from $POST and send an update*
phphtml
// send to profile.php* form.submit();}
htmlMedium