Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSS security. Communication between 2 iframes from the same domain

Domain abc.com has a page with 2 iframes. Both of them are loaded from domain xyz.com. Will XSS security block JavaScript access/communication/interaction between those two iframes?

like image 266
Ilia Choly Avatar asked Feb 02 '10 19:02

Ilia Choly


People also ask

How do you communicate between two iframes?

Communicating directly between iframes is also possible by combining window. parent with target as defined above. In conclusion, the postMessage method is a more dynamic alternative to the single DOM, better suited if you load multiple pages in one iframe, but not always easier and it still requires the use of the DOM.

Are iframes a security risk?

iframe injection is a very common cross-site scripting attack. iframes use multiple tags to display HTML documents on web pages and redirect users to different web addresses. This behavior allows 3rd parties to inject malicious executables, viruses, or worms into your application and execute them in user's devices.

What is cross domain iframes?

A cross domain inline frame (iframe) is a type of web technology that can be used to embed a small portion of one website within a larger "parent" page hosted on a different domain.

Can an iframe access its parent?

When a page is running inside of an iframe, the parent object is different than the window object. You can still access parent from within an iframe even though you can't access anything useful on it. This code will never cause an error even when crossing origins.


1 Answers

Well, it depends on what you mean by communicate. It seems some type of communication is possible. Here is an example: HTML on www.abc.com:

<iframe name="test1" src="http://www.xyz.com/frame1.html">
<iframe name="test2" src="http://www.xyz.com/frame2.html">

Because the iframes are named we can do this in frame2:

<a href="javascript:alert(document.body.innerHTML)" target="test1">click me</a>

So we click the link in frame 2, but the contents of frame 1 is displayed.

like image 102
Erlend Avatar answered Nov 10 '22 10:11

Erlend