Hi All. I've got a question about blocking php re...
# water-cooler
n
Hi All. I've got a question about blocking php requests to our server, which runs CF on IIS. I haven't been able to do it as easily as expected and was wondering if others have solved this problem. In IIS, I've set up a basic rule to block php requests using the "Request Filtering" module. It seems to be working on a browser inside our server in the sense that when I make a browser request /inside our server/ such as https://www.domain.com/index.php, I see the IIS 404.5 Not Found screen indicating that the request has been blocked. And, it's not in our FusionReactor request history. That's good. But, outside our server, when I run the same browser request from my desktop, 1) the website displays with our custom/friendly 404 error message, and 2) the request displays in our FusionReactor request history. So, it seems that the request from my desktop is getting to both CF and FusionReactor. I was hoping to block these kinds of junk requests upstream of our ColdFusion sites AND our FusionReactor request displays so that they consume minimal resources and don't muck up our logging. Are there better ways to block these kinds of requests from getting to CF? Should I be using a different IIS module, like URL Rewrite?
c
I don't know if it's "better", but I am using an IIS Rewrite rule to throw 404 errors on several non-ColdFusion extensions and url patterns. This is based on several pen tests and the resulting errors thrown in ColdBox/ColdFusion when it can't match to a defined CF route.
Copy code
<rule name="Invalid Request Blocking" stopProcessing="true">
                    <match url="^wsman$|^(sdk|portal|DB4Web)\/(.*)$|^(.*)\.(pl|asp|aspx|cgi|dll|php|jsp|jsf|fts|http).*|^admin\/(statistics|login|airflow)(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="CustomResponse" statusCode="404" subStatusCode="5" statusReason="URL sequence denied." statusDescription="The specified URL sequence is not accepted by the server." />
                </rule>
I add to it as new pen test URLs are attempted and throw errors in my CF app. The last part of the regex might need tweaking if you actually need a URL of
/admin/login
n
@cfvonner Thanks for your response. It sounds like URL Rewrite may be a better bet than the Request Filtering module, although that doesn't seem that intuitive to me. Using the URL Rewrite UI, here is what I had created: <rule name="RequestBlockingRule1" patternSyntax="Wildcard" stopProcessing="true"> <match url="*" /> <conditions> <add input="{URL}" pattern=".php" /> </conditions> <action type="AbortRequest" /> </rule>
But, when I run this in a browser (e.g. www.domain.com/index.php), it still gets to the website (and triggers our friendly error process). I was hoping to block it altogether.
c
What version of Windows/IIS?
On Windows 2019/IIS 10 here. Using CF Standard installed via the normal GUI installer and lockdown tool.
n
Does your code stop it completely from getting to your site?
yes, we're also on Windows 2019 / IIS 10
also CF Standard
c
Yes, I get an IIS 404.5 screen and the request never hits CF.
n
Yes, that's what I'm trying to get. That's what I get when I am browsing inside the server. but on the outside, it gets to our site.
@cfvonner It may be that our IIS request filter is catching the issue first (due to a php filter there) and re-directing into our custom 404 path/file. This MS documentation speaks to the order or processing in IIS
e
Usually, these are bad bots, I would suggest using a proxy before your app server and blocking the request. There are plenty of ways to do this, from CDN's , F5 boxes, to just defining your own rules for handling bots. Unless your site is tiny and has very low traffic, its more effective to pre-screen your traffic before it hits your application server.