javascript - Exploiting jquery html encoding XSS -


this question has answer here:

after reading this question users warned method of encoding html unsafe

    return $('<div/>').html(encodedtext).text(); 

"don't use jquery.html().text() decode html entities it's unsafe because user input should never have access dom "

"i suggest using safer, more optimized function"

the purpose of method take encoded input i.e fish &amp; chips , produce unencoded output i.e fish & chips

so understand it, claim value of encodedtext, javascript can executed. tried reproduce setting encodedtext <script>alert(1)</script> , few other simple attacks , unable find signs of xss vulnerability.

my question is: there demonstrable xss vulnerability in browser when using $('<div/>').html(encodedtext).text()

there plenty of ways of doing it, 1 way onerror image tag.

var x = $("<div/>").html('<img src="x" onerror="alert(\'hi\');" />').text();  console.log(x);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -