I use Extjs and JS to build a dialog where can display my html data from DB, that data is wrapped with iframe
like this:
JavaScript
x
14
14
1
<iframe name="ext-gen568" frameborder="0" src="javascript:;" style="width: 514px; height: 189px;">
2
<html>
3
<head> </head>
4
<body>
5
<br><br>
6
<blockquote type="cite">
7
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
8
<p>Hello</p>
9
<video><source src="x" onerror="alert('xss')"></video>
10
</blockquote>
11
</body>
12
</html>
13
</iframe>
14
I tried to add sandbox
to iframe
, but it doesn’t work, the XSS alert still show.
- Then I tried to change to
<iframe src='#'... sandbox>
, but XSS alert still show. - I removed
src
or just set it''
in<iframe src=''... sandbox>
, it got this error:DOMException: Blocked a frame with origin "mytestdomain" from accessing a cross-origin frame.
What should I do to handle my issue?
Thanks a lot for any help.
Advertisement
Answer
The issue is fixed by set “allow-same-origin” for sandbox
JavaScript
1
2
1
<iframe sandbox="allow-same-origin" src="javascript:;"></iframe>
2