Cross-site scripting attacks are considered as type of injection wherein malicious scripts are being injected into the other benign as well as trusted web sites. This would occur once a certain attacker uses a web application in order to send malicious code which is particularly in the form of a browser side script up to a different end user. The flaws that allow the said attacks to be successful are quite widespread and so occur anywhere as web application would use input coming from a user within the output that it generates even without encoding or validating it.
A certain attacker might also use cross-site scripting in sending malicious script into an unsuspecting user. The browser of the end user has no way to know which the script must be trusted and might execute the script as well. Since it thinks that the certain script came from a certain trusted source, this malicious script could access any session tokens, cookies and some other sensitive information being retained by the browser and being used with the site. The said scripts could even rewrite the content into the HTML page. In simpler form, cross-site scripting could happen once data enters the web application by untrusted source most particularly a web request and also once the data is being included within dynamic content which is sent into a web user having not to validate the malicious content.
Two Types of Cross-site Scripting
- Server XSS – this occurs once untrusted user has supplied data that is included in an HTML response being generated by the server. The data source might be from the request or could be from stored location. In such case, the entire vulnerability is into the server-side code as well as the browser is simply rendering the response as well as executing any of the valid script being embedded into it.
So how does this cross-site scripting works?