Search code examples
xssjsp-tagsfortify

<script>document.write('<base href=“' + document.location + '” />');</script>


I am getting cross-site Scripting: DOM critical issue. Please can anyone help with the alternateway of using document.write

<script>
document.write('<base href=“' + document.location + '” />');
</script>


Solution

  • You can use following to prevent DOM XSS:

    <body>
    <script>
    document.body.innerHTML='<base href="' + encodeURI(document.location) + '" />';
    </script>
    </body>