WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
4872
XMLHttpRequest fails to throw an exception when there is a security violation (mismatching domains)
https://bugs.webkit.org/show_bug.cgi?id=4872
Summary
XMLHttpRequest fails to throw an exception when there is a security violation...
Damian Steer
Reported
2005-09-07 05:11:41 PDT
XMLHttpRequests are tied to the originating domain (host?) for security reasons. Safari does not appear to violate this, however it seems to be impossible to detect this reliably in javascript. Mozilla (et al), Opera and IE (*) all raise exceptions in the following (although at slightly different points): (taken from above url) try { xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", "
http://example.com/
", true); xmlhttp.send(null); } catch(e) { alert(e); } Safari remains on readyState == 0, which suggests something is wrong, but isn't definitive. (*)
http://rdfweb.org/people/damian/2005/09/test_xmlhttprequest_ie.html
will check all platforms.
Attachments
proposed patch
(26.93 KB, patch)
2006-09-09 10:25 PDT
,
Alexey Proskuryakov
darin
: review-
Details
Formatted Diff
Diff
proposed patch
(31.89 KB, patch)
2006-09-11 10:45 PDT
,
Alexey Proskuryakov
eric
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Mark Rowe (bdash)
Comment 1
2005-09-07 21:30:24 PDT
Confirmed with WebKit 412.7 and ToT WebKit.
Alexey Proskuryakov
Comment 2
2006-09-09 10:25:35 PDT
Created
attachment 10476
[details]
proposed patch
Darin Adler
Comment 3
2006-09-10 12:37:20 PDT
Comment on
attachment 10476
[details]
proposed patch - if (args.size() < 2 || args.size() > 5) - return jsUndefined(); + if (args.size() < 2) - if (args.size() >= 1) { + if (args.size() == 1) { It looks like this change now tolerates extra arguments for open, but no longer tolerates extra parameters for send. Is that intentional? Do the tests cover this? In general, I'd like to see tests that cover the "extra arguments" behavior since we keep tweaking it back and forth. Does the XMLHttpRequest exception in setDOMException need to have the strange pattern where it thows the error without putting the exception code into the object? If so, we need a comment at least to explain why. How can those checks of the response headers be turned into asserts? Where is the code that guarantees the headers will have that form?
Darin Adler
Comment 4
2006-09-10 13:07:47 PDT
Comment on
attachment 10476
[details]
proposed patch I'm going to mark this review- because of the issue in setDOMException.
Alexey Proskuryakov
Comment 5
2006-09-11 10:45:50 PDT
Created
attachment 10501
[details]
proposed patch (In reply to
comment #3
)
> It looks like this change now tolerates extra arguments for open, but no longer > tolerates extra parameters for send. Is that intentional?
This was a mistake, fixed!
> In general, I'd like to see tests that cover the "extra arguments" behavior > since we keep tweaking it back and forth.
Added http/tests/extra-parameters.html
> Does the XMLHttpRequest exception in setDOMException need to have the strange > pattern where it thows the error without putting the exception code into the > object? If so, we need a comment at least to explain why.
Done. The current XMLHttpRequest spec draft does not specify any code for the exception (actually, it does not even specify that an exception should be thrown). And Firefox doesn't put any exception code either.
> How can those checks of the response headers be turned into asserts? Where is > the code that guarantees the headers will have that form?
The string is created in HeaderStringFromDictionary(), LoaderFunctionsMac.mm in the expected form. Actually, I think that the ResourceLoader interface should be changed to pass this information without serialization.
Eric Seidel (no email)
Comment 6
2006-09-21 14:35:00 PDT
ap: I keep meaning to talk with you about this over irc... ping me next time you're around.
Eric Seidel (no email)
Comment 7
2006-09-23 00:54:24 PDT
Comment on
attachment 10501
[details]
proposed patch I've read through this a couple times over the last week or so. I also just talked with ap about it again over irc. The code looks sane. Most important here are the tests. So long as we have excellent XHR testing coverage, I'm happy. It's sad that this string has to be repeated so many times: return throwError(exec, SyntaxError, "Not enough arguments"); You've noted these try/catches are for testing in IE: + try { + req.overrideMimeType('text/xml'); + } catch (ex) { + } IMO it's best to log any exceptions, even if they're specific to a single browser. This should have a bug about it: - // FIXME: Should this abort instead if we already have a m_job going? + // FIXME: Should this abort or raise an exception instead if we already have a m_job going? looks good. r=me.
Alexey Proskuryakov
Comment 8
2006-09-23 11:51:38 PDT
Committed revision 16543.
> IMO it's best to log any exceptions, even if they're specific to a single > browser.
Done; also added empty-response.xml to make the tests work in WinIE without tweaking .htaccess.
> This should have a bug about it: > - // FIXME: Should this abort instead if we already have a m_job going? > + // FIXME: Should this abort or raise an exception instead if we already > have a m_job going?
This is not something we can really resolve without help from the web-api WG; I have asked Anne van Kesteren for comments.
Alexey Proskuryakov
Comment 9
2006-09-24 21:34:13 PDT
(In reply to
comment #8
)
> This is not something we can really resolve without help from the web-api WG
http://www.w3.org/2006/webapi/track/issues/91
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug