Skip to content

DOM XSS: document.write Sink Using Source location.search

Vulnerable snippet:

<script>
  function trackSearch(query) {
    document.write('<img src="/resources/images/tracker.gif?searchTerms='+query+'">');
  }
  var query = (new URLSearchParams(window.location.search)).get('search');
  if(query) {
    trackSearch(query);
  }
</script>

DOM Invader solves this one in a few seconds:

Clicking "Exploit" solves the lab.