PowerShell Script to Test for TRACE method
This article has been superseded by this one.
No further updates will be made to this article.
UPDATE: This script has been slightly updated to allow you to test for other methods. See here for more details.
In a previous post, I described an iRule for BigIP that will allow you to disable the TRACE method, which you can attach to your VIPs instead of manually checking your hundreds of servers to verify whether the TRACE method is enabled or disabled. Most modern web servers, including Apache, IIS 6+, tomcat 5.5+) ship with the TRACE method disabled, however.
I described in another post a theory as to why the PCI scanner keeps flagging your sites as being vulnerable because it is not actually running a TRACE but is executing an OPTIONS method instead and scraping the Response Headers. You could ask your third-party auditer yourself but they may not know or won't tell you. This makes verification that the vulnerability has really been remedied up to you.
The following PowerShell script, which was only slightly adapted from the very good book Pro Windows PowerShell
testSiteForTrace.ps1 http://www.apache.org
returns True but testSiteForTrace.ps1 http://www.apache.org/
returns False. If anyone knows, let me know please.param ($url)
trap{
Write-Host $_
$request.Abort()
continue
}
$request = [System.Net.WebRequest]::Create($url)
$request.Method = "TRACE"
$request.TimeOut = 5000
if ($request.GetResponse().StatusCode -eq "200"){
$request.GetResponse().Close()
return $true
}
return $false
Running this against one of my sites, I get the following message:
The underlying connection was closed: An unexpected error occurred on a receive.
Which is perfect!