今天QQ群聊到xss前端漏洞,是通过ajax来发布的。
仔细看下面的ajax请求,data是用来获取客户端的数据,其实他这里是用php获取参数的($_GET),即&wd=<?php...?>,所以这里要做处理的,不能直接获取到数据就输出。
比如网址url后面拼接上js内容就惨了,如:index?wd=NARI',custom:alert(407871),//'
这样拼接后,ajax请求的话就会执行了,换成getCookie 那就悲剧了,客户的cookie就会被盗取了。。。。。。。
$.ajax({
type: 'GET',
url: '/search',
data: 't=' + aval + '&wd=',
dataType: 'html',
success: function (data) {
//console.log(data);
_this.parents("#JS_search_tab").siblings(".case_main").find(".bd").eq(index).html(data);
},
error: function (msg) {
alert('Load Error,Please try again.');
}
});