2. HTTP Verb Tampering

HTTP protocol works by accepting various HTTP methods as verbs.

Programmers mainly consider the most two commonly used methods: GET and POST - however, clients can send any other methods in http requests and see how the webserver handles them.


HTTP has 9 different verbs that can be accepted as HTTP methods by web servers. https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods

Aside from GET + POST:

Verb Description
HEAD Identical to a GET request, but its response only contains the headers, without the response body
PUT Writes the request payload to the specified location
DELETE Deletes the resource at the specified location
OPTIONS Shows different options accepted by a web server, like accepted HTTP verbs
PATCH Apply partial modifications to the resource at the specified location

Some of the above perform some very sensitive functions. Writing (PUT) or deleting (DELETE) files to the webroot dir on the back-end server.

If a webserver isn't configured to manage these, we can use them to gain control over the backend server. What makes http verb tampering attacks more common (hence more critical) is that they are caused by a miscconfiguration in either the backend webserv or webapp - either of which are capable of causing this behavior


Insecure configurations

Insecure webserv configs cause the first type of HTTP verb tampering vulns:

<Limit GET POST> 
	Require valid user
</Limit> 

Even though the configuration specifies both GET+POST reqs for auth method an attacker may still use a different HTTP method (like HEAD) to bypass this authentication mechanism altogether. This eventually leads to an auth bypass and allows attackers to access web pages + domains they otherwise would not be able to.


Insecure coding

Insecure coding practices also introduce this vuln even though some may not consider it verb tampering necessarily.

Dev applies filters to mitigate vulns; not covering all http methods with that filter.

$pattern = "/^[A-Za-z\s]+$/";

if(preg_match($pattern, $_GET["code"])) {
    $query = "Select * from ports where port_code like '%" . $_REQUEST["code"] . "%'";
    ...SNIP...
}

Sanitization filter only includes the GET parameter. If GET requests do not contain any bad characters - query would be executed.

Both above vulns are found in public - the second one is much more common as it is due to mistakes made in coding

First is usually avoided by secure webserver configurations as documentation often cautions against it.


Bypassing basic authentication

Usually detecting and exploiting this is relatively straightforward.

Just need to try alternate HTTP methods and see how they are handled by webserver/webapp

While many automated vulnerability scanning tools can consistently identify HTTP Verb Tampering vulns caused by insecure server configurations they usually miss identifying HTTP tampering vulns caused by insecure coding.

Identifying insecure server configurations

Suppose filesharing app.

Step 1)

stejwes@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

Seen above - HEAD is acceptable. (This is default behavior for many webservers) Repeat above with HEAD, we will see we no longer get a login prompt or 401 unauth page and get empty output. Navigating back to file manager app we see all files have been deleted.


![](/img/Pasted image 20241207220213.png) ![](/img/Pasted image 20241207220229.png) ![](/img/Pasted image 20241207220242.png)

![](/img/Pasted image 20241207220311.png) ![](/img/Pasted image 20241207220405.png) didnt work like the example but PUT worked, trust bro ![](/img/Pasted image 20241207221206.png)


Bypassing security filters

The other more common http verb tampering vulnerability is caused by Insecure coding

Step 1)


![](/img/Pasted image 20241207222337.png) ![](/img/Pasted image 20241207222419.png)

Changed the request method with burp in below image ![](/img/Pasted image 20241207222504.png) ![](/img/Pasted image 20241207222512.png)


Verb tampering prevention

Remember: two things involved here

*The below covers insecure configurations. *

Vulns can occur in most modern webservers including Apache, Tomcat, and ASP.NET

Example of a vulnerable config for Apache located in site configuration file 000-default.conf or a .htaccess webpage conf file

<Directory "/var/www/html/admin">
    AuthType Basic
    AuthName "Admin Panel"
    AuthUserFile /etc/apache2/.htpasswd
    <Limit GET>
        Require valid-user
    </Limit>
</Directory>

As we see above this configuration is setting the authorization configurations for the admin web dir. However <Limit GET> keyword being used the Require valid-user setting will only apply to GET requests leaving the page accessible through POST requests Even if both GET and POST were specified this would leave the page accessible through other methods like HEAD or OPTIONS

<security-constraint>
    <web-resource-collection>
        <url-pattern>/admin/*</url-pattern>
        <http-method>GET</http-method>
    </web-resource-collection>
    <auth-constraint>
        <role-name>admin</role-name>
    </auth-constraint>
</security-constraint>

This example below shows same vulnerability for Tomcat. (found in web.xml ) We can see auth is being limited only to the GET method with http-method leaving other methods accessible

<system.web>
    <authorization>
        <allow verbs="GET" roles="admin">
            <deny verbs="GET" users="*">
        </deny>
        </allow>
    </authorization>
</system.web>

This is an example of a ASP.NET config for web.config file of webapp allow and deny scope limited to the GET method which leaves the webapp accessible through other HTTP methods


These examples above show it is not secure to limit the authorization configuration to a specific HTTP verb We should always avoid restricting authorization to a single method and always allow/deny ALL http verbs and methods

If we want to specify a single method, we can use safe keywords like LimitExcept in apache ; http-method-omission in Tomcat and add/remove in ASP.NET which should cover all verbs except the specified ones

To avoid similar attacks - generally conside disabling/denying all HEAD requests unless specifically required by the webapp


The below covers insecure coding

While identifying + patching insecure webconfs is relatively easy doing the same for insecure code is much more challenging, this is because to identify this vulnerability in the code, we need to find inconsistencies in the use of http parameters across functions, as in some instances, this may lead to unprotected functionalities and filters.

Consider PHP code from our file manager exercise

if (isset($_REQUEST['filename'])) {
    if (!preg_match('/[^A-Za-z0-9. _-]/', $_POST['filename'])) {
        system("touch " . $_REQUEST['filename']);
    } else {
        echo "Malicious Request Denied!";
    }
}

If we were only considering command injection vulns we would say this is securely coded. the preg_match fx properly looks for special chars. fatal error? = inconsistent use of HTTP methods.

Thus, in prev section when we were sending our malicious input through a GET request it did not get stopped by the preg_match function as the POST params were empty and hence did not contain any special characters

Minor inconsistencies in http methods can lead to critical vulnerabilities. In a production webapplication these types of vulns will not be as obvious and would likely be spread across the webapp and will not be on two consecutive lines like we have in the aebove example

Moral of the story here is to be consistent with the use of HTTP methods

Language Function
PHP $_REQUEST['param']
Java request.getParameter('param')
C# Request['param']