XSS attack to bypass htmlspecialchars() function in value attribute

后端 未结 5 1621
终归单人心
终归单人心 2020-12-24 13:48

Let\'s say we have this form, and the possible part for a user to inject malicious code is this below

...


        
5条回答
  •  不思量自难忘°
    2020-12-24 14:26

    value is a normal HTML attribute, and has nothing to do with Javascript.
    Therefore, String.fromCharCode is interpreted as a literal value, and is not executed.

    In order to inject script, you first need to force the parser to close the attribute, which will be difficult to do without >'".

    You forgot to put quotes around the attribute value, so all you need is a space.

    Even if you do quote the value, it may still be vulnerable; see this page.

提交回复
热议问题