簡體   English   中英

基於DOM的XSS在哪里

[英]Where is the DOM based XSS

我收到了一份AppScan安全報告,其中以下代碼段被標記為“基於DOM的跨站點腳本”:

i !== null && i.errors ? (i.errors[0].Key === "OrderNotFound" || 
i.errors[0].Key === "ShoppingCartModified") && (alert(i.errors[0].Value),
window.location.href = window.location.href.split("#")[0]) : 
t([s("GenericErrorMessage")])

但我看不出問題出在哪里。 我想知道這是否可能是假陽性。 這是原始代碼,沒有縮小

if (jsonResult !== null && jsonResult.errors) {
    if (jsonResult.errors[0].Key === "OrderNotFound" ||
        jsonResult.errors[0].Key === "ShoppingCartModified") {
        alert(jsonResult.errors[0].Value); //the problem is here
        window.location.href = window.location.href.split("#")[0]; //or here
    }
} else {
    //uiErrors is a KnockoutJS observableArray that is 
    //shown in the page using the text binding avoiding any innerHTML injection.
    //res = method that returns an error msg string for a given key.
    uiErrors([res("GenericErrorMessage")]); 
}

jsonResult是ajax調用的響應,它具有以下結構:

{
    "errors": [
        {"Key": "OrderNotFound", "Value": "Your order could not be found."}
    ]
}

不使用任何用戶輸入創建值的情況。 它們是服務器代碼中的const字符串。

添加AppScan輸出

[1 of 1]基於DOM的跨站點腳本

嚴重程度:高

測試類型:應用

脆弱的網址: https//www.domain.com/scripts/checkout.js

CVE ID:不適用

CWE ID:79

修復任務:分析客戶端代碼並清理其輸入源

1的變式1 [ID = 1612185601]

請求/響應:

https://www.domain.com/scripts/checkout.js嗎? v = m9is46e_hmcr4gnmuj4o6xssdozcytmn9flbuxtvbmy1:

1:i!== null && i.errors? (i.errors [0] .Key ===“ OrderNotFound” || i.errors [0] .Key ===“ ShoppingCartModified”)&&(alert(i.errors [0] .Value),window.location。 href = window.location.href.split(“#”)[0]):t([s(“ GenericErrorMessage”)])

驗證回應:

不適用

推理:

不適用

CWE ID:

79

您顯示的代碼似乎沒有任何XSS問題。 這是誤報,或者掃描儀沒有正確識別問題的位置。

可能值得在使用完全未縮小的代碼的同時在應用程序上重新運行掃描儀,以獲取更精確的位置信息; 即使實際上是假陽性,這也可以幫助您了解掃描儀的困惑之處。

window.location.href = window.location.href.split(“#”)[0];

上面的代碼行導致了您的問題。 從技術上講,split(“#”)[0]將刪除#個字符后的值。.但他的緩存點是:如果在“#”個字符前包含注入怎么辦?

protocal://domainname.com/details.htm/ “注入!@#$ XSS” #Helloworld!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM