# CSRF

## What is CSRF

Cross-Site Request Forgery (CSRF) is a type of web attack that exploits the trust between a website and its users. It occurs when an attacker tricks a user's browser into making an unintended and unauthorized request to a target website on which the user is authenticated.

Here's how it works:

* The user visits a malicious website or clicks on a malicious link that the attacker has crafted.
* The malicious website contains code that automatically sends a request to a legitimate website where the user is authenticated, without the user's knowledge.
* Since the user is already logged in to the legitimate website, the browser automatically includes the necessary authentication credentials in the request.
* The legitimate website receives the request, assumes it's legitimate due to the included authentication credentials, and performs the requested action, such as changing the user's password, making a purchase, or deleting an account.

The key point to understand is that the attack relies on the user's browser sending authenticated requests to the target website, unbeknownst to the user. The attacker can't directly access the user's credentials but rather exploits the trust between the user's browser and the targeted website.

## Resources

* [CSRF Complete guide Rana Khalil](https://youtu.be/7bTNMSqCMI0?si=f8CpPNHprDDYDnVJ)
* [CSRF Explained NahamSec](https://youtu.be/wYazaHJ3l0E?si=AH4_6YJ0hmBhp6oB)
* [Finding your first bug CSRF Katie Paxton Fear](https://youtu.be/ULvf6N8AL2A?si=h-6zyYaz6f2T9LGJ)
* [CSRF on PortSwigger](https://portswigger.net/web-security/csrf)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://csbygb.gitbook.io/pentips/web-pentesting/webvulns/csrf.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
