We will look at eval, href and dangerouslySetHTML vulnerabilities. In principle, a website is vulnerable to DOM-based cross-site scripting if there is an executable path via which data can propagate from source to sink. This cheatsheet is a list of techniques to prevent or limit the impact of XSS. The doubleJavaScriptEncodedData has its first layer of JavaScript encoding reversed (upon execution) in the single quotes. -->, "javascript:myFunction('<%=ESAPI.encoder().encodeForJavascript(untrustedData)%>', 'test');", "<%=ESAPI.encoder().encodeForHTML(last_name)%>", //when the value is retrieved the encoding is reversed. The document.write sink works with script elements, so you can use a simple payload, such as the one below: Note, however, that in some situations the content that is written to document.write includes some surrounding context that you need to take account of in your exploit. The most common one would be adding it to an href or src attribute of an tag. XSS is serious and can lead to account impersonation, observing user behaviour, loading external content, stealing sensitive data, and more. In order to understand DOM based XSS, one needs to see the fundamental difference between Reflected and Stored XSS when compared to DOM based XSS. To signify that the data was securely processed, create a special object - a Trusted Type.DoanElement.innerHTML = aTrustedHTML; With Trusted Types enabled, the browser accepts a TrustedHTML object for sinks that expect HTML snippets. If youre not using a framework or need to cover gaps in the framework then you should use an output encoding library. More info about Internet Explorer and Microsoft Edge. The best manual tools to start web security testing. At a basic level XSS works by tricking your application into inserting a