[FIX] XSS validating context and encoding HTML#1
Conversation
There was a problem hiding this comment.
JQuery.parseHTML() is not a good mitigation for XSS vulnerabilities, it's bypassable. The fix also doesn't seem well fit in the codebase, you rewrote the parseJSON function to throw a console error which initially just returned a new window.
Good approach tho, without having a PoC! 👏
📚 References:
|
Hi @mufeedvh 😄
A different solution was using I checked if the fix was broken also making a function like this: function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}and evaluating the passed
Let me know if the part regarding Cheers, |
|
@mufeedvh - just to confirm, are you happy with this fix? |
|
Attaching reference (jquery-form#580)! 🍰 @kevindb - we will look to open this pull request now! |
|
Congratulations Mik317 - your fix has been selected! 🎉 Thanks for being part of the community & helping secure the world's open source code. |





📊 Metadata *
Please enter the direct URL for this bounty on huntr.dev. This is compulsory and will help us process your bounty submission quicker.
Bounty URL: https://www.huntr.dev/bounties/1-npm-form
⚙️ Description *
The
formlibrary suffered of aXSSissue, which was caused by 2 minor issues inside thecode, which made possible the usage ofevalonunsanitized values(inside the "override" ofparseJSON) andhtml parsingon aunsanitized AJAX response.💻 Technical Description *
The 2 issues have been fixed in the following way:
The
evalinside theparseJSONfunction has been removed, while it's been added aerrorwhich arises when the default$.parseJSONfunction (onjquery) isn't declared (anyone with good intentions would simply add thejqueryscript on the page and all works correctly again).The
)
unsanitized AJAX responsewas previously passed toparseHTMLwithout any check, making possible inject additionalHTML. I used a peculiarity ofjqueryto translate theHTMLnodes evaluated intotext nodes, which are equal toHTML encoded entities(can be verified seeing this:🐛 Proof of Concept (PoC) *
No PoC was provided, so I worked mostly theoretically on the issue/lines identified by the 2 issues in the
original repo🔥 Proof of Fix (PoF) *
Theoretical fix 😄
👍 User Acceptance Testing (UAT)
Can't be sure of this but seems all OK (nodes are still nodes of different type and a function is null --> arises exception due to a function undefined)