WebKit cross-domain security problem description _javascript Skills

Source: Internet
Author: User
Here is a simple test page: IE, Firefox pop-up "Hello World", and Chrome,safari,opera no response.
The following is a small section of the test code (deliberately modify domain, so that the parent page and subpage page for different domains):
1. Parent page code:
Copy Code code as follows:

<script>
Document.domain = "Nunumick.me";
function Dotest () {
Alert (' Hello World ');
}
</script>
<iframe src= "http://www.nunumick.me/lab/x-domain/webkit-test.html" >
</iframe>

2. Sub-page code:
Copy Code code as follows:

<script>
try{
Top.name;
}catch (e) {
Document.domain = ' nunumick.me ';
Top.dotest ();
}
</script>

The purpose of the above code is to attempt to dynamically modify domain to achieve a smooth access while accessing an exception, but the WebKit kernel browser rudely complains rather than throws the intercepted exception, and other browsers are running as scheduled.

Chrome Error message:

It is understood that the use of such a try-catch method to do security feasibility judgment is not only a separate phenomenon, such as Dojo

Copy Code code as follows:

try{
If we can access the IFRAME ' s location
Without a permission denied error
var iframesearch = _getsegment (Iframeloc.href, "?");
Good, the IFRAME is same origin (no thrown exception)
if (document.title!= doctitle) {
Sync title of main window with title of IFRAME.
DocTitle = This.iframe.document.title = Document.title;
}
}catch (e) {
Permission Denied-server cannot be reached.
Ifroffline = true;
Console.error ("Dojo.hash:Error adding history
Entry. Server unreachable. ");
}

Another example of FCKeditor
Copy Code code as follows:

try{
if ((/fcksource=true/i). Test (Window.top.location.search))
sfile = ' fckeditor.original.html ';
}
catch (E) {/* Ignore it. Much probably we are insi
De a FRAME where the "top" was in another domain (security error). */ }

And a lot of netizens ' Feedback: Chrome bug report

None of the above code is applicable in Chrome,safari,opera. Turned over some information, recorded here:
1.HTML5 Security Location
2.webkit Dev Lists
From the WebKit developer's discussion message, they acknowledged the problem but were reluctant to correct it, Holly shit!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.