- [簡報連結](https://wanyewei.github.io/wanyewei/) ## 5-1: Click Jacking > Click Jacking 是一種網站攻擊技術,透過 iframe 將目標網站隱藏在一個看不見的網頁中,並將 iframe 設定為透明,當使用者點擊透明的 iframe 時,實際上是點擊了目標網站的按鈕。 ### 防範方式 #### 1. Frame busting:透過 JavaScript 來檢查是否在 iframe 中,如果是則將頁面導向到原始網站。 ```javascript if (top === self) { dociment.documentElement.style.display = 'block'; } else { top.location = self.location; } ``` `self`:代表當前的 window,`top`:代表最上層的 window。 #### 2. `iframe` 的 `sandbox` 屬性:可以限制 iframe 的行為,例如:禁止表單提交、禁止腳本執行等。 #### 3. X-Frame-Options:透過 HTTP Header 來限制網站是否可以被 iframe。 > 不過 X-Frame-Options 在實作時,瀏覽器不會每一層都去檢查是否同源,因此可以被 nested 繞過,目前已經被 CSP 取代。 ```plaintext example.com/A.html --> attacker.com ---> example.com/A.html ---> example.com/B.html ``` #### 4. CSP:frame-ancestors 指令可以限制 iframe 的來源。 ```plaintext Content-Security-Policy: frame-ancestors 'self' example.com ```
×
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