> For the complete documentation index, see [llms.txt](https://csbygb.gitbook.io/pentips/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://csbygb.gitbook.io/pentips/web-pentesting/webvulns/csrf.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
