Frame Navigation Policies in web browsers-One reason to upgrade to modern browsers
Frame Navigation-who decides what:
Though the same origin policy of browsers isolates frame content of different domains, it has nothing to do with navigation of frames. i.e., if you know the id of a frame, you can navigate it to a different URL. (The browser window can be considered as a top level frame, having a visible address bar which iframes lack).
The above script redirects one of the iframes present in iGoogle page to the address yahoo.com. So if your trusted components are in iframes, what if someone can redirect the frame to a malicious URL? Which iframe has the permission to navigate which other iframe on a complex mashup page like iGoogle? Even worse, can iframes on a different window/tab navigate the iframes on your page? What about popups? Do you feel the sense of insecurity now?
Well, the fact is, none of these are under the control of web developers. The policies used by browser vendors answer the above questions and developers should know these policies to understand how secure their websites are. Below is a brief outline of the navigation policies used by browsers:
1. Permissive policy: This policy prevailed in all browsers prior to 1999. It simply states that a frame can navigate any other frame. The frames can be in the same window or in different windows. This dangerous policy gave rise to what are called "Cross window attacks". Several sites like CitiBank kept their password fields in iframes for secure sandboxing. So, an advertisement in another window or a popup containing malicious script can redirect the password frame to an evil frame and grab credentials! IE6, Safari 3 and Flash by default used permissive policy.
2. Window policy: Starting 2001, browsers implemented a new policy called window policy, in order to prevent the cross window attacks. As per this, a frame can navigate frames in its own window and hence external popups/ads cannot affect frames of a different window. However, this gave rise to new line of attacks called "Same window attacks". Using this policy, advertisements in the same window or evil gadgets (widgets) in mashups (e.g., iGoogle) can redirect legitimate gadgets to malicious URLs. So Gadget hijacking became the fashion of the day due to this policy. Firefox 2 and Opera 9 followed this policy which is dangerous to work with today's gadget rich Web 2.0 applications.
3. Child Policy: This is a stricter policy, which says that a frame can navigate only its direct child. IE6 team wanted to enable this by default but did not since majority of the existing sites are not compatible with this. Such a strict implementation will prevent even the navigation of legitimate frames which are from same origin as the parent. So this policy could not be implemented.
4. Descendant policy: This is another stricter policy which was designed by IE7 team and it provides the best trade-off between security and compatibility. As per this, a frame can navigate only its descendants. So this prevents the cross window as well as same window attacks. HTML5 working group has standardized this policy.
The above picture explains the policies better. The outer blue box is the browser frame, the inner blocks are iframes and the arrows indicate who can navigate the content of what. Notice that child policy is a subset of descendant., descendant is a subset of window., window is a subset of permissive policies.
All modern browsers (IE8+, FF3+, Safari 3+, Opera >9) follow the descendant policy to navigate frames and hence are more secure than their older counterparts. This is one of the several hundred reasons why you should get rid of older browsers and upgrade to modern ones in the era of Web 2.0 applications.
Researchers at Stanford web security lab have published an excellent research paper-"Secure Frame Communications in Browsers", which is the motivation for this post. Suggest reading the paper for better understanding of the concepts discussed in this article.
Hope the article helped in understanding the frame navigation policies implemented by various browsers and how security in modern browsers got enhanced. We shall see more on related areas in the upcoming articles.