The error you are seeing is request validation which is a security mechanism that comes OOTB with ASP.net. These errors can be triggered by multiple scenarios, including:
- Malicious bot traffic (most common)
- User tampering
- Improperly encoded links on your site
- Improperly encoded backlinks on external sites
There are an unbounded amount combinations and permutations of such requests, so it can be tricky to catch all of them. If your site is protected by a WAF (and it should be!), you probably won't see many of these errors, if any. I recommend setting up rules to block these types of requests so that they never reach your application in the first place. You can also implement IP blocking or RECAPTCHA actions when the rules are triggered.
However, it is common for Sitecore site endpoints to not be secured by a WAF, in which case, I recommend blocking the requests with inbound filters in IIS. You could start by slapping down requests for dot files such as .php
and .asp
which are probably not on your server at all (be sure to check, though). Other good ones are *<script>*
and *%3Cscript%3E*
.
It is important to set up some broad blocking rules for such requests, as not doing so can lead to interesting second and third order consequences such as:
- Noise in the logs
- Malicious strings showing up in error logging tools that you may use, and worse yet, if the error logging tool does not properly encode the strings, it can cause UI issues or even result in XSS exploits in your third party tools
- Free advertising for hackers when you view their requests in the logs (URLs often contain URLs that advertise gambling, pornography, and phishing sites)
Another option is to ignore such errors entirely (but not to disable the validation).
Final point: there are some legitimate cases in which HTML / special characters in URLs may need to be accepted by your server, so setting up such blocking rules can cause issues. Familiarize yourself with your codebase and any external systems that your site may be integrated with to ensure that you don't break anything.