Reputation: 123
I'm faced with the following hypothetical XSS vulnerability in my web code:
original code: <INPUT TYPE=HIDDEN NAME='acctno' VALUE='" &Session("acctno")& "'>
hacked code: <INPUT TYPE=HIDDEN NAME='acctno' VALUE='12345'/><script>alert(98765)</script>
Can I mitigate this simply by adding HTMLEncode
to the session variable in the value field?
Thanks.
Upvotes: 0
Views: 1070
Reputation: 887459
Exactly. You need to HTML encode all text that gets inserted into the HTML.
You also need to Javascript-encode any text that gets inserted into Javascript code, and you need to URL-encode any text that gets inserted into URLs.
Upvotes: 1