如何通过 iframe 防止存储型 XSS?

How can prevent Stored XSS by iframe?

我使用 Extjs 和 JS 构建一个对话框,可以在其中显示来自数据库的 html 数据,该数据用 iframe 包装,如下所示:

<iframe name="ext-gen568" frameborder="0" src="javascript:;" style="width: 514px; height: 189px;">
<html>
<head> ... </head>
<body>
<br><br>
<blockquote type="cite"> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <p>Hello</p>
    <video><source src="x" onerror="alert('xss')"></video>
</blockquote>
</body>
</html>
</iframe>

我尝试将 sandbox 添加到 iframe,但它不起作用,XSS 警报仍然显示。

我应该如何处理我的问题?

非常感谢您的帮助。

此问题已通过为沙盒设置“allow-same-origin”得到修复

<iframe sandbox="allow-same-origin" src="javascript:;"...></iframe>