history.pushState 污染
堆积 iframe 自身 origin 的 history 条目,干扰父标签页的后退导航。
按 sandbox 策略的行为
| 策略 | 预期结果 |
|---|---|
| 无 sandbox | 通过 |
sandbox="allow-scripts" | 通过 |
sandbox="" (最严) | 阻止 |
Embed 代码
此代码使用专用嵌入页面。粘贴到您的服务后检查渲染或拦截行为。
<iframe src="https://xss-playground.com/embed/history-pollution?lang=zh" title="XSS Playground - history.pushState 污染" width="600" height="420" loading="lazy" referrerpolicy="strict-origin-when-cross-origin"></iframe>
执行
// 无日志
说明
- iframe pushState 只改变自己的 URL,但这些条目会堆积到父标签页的后退栈中。用户想回到服务上一页时,可能只是在 iframe history 中循环。
- 攻击价值主要是 annoyance / 把用户困在页面上。
- 使用
sandbox=""时 JS 被阻止,此攻击也会停止。只有allow-scripts时 history API 仍可自由调用。