###### tags: `資訊安全`,`2022` {%hackmd BJrTq20hE %} # 開放式重定向 Open Redirect 在登入後,大家都會有網站重新跳轉到前一頁或是首頁的經驗,有些網站會把重定向的目的頁面當作參數,這時候就有可能被駭客竄改攻擊。 以下範例是 可能被攻擊的形式: + https://test.com/loging?redirect_uri=http://fake.com + https://test.com/loging?redirect_uri=//fake + https://test.com/loging?redirect_uri=javascript:alert(document.cookie) + https://test.com/loging?../fake ## 防禦要點 **1. 白名單:** 因為 http 或 https 可以被省略,所以不能只是利用特定字串來作為合法依據,最好的做法是網址在伺服器端用白名單作為限制或是驗證整個網域。 **2. 參數格式:** 因為駭客可能會在參數輸入 javascript 程式碼,所以可以檢查檢查導向參數為網址格式,或是不能為非法字串。 因為導向後的頁面是同源,所以被入侵,駭客是可以取得敏感資料,例如:登入者資訊、cookie。 **3. 防止相對路徑:** 需注意駭客可能輸入相對路徑,進入內網目錄取得機密資料(Path Traversal 漏洞)。因此在檔案管理除了設定防火牆內網可以取得資料外,也應該要有權限管理的機制。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up