top.location forced redirect
Replace the entire parent window from inside an iframe. The classic test for sandbox allow-top-navigation.
sandbox ポリシー別の挙動
| ポリシー | 想定結果 |
|---|---|
| sandbox 未指定 | 動作 |
sandbox="allow-scripts" | ブロック |
sandbox="" (最も厳格) | ブロック |
Embed スニペット
このスニペットは埋め込み専用ページを使用します。自サービスに貼り付けてレンダリング/ブロックの挙動を確認してください。
<iframe src="https://xss-playground.com/embed/top-redirect?lang=ja" title="XSS Playground - top.location forced redirect" width="600" height="420" loading="lazy" referrerpolicy="strict-origin-when-cross-origin"></iframe>
실행
// 로그 없음
해설
window.top.location변경은 cross-origin 이어도 기본 허용 됩니다. SOP 가 막아주지 않는 영역입니다.- 차단하려면 sandbox 에
allow-top-navigation을 주지 않으면 됩니다.sandbox="allow-scripts"만 줘도 차단됩니다. - 실제 공격 가치는 매우 큽니다. 사용자가 신뢰하는 서비스 안에서 무언가 클릭한 직후 페이지가 통째로 피싱 사이트로 갈아치워지는 시나리오가 만들어집니다.