1

Is this code vulnerable to DOM based XSS?

The application is using jQuery 1.12.4 and i noticed that Data is read from window.location.hash and passed to $() via the following statements:

var target_ = window.location.hash.substr(1);
$('html, body').animate({ 
    scrollTop: $("." + target_).offset().top - $(".site-header").outerHeight() 
}, 1000);

What payload could I use to trigger an alert box or execute any JS code? Is this code vulnerable or 100% safe?

alecxe
  • 1,515
  • 5
  • 19
  • 34
Jamyzed
  • 11
  • 2

1 Answers1

1

The code snippet you shared above is not vulnerable to DOM-based XSS. jQuery version 1.12.4 is not affected by the selector XSS bug. I highly recommend using http://research.insecurelabs.org/jquery/test/ to determine if a specific version of jQuery is affected by any publicly-disclosed vulnerabilities.

enter image description here

EdOverflow
  • 1,246
  • 8
  • 21