Closed Bug 47905 Opened 26 years ago Closed 25 years ago

XMLHttpRequest object security vulnerability

Categories

(Core :: Security, defect, P1)

defect

Tracking

()

VERIFIED FIXED
mozilla0.9.1

People

(Reporter: security-bugs, Assigned: security-bugs)

References

()

Details

Attachments

(3 files)

Date: Mon, 07 Aug 2000 14:51:42 +0300 From: Georgi Guninski <joro@nat.bg> To:Mitchell Stoltz <mstoltz@netscape.com> The XMLHttpRequest object is not subject to same origin security policy and allows exploits. The code is: -------------------------------------- <SCRIPT> var h = new XMLHttpRequest(); h.open("GET", "http://joro/joro/mozilla/test/xml.xml", false); // The XML file must be a valid XML file h.send(document); d = h.responseXML; s = new XMLSerializer() alert("The xml file is: "+s.serializeToString(d)); </SCRIPT> --------------------------------------
nsbeta3 for exploit.
Status: NEW → ASSIGNED
Keywords: nsbeta3
Target Milestone: --- → M18
escalating.
Priority: P3 → P1
Whiteboard: [nsbeta3+]
Future'd because this functionality is not present in the commercial build. However, Mozilla builds are currently vulnerable; we need to be doing Same Origin checks on this functionality. Reassigning to Vidur as he is the author of this code.
Assignee: mstoltz → vidur
Status: ASSIGNED → NEW
Keywords: nsbeta3
QA Contact: czhang → junruh
Whiteboard: [nsbeta3+]
Target Milestone: M18 → Future
QA Contact: junruh → ckritzer
Taking, I am now the owner of most XMLExtras bugs.
Assignee: vidur → heikki
Target Milestone: Future → mozilla0.9
We may need to reconsider this bug due to bugscape: http://bugscape.netscape.com/show_bug.cgi?id=3734 to have this feature in Netscape Commercial builds.
We need to add Security Manager hooks to this code (to do a same-origin check before loading XML content). Heikki, I will work with you on this.
Mitch is working on this, reassigning. I can review, vidur should probably sr. This seems to be blocking the Bugscape bug so the sooner the better...
Assignee: heikki → mstoltz
An ideal fix for this will depend on the new XPConnect security mechanism, and that's dependent on Jband's forthcoming changes. In the meantime, I'm implementing a temporary solution; I will have it checked in this week.
Status: NEW → ASSIGNED
This fix is TEMPORARY. Once the DOM moves to XPConnect, security for XMLHttpRequest will be subsumed by the general DOM security manager.
Looks ok to me (whitespace nits picked in private email, take 'em or leave 'em), r=brendan@mozilla.org. /be
This part doesn't look right to me; you remove braces but you still have two lines that should be scoped by that if: if (!principal || NS_SUCCEEDED(principal->Equals(mSystemPrincipal, &equals)) && equals) - { // We have native code or the system principal: just allow access return NS_OK; - } Here you can avoid operator= if you just use the constructor (hmm, maybe you don't need the explicit QI at all, it might be automatic): -nsCOMPtr<nsICodebasePrincipal> codebase = do_QueryInterface(principal); +nsCOMPtr<nsICodebasePrincipal> codebase(do_QueryInterface(principal)); I have a small concern that the fix would break things if XMLHttpRequest was used without a script environment, in a command line tool, but I didn't have time to look at that yet. Mitch, could you check if the tests in xmlextras/tests work? There is also a test C++ program you could try. I think there was something that didn't work in it, but give it whirl. Once I get back from a meeting I'll take another look.
But there aren't two lines scoped by that if - one is a comment. I'm just trying to be consistent; elsewhere in the file I don't use braces if there's only one statement in the if. Looks like this function already assumes that a script context exists; I didn't add that. Anyway, if there's no script context or there's no principal in the contaxt, caps assumes it's being called by native code. I don't know how to test this, but I think we're OK.
Your post.html test is broken by this patch, as I would expect - it's trying a cross-origin load. We can add an enablePrivilege call to the test to make it work locally; it won't work over the web unless you enable codebase principals. This is probably OK for testing. Do we need a security check on the SOAPCall object, too?
Well, even if one is a comment it looks really weird to me - I didn't even know this would work! I checked the command line testprogram in xmlextras/tests and it seems to have been bitrotted so that it does no longer work. If you open xmlextras/tests/syncpost.html or post.html in the browser, does the new security check prevent them from working? They are supposed to send data to http://blueviper and get the response (echo of what was sent) back, and display the results in alert boxes. What if you move the html files to blueviper?
If both the html and the xml are on blueviper the test will work; or if you apply my patch to the test and run it from file:, that will work too. Do I have your r=?
Hmm, nobody has been interested in the SOAP stuff so far, that I know of. It should not go into the installer for nightly builds at this point so I don't think that it is urgent at this point (it is a separate DLL & typelib from xmlextras). vidur is still the owner of the SOAP stuff so you might want to chat with him - he might have some plans for SOAP in the web applications group.
Temporary fix checked in. Leaving open to remind myself to set a policy for this call when the new XPConnect security manager becomes active.
Group: netscapeconfidential?
Mass changing milestones to Moz0.9.1. Many of these bugs are dependent on the XPConnected DOM and its associated security UI changes.
Target Milestone: mozilla0.9 → mozilla0.9.1
sr=jst
r=vidur. Mitch is planning on adding a comment to the string funkiness in nsScriptSecurityManager::Init. The exception related code in nsXMLHttpRequest::Open will be removed when it's dealt with in nsIScriptSecurityManager::CheckConnect.
FYI I backed out the fix for this.
> Future'd because this functionality is not present in the commercial build. > However, Mozilla builds are currently vulnerable Why the difference? Does Mozilla incude xmlextras by default and Netscape builds don't, or what? In other words, to protect, can I just delete the xmlextras component?
Fix is in. XMLHttpRequest.open() should only be allowed to open connections to the script's origin.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Annnnnnd does anybody have a testcase? :-) Should the bit at the beginning of the bug be put into a 'standard' xml file? If yes, should the valid XML file in line 3 (mentioned in line 4) of the given example exist on a different or same server as the testcase? Any info would be greatly appreciated!
Try the URL above for a testcase. This attempts to load and read an XML file from a different host. It should throw an exception. Try http://warp/u/mstoltz/bugs/47905a.html as a counterexample - it does a load from the same host and should successfully display some data from the target XML document.
Yep. That works dandy. Marking VERIFIED FIXED on: -MacOS91 2001-05-21-15-trunk MOZILLA -Win98SE 2001-05-22-06-trunk -LinRH62 2001-05-22-05-trunk
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: