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=zh" 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"만 줘도 차단됩니다. - 실제 공격 가치는 매우 큽니다. 사용자가 신뢰하는 서비스 안에서 무언가 클릭한 직후 페이지가 통째로 피싱 사이트로 갈아치워지는 시나리오가 만들어집니다.