Avoid disabling ValidateInput on controller | CAST Appmarq

Avoid disabling ValidateInput on controller


Rule Definition
Cross-Site Scripting (XSS) attacks are a type of injection, in which malicious scripts are injected into otherwise benign and trusted websites. XSS attacks occur when an attacker uses a web application to send malicious code, generally in the form of a browser side script, to a different end user. Flaws that allow these attacks to succeed are quite widespread and occur anywhere a web application uses input from a user within the output it generates without validating or encoding it. An attacker can use XSS to send a malicious script to an unsuspecting user. The end user’s browser has no way to know that the script should not be trusted, and will execute the script. Because it thinks the script came from a trusted source, the malicious script can access any cookies, session tokens, or other sensitive information retained by the browser and used with that site. These scripts can even rewrite the content of the HTML page. For more details on the different types of XSS flaws, see: Types of Cross-Site Scripting. Request Validation is a feature that prevents potentially dangerous content from being submitted. This feature is enabled by default. However, at times you might need your application to post HTML markup tags to the server. You would then need this feature to be disabled.

Remediation
Ensure the validation request is always enabled when using HttpPost/HttpPut (or equivalent) requests

Violation Code Sample
[ValidateInput(false)]
 public class HomeController : Controller
 {
 }
Fixed Code Sample
[ValidateInput(true)]
 public class HomeController : Controller
 {
 }

Reference
https://docs.microsoft.com/en-us/aspnet/whitepapers/request-validation https://www.owasp.org/index.php/Top_10-2017_A7-Cross-Site_Scripting_(XSS)

Related Technologies

Health Factor

  Total Quality Index


Technical Criterion
CWE-79 - Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

About CAST Appmarq

CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.

Benchmark Statistics

Global Compliance

nan%

Total Violations
0
Total Opportunities
0
Average Violations / App.
nan
The compliance score represents 1 minus the ratio between the number of times a rule has been violated compared to the number of opportunities in a set of applications that the rule could have been violated.

Industry Insights

Telecommunications

98.06%

Select from drop-down

99.95%

Don't Know

99.57%