
OLdev (Community Member) asked a question.
Hi, I've resolved all but one XSS vulnerability scan found by Veracode, and the last one I have absolutely no idea how to fix at all. The line reads:
var $zipCodeEntry = $(element).find('.zip-code-entry');
Yeah element is a variable rather than hard coded string, but I've had similar codes scattered elsewhere and they were not flagged for XSS vulnerability. Why this one particulaly triggered Veracode? How do I address this issue properly? Thanks.
.png)
Hi @OLdev (Community Member) - hope you're doing well!
$() is a jQuery selector function that can lead to XSS depending on the version of jQuery used. If you're on the latest version of jQuery, it's likely not an issue but it still recommended to validate any data passed into the application to potentially risky functions like this. Also, this particular item is likely being flagged because element is seen as tainted and other usage they have elsewhere might not be.
So for this, you can likely put in some validation and propose a mitigation to close out flaw. If you still have questions, Create a Case with the details of the scan or you can schedule a consultation call to review/discuss in more detail.
Here's the vulnerability with jQuery described in a bit more detail: https://portswigger.net/web-security/cross-site-scripting/dom-based/lab-jquery-selector-hash-change-event