> 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

### Explorando XXE por meio de upload de arquivo de imagem

Explorando uma vulnerabilidade XXE ao enviar 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 o upload de um avatar SVG exibindo `/etc/hostname` o conteúdo e, em seguida, 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="/files/a75503b6d068b5a327e732b139737c92c68fe8d3" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/b5df2d0cd02ef737e22c5a102bead8ff2f4b629d" 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="/files/09c734e54a8c4e3d261e15c37a98455f3ed33001" 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="/files/f23d3b3a8bebd357dbe14fc74ad8073cd5101429" 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/xxe/xxe-via-malicious-image-upload.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.
