I have an ASP.NET web application which uses HTTPS and XML based request-response. It seems a user's session cookie can be retrieved via XSS, if the request/response is intercepted and malicious JavaScript code is added as a payload.
Since it is an XML based request-response, the payload has to be HTML encoded. Here is an example:
"<iframe name="if(0){\u0061lert(1)}else{\u0061lert(document.cookie)}" onload="eval(name)"/>
Is there any way I can stop executing any malicious script?
- How to identify a request/response containing a malicious script? I noticed that all malicious scripts must contain
"
,&
,(
and)
, but user data may also contain these characters. - How do I stop such a script to be run on users' browsers? I have already tried decoding all request/ response to corrupt the script which works, but my requests/responses contain user data which contains characters like
&
. This leads to the whole XML to become corrupt, which crashes the application.