亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

ajax響應返回html響應(XSS veracode)

ajax響應返回html響應(XSS veracode)

UYOU 2021-04-27 14:16:54
function viewAcc() {    var errorMsg = "";    var result = true;    $(".errorView").hide();    var accNum = document.getElementById('custAccNum').value;    var accType = document.getElementById('custAccType').value;    $("#overlayPopup").show();    $.ajax({        url : '<attribute:resourceURL/>',        data : {            "custNo" : accNum ,            "custType" : accType         },        success : function(data) {            if (data == 'CUS_ACC') {                window.location = "/cust/account/c";            } else {                $("#overlayPopup").hide();                //display warning                $(".errorView").show();                $(".errorView").html(data); // <--- XSS line                e.preventDefault();            }        },        cache : false,        dataType : 'text',        error : function(error, textStatus, errorThrown) {            alert('error in ajax call: ' + textStatus);            console.log('error in ajax call: ' + textStatus);            window.location = "/cust/account/c/lookup";        },        timeout : ajaxTimeOutMilliSeconds    });}因此,veracode指出我在$(".errorView").html(data); 如何解決此問題上有問題。如果我只是將其轉換為文本,它是否會像html一樣顯示在客戶端上?
查看完整描述

2 回答

?
慕萊塢森

TA貢獻1810條經驗 獲得超4個贊

不要盲目相信那些聲稱您容易受到XSS攻擊的工具。

僅當XSS的值不可信時,您才有遭受XSS的風險data。由于它來自您自己的服務器,因此您應該已經對XSS問題的數據進行了清理,然后再將其發送到對Ajax請求的響應中。


查看完整回答
反對 回復 2021-05-27
  • 2 回答
  • 0 關注
  • 235 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號