img 标签 GET 请求 CSRF
检查是否可通过 img.src 请求外部状态变更 GET endpoint,并自动携带 cookie。
按 sandbox 策略的行为
| 策略 | 预期结果 |
|---|---|
| 无 sandbox | 通过 |
sandbox="allow-scripts" | 通过 |
sandbox="" (最严) | 通过 |
Embed 代码
此代码使用专用嵌入页面。粘贴到您的服务后检查渲染或拦截行为。
<iframe src="https://xss-playground.com/embed/csrf-image?lang=zh" title="XSS Playground - img 标签 GET 请求 CSRF" width="600" height="420" loading="lazy" referrerpolicy="strict-origin-when-cross-origin"></iframe>
执行
// 无日志
说明
- 最古老的 CSRF 形式:一行
<img src="https://target/action?a=b">就足以带着用户 cookie 发出 GET 请求。 - 即使
sandbox=""也不会阻止 img 请求。真正的防护需要 CSPimg-src,或在 HTML 渲染阶段校验 img src host。 - 如果目标使用 SameSite=Lax cookie,cross-site GET 通常不会携带 cookie,CSRF 影响较小。但 IP 暴露、tracking pixel、internal-only endpoint ping 仍然可能存在。
- 许多编辑器和 CMS 默认允许 img 标签,因此需要 host allowlist 或 CSP 来关闭这个攻击面。