Bug 780351 - Don't let code in different apps access each others' windows. r=smaug
This commit is contained in:
@@ -2846,7 +2846,10 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
|
|||||||
// window with javascript
|
// window with javascript
|
||||||
// Bug 408052: Adopt "ancestor" frame navigation policy
|
// Bug 408052: Adopt "ancestor" frame navigation policy
|
||||||
|
|
||||||
// Now do a security check
|
// Now do a security check.
|
||||||
|
//
|
||||||
|
// Disallow navigation if the two frames are not part of the same app, or if
|
||||||
|
// they have different is-in-browser-element states.
|
||||||
//
|
//
|
||||||
// Allow navigation if
|
// Allow navigation if
|
||||||
// 1) aAccessingItem can script aTargetItem or one of its ancestors in
|
// 1) aAccessingItem can script aTargetItem or one of its ancestors in
|
||||||
@@ -2860,6 +2863,28 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDocShell> targetDS = do_QueryInterface(aTargetItem);
|
||||||
|
nsCOMPtr<nsIDocShell> accessingDS = do_QueryInterface(aAccessingItem);
|
||||||
|
if (!!targetDS != !!accessingDS) {
|
||||||
|
// We must be able to convert both or neither to nsIDocShell.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetDS && accessingDS) {
|
||||||
|
bool targetInBrowser = false, accessingInBrowser = false;
|
||||||
|
targetDS->GetIsInBrowserElement(&targetInBrowser);
|
||||||
|
accessingDS->GetIsInBrowserElement(&accessingInBrowser);
|
||||||
|
|
||||||
|
PRUint32 targetAppId = 0, accessingAppId = 0;
|
||||||
|
targetDS->GetAppId(&targetAppId);
|
||||||
|
accessingDS->GetAppId(&accessingAppId);
|
||||||
|
|
||||||
|
if (targetInBrowser != accessingInBrowser ||
|
||||||
|
targetAppId != accessingAppId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> accessingRoot;
|
nsCOMPtr<nsIDocShellTreeItem> accessingRoot;
|
||||||
aAccessingItem->GetSameTypeRootTreeItem(getter_AddRefs(accessingRoot));
|
aAccessingItem->GetSameTypeRootTreeItem(getter_AddRefs(accessingRoot));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user