# HTTP Verb Tampering

Intro to HTTP Verb Tampering

The first type of HTTP Verb Tampering vulnerability is mainly caused by `Insecure Web Server Configurations`, and exploiting this vulnerability can allow us to bypass the HTTP Basic Authentication prompt on certain pages.

***

### Identify

When we start the exercise at the end of this section, we see that we have a basic `File Manager` web application, in which we can add new files by typing their names and hitting `enter`:

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

However, suppose we try to delete all files by clicking on the red `Reset` button. In that case, we see that this functionality seems to be restricted for authenticated users only, as we get the following `HTTP Basic Auth` prompt:

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

As we do not have any credentials, we will get a `401 Unauthorized` page

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

So, let's see whether we can bypass this with an HTTP Verb Tampering attack. To do so, we need to identify which pages are restricted by this authentication. If we examine the HTTP request after clicking the Reset button or look at the URL that the button navigates to after clicking it, we see that it is at `/admin/reset.php`. So, either the `/admin` directory is restricted to authenticated users only, or only the `/admin/reset.php` page is. We can confirm this by visiting the `/admin` directory, and we do indeed get prompted to log in again. This means that the full `/admin` directory is restricted.

### Exploit

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

As the page uses a `GET` request, we can send a `POST` request and see whether the web page allows `POST` requests (i.e., whether the Authentication covers `POST` requests). To do so, we can right-click on the intercepted request in Burp and select `Change Request Method`, and it will automatically change the request into a `POST` request:

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

Once we do so, we can click `Forward` and examine the page in our browser. Unfortunately, we still get prompted to log in and will get a `401 Unauthorized` page if we don't provide the credentials:

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

So, it seems like the web server configurations do cover both `GET` and `POST` requests. However, as we have previously learned, we can utilize many other HTTP methods, most notably the `HEAD` method, which is identical to a `GET` request but does not return the body in the HTTP response. If this is successful, we may not receive any output, but the `reset` function should still get executed, which is our main target.

To see whether the server accepts `HEAD` requests, we can send an `OPTIONS` request to it and see what HTTP methods are accepted, as follows:

```shell-session
eldeim@htb[/htb]$ curl -i -X OPTIONS http://SERVER_IP:PORT/

HTTP/1.1 200 OK
Date: 
Server: Apache/2.4.41 (Ubuntu)
Allow: POST,OPTIONS,HEAD,GET
Content-Length: 0
Content-Type: httpd/unix-directory
```

As we can see, the response shows `Allow: POST,OPTIONS,HEAD,GET`, which means that the web server indeed accepts `HEAD` requests, which is the default configuration for many web servers. So, let's try to intercept the `reset` request again, and this time use a `HEAD` request to see how the web server handles it:

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

Once we change `POST` to `HEAD` and forward the request, we will see that we no longer get a login prompt or a `401 Unauthorized` page and get an empty output instead, as expected with a `HEAD` request. If we go back to the `File Manager` web application, we will see that all files have indeed been deleted, meaning that we successfully triggered the `Reset` functionality without having admin access or any credentials:

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

### PoCs - Questions

* Try to use what you learned in this section to access the 'reset.php' page and delete all files. Once all files are deleted, you should get the flag.

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

I can write into new file name and for example, put the same name "notes.txt", with it, i will be to intercept the peticion with burp -->

<figure><img src="/files/6cZmn2Y1jEAum53NmBf3" alt=""><figcaption></figcaption></figure>

For this peticion, it return us "Unauthoried", but if you replace the GET for DELETE, maybe the system think we need DELETE it without auth -->

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

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

## Bypassing Security Filters

This is commonly found in security filters that detect malicious requests. For example, if a security filter was being used to detect injection vulnerabilities and only checked for injections in `POST` parameters (e.g. `$_POST['parameter']`), it may be possible to bypass it by simply changing the request method to `GET`.

***

### Identify

In the `File Manager` web application, if we try to create a new file name with special characters in its name (e.g. `test;`), we get the following message:

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

This message shows that the web application uses certain filters on the back-end to identify injection attempts and then blocks any malicious requests

### Exploit

To try and exploit this vulnerability, let's intercept the request in Burp Suite (Burp) and then use `Change Request Method` to change it to another method:

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

This time, we did not get the `Malicious Request Denied!` message, and our file was successfully created:

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

So, we can inject a command that creates two files and then check whether both files were created. To do so, we will use the following file name in our attack (`file1; touch file2;`):

<figure><img src="/files/6toLa5v3qaTirYNuxeb4" alt=""><figcaption></figcaption></figure>

Then, we can once again change the request method to a `GET` request:

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

Once we send our request, we see that this time both `file1` and `file2` were created:

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

### PoCs - Questions

* To get the flag, try to bypass the command injection filter through HTTP Verb Tampering, while using the following filename: file; cp /flag.txt ./

<figure><img src="/files/3QWgynj9EI4t3aD2HwKh" alt=""><figcaption></figcaption></figure>

We cannot do anything without prior permissions, but we can see that the peticion is GET, change it for POST, but we can know, the parameter filename -->

<figure><img src="/files/5BJ16rwMMhhvLGgP5XoT" alt=""><figcaption></figcaption></figure>

> Remenber, urlencoder the file name


---

# Agent Instructions: 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:

```
GET https://eldeim.gitbook.io/brain_fuck/notes/certifications/eastereggs/htb-cbbh/web-attacks/http-verb-tampering.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
