jQuery DOM XSS漏洞

JQuery DOM方法中XSS漏洞:

漏洞截图:

测试代码:

<html class=" -webkit- js flexbox canvas canvastext webgl no-touch geolocation postmessage websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers no-applicationcache svg inlinesvg smil svgclippaths" style=""><head> <meta charset="UTF-8"><title>HTML5 Preview Panel</title><style>html {
    height: 100%;
}
body {
    background: #ff8800 -webkit-linear-gradient(transparent, rgba(100, 0, 0, 0.3));
    background: #ff8800 linear-gradient(transparent, rgba(100, 0, 0, 0.3));
    color: #333;
    margin: 1em;
}
h1 {
    color: black;
}
hr {
    border: 1px solid #ffaa00;
}
a {
    color: #ffff33;
}
#wrap {
    max-width: 500px;
    text-align: center;
    margin: 0 auto;
}
form {
    margin-bottom: 2em;
}
code {
    font-weight: normal;
    color: #800;
}
.info {
    font-size: 0.8em;
}
.out {
    min-height: 80px;
    border: 1px solid silver;
    background: #ddd;
    margin-bottom: 2em;
    color: #888;
}</style><script src="http://test.com.cn/js/jquery-1.7.2.min.js"></script></head><body><div id="wrap">
    <h1>XSS vulnerabilities in jQuery DOM methods</h1>

    <hr>

    <h3>Input</h3>
    <form>
        <input id="test" placeholder="Enter malicious input here" size="40" value="<script>alert('XSS injected!');</script>">
        <input type="submit" value="Submit">
    </form>

    <hr>

    <h3>Output (native <code>innerHTML</code>)</h3>
    <p class="info">The <a href="https://www.w3.org/TR/2008/WD-html5-20080610/dom.html#innerhtml0" target="_blank">HTML5 spec</a> states that script tags inserted via <code>innerHTML</code> will not be executed.</p>
    <div class="out" id="output-inner">
        Injection goes here...
    </div>

    <h3>Output (<code>$.html()</code>)</h3>
    <p class="info">jQuery DOM methods strip and <code>eval()</code> any script tags passed in, exposing an XSS vulnerability.</p>
    <div class="out" id="output-html">
        Injection goes here...
    </div>

    <h3>Output (<code>$.text()</code>)</h3>
    <p class="info">This method treats the passed string as a textNode, preventing it from being executed by the browser.</p>
    <div class="out" id="output-text">
        Injection goes here...
    </div>
</div>

<script src="http://test.com.cn/js/jquery-1.7.2.min.js"></script><script>$('form').on('submit', function(e) {
    e.preventDefault();

    var ov = $('#test').val();

    $('#output-inner').get(0).innerHTML = ov;
    $('#output-html').html(ov); // Comment this out to see how innerHTML does not fire the dialog
    $('#output-text').text(ov);

});</script></body></html>

参考链接:jQuery DOM方法中的XSS漏洞演示 - 踏得网

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

K2epUp

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值