top.location forced redirect
Replace the entire parent window from inside an iframe. The classic test for sandbox allow-top-navigation.
Behavior by sandbox policy
| Policy | Expected result |
|---|---|
| No sandbox | works |
sandbox="allow-scripts" | blocked |
sandbox="" (strictest) | blocked |
Embed snippet
This snippet uses the dedicated embed page. Paste it into your own service and check rendering or blocking behavior.
<iframe src="https://xss-playground.com/embed/top-redirect?lang=en" 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"만 줘도 차단됩니다. - 실제 공격 가치는 매우 큽니다. 사용자가 신뢰하는 서비스 안에서 무언가 클릭한 직후 페이지가 통째로 피싱 사이트로 갈아치워지는 시나리오가 만들어집니다.