Answer the question
In order to leave comments, you need to log in
Why doesn't xss work?
I wrote two versions of the same code. The bottom line is that the user enters malicious code into the input field:
As a result, the jquery code executes the alert command. And the nativeJS code does not execute. LIVE DEMO
Please help me to make the nativeJS code also execute the alert command. It is not necessary to use innerHTML.
I tried using createElement/createTextNode instead of innerHTML , but that didn't work either. Although the jquery method uses them, judging by the sources
<script>alert('xss attack')</script>
Answer the question
In order to leave comments, you need to log in
Script elements inserted using innerHTML do not execute when they are inserted.
<img src='x' onerror='alert(1)'>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question