> For the complete documentation index, see [llms.txt](https://kunalwalavalkar.gitbook.io/write-ups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kunalwalavalkar.gitbook.io/write-ups/bwapp/html-injection-reflected-get.md).

# HTML Injection - Reflected (GET)

## Security level: low

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2F47DZNJ9CxrA5h87bgyxW%2F1.png?alt=media&amp;token=44020870-37b3-43f5-9310-79d2c990ccae" alt=""><figcaption></figcaption></figure>

We are provided with two input fields to enter the first and last name.

Let's give it some random name and see what happens.

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FeVZeefm2slJ4Q2pu0Xgi%2F2.png?alt=media&amp;token=29c8556c-e302-4cb5-9525-3dd27f9f9e8e" alt=""><figcaption></figcaption></figure>

Looks like our input is reflected back on the screen.

### HTML injection

HTML injection is a type of injection when the user is able to enter arbitrary HTML code in a web page. This allows us to modify the contents of the page.

Let's input the following HTML tag:

```
First name: 
<h1>john</h1>

Last name: 
<h2>doe</h2>
```

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FlWC7ucpdkGh19MkUECR4%2F3.png?alt=media&amp;token=2da104ad-2927-4824-aedc-3baaeb86f237" alt=""><figcaption></figcaption></figure>

## Security level: medium

Let's try inserting the same input as before.

```
First name: 
<h1>john</h1>

Last name: 
<h2>doe</h2>
```

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FXpoumogyDWTT1Px7GbXo%2F4.png?alt=media&amp;token=e00a3632-f03b-4436-aad9-3d3065c96e2c" alt=""><figcaption></figcaption></figure>

This time the input is not treated as HTML code.

We can intercept the request in Burpsuite to check how out input is being treated.

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2Fov5XgyuuvMAeGjr5fipQ%2F5.png?alt=media&amp;token=709b7414-34d3-441e-8d8b-8f3b99d9dc8f" alt=""><figcaption></figcaption></figure>

As we can see the input is URL encoded. We can also check this out in the `Decoder`.

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2F2vya1jg3fsi1upWiuKOR%2F6.png?alt=media&amp;token=9bee5c89-bfa1-4a3b-beff-dc51202803b0" alt=""><figcaption></figcaption></figure>

We can bypass the security filter using double URL encoding as suggested in [this](https://owasp.org/www-community/Double_Encoding) OWASP document.

### Double URL encoding

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2F5DS6QCTQ9xv6tzsBQhQz%2F7.png?alt=media&amp;token=bd4b07b0-c372-4049-97bd-fbd1be1e9580" alt=""><figcaption></figcaption></figure>

```
%25%33%63%25%36%38%25%33%31%25%33%65%25%36%61%25%36%66%25%36%38%25%36%65%25%33%63%25%32%66%25%36%38%25%33%31%25%33%65
```

Let's forward the request to the `Repeater` so that we can make modifications.

We can now provide the double encoded string as the input.&#x20;

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2F0SouXnmE5FFhHo0w5ZrY%2F8.png?alt=media&amp;token=35fa7536-ac73-4483-be3f-9cce25933a17" alt=""><figcaption></figcaption></figure>

As we can see the name is now treated as an `h1` element. This means we have successfully performed URL injection.
