假登录表单(钓鱼)
在 iframe 内绘制类似父站点的登录表单,并在 iframe 自己的 origin 中收集用户输入。
按 sandbox 策略的行为
| 策略 | 预期结果 |
|---|---|
| 无 sandbox | 通过 |
sandbox="allow-scripts" | 通过 |
sandbox="" (最严) | 部分 |
Embed 代码
此代码使用专用嵌入页面。粘贴到您的服务后检查渲染或拦截行为。
<iframe src="https://xss-playground.com/embed/phishing-form?lang=zh" title="XSS Playground - 假登录表单(钓鱼)" width="600" height="420" loading="lazy" referrerpolicy="strict-origin-when-cross-origin"></iframe>
真实攻击会把此 iframe 放在父页面中,让它看起来像服务自己的弹窗或登录区域。用户很难注意到域名是 attacker.example。
假登录表单(可在自己的 origin 内自由绘制)
捕获日志
// 无日志
说明
- iframe 内的表单只是其自身 origin 上的页面,因此可以绘制任何 UI,并把值发送到自己的服务器。SOP 不会阻止这一点。
- 即使
sandbox="allow-scripts"会阻止原生表单提交,JS 仍然可以收集值并通过 fetch 发出。只有sandbox=""也能阻止 JS。 - 最有效的防护是限制 iframe src 的 host allowlist。