iframe注入
概述
<iframe>
标签用于将HTML文档嵌入到另一个HTML文档中。如果插入文档的源位于另一个源,同源策略将阻止它们双方访问另一个文档的内容。
开放重定向
子文档可以查看和设置父文档的 location 属性,即使是跨域的 top.window.location
。
例如,如果 vulnerable-website.com
包含以下 iframe
:
<iframe src=//malicious-website.com/toplevel.html></iframe>
其中 https://malicious-website.com/toplevel.html
是:
<html><head></head><body><script>top.window.location = "https://malicious-website.com/pwned.html"</script></body></html>
当 iframe
加载时,父文档将被重定向到 https://malware-website.com/pwned.html
页面,即使子文档是从不同的源加载的。在这种情况下,同源策略将被绕过,因为 iframe
没有被"沙盒化",请查看 sandbox iframe 属性。
参考资料:
最后更新于