简体   繁体   中英

XSS mitigation in HTML/VBScript/Classic ASP

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM