Closed Bug 1333887 Opened 9 years ago Closed 8 years ago

Crash in nsNPAPIPluginInstance::GetIsOOP

Categories

(Core Graveyard :: Plug-ins, defect)

x86
Windows
defect
Not set
critical

Tracking

(firefox-esr4552+ fixed, firefox51 wontfix, firefox52+ fixed, firefox-esr52 fixed, firefox53+ fixed, firefox54+ fixed)

RESOLVED FIXED
mozilla54
Tracking Status
firefox-esr45 52+ fixed
firefox51 --- wontfix
firefox52 + fixed
firefox-esr52 --- fixed
firefox53 + fixed
firefox54 + fixed

People

(Reporter: jesup, Assigned: benjamin)

Details

(Keywords: crash, csectype-uaf, sec-critical, Whiteboard: [post-critsmash-triage][adv-main52+][adv-esr45.8+])

Crash Data

Attachments

(1 file, 1 obsolete file)

This bug was filed from the Socorro interface and is report bp-0b838817-22cb-4b10-8b40-96c872170125. ============================================================= This is a UAF crash going back to at least Firefox 31ish. Interestingly, there are no crashes in 52 or later, and the code is still there. Affects release 51 and ESR 45 I'm sure.
Group: core-security → dom-core-security
Karl, this looks like code you have been involved with. Can you take a look? If you can not, please redirect as you deem fit, but as a a security problem, we want this fixed ASAP.
Flags: needinfo?(karlt)
https://crash-stats.mozilla.com/report/index/5e0d015f-db82-4268-a777-5f2212170207 is 52.0b3. Different stack to that in comment 0, but similar to other 51 crashes. https://crash-stats.mozilla.com/report/index/455bfd22-8bd4-4099-bcd5-836422170206 is one of a minority of reports without a truncated stack. I don't know whether the high frequency of truncated stack reports is significant, or typical because of poor stack walking code or cfi generation. nsBlockFrame::BuildDisplayList() is not a function I'd expect a foreign object to be able to call.
nsPluginInstanceOwner::UseAsyncRendering() has just read nsPluginInstanceOwner::mInstance, and so I expect the nsNPAPIPluginInstance is still alive. The virtual PluginLibrary::IsOOP() implementations just return true or false, and so I doubt the crash is within the IsOOP() implementation. If the object referenced by |library| were freed, and |library| still contained the object's address then I'd expect the vtbl pointer to contain 0xe5e5e5e5. IsOOP() is not the first virtual function on PluginLibrary, and so the virtual function address would be stored at an offset to the vtbl pointer value. A read of this function address would usually crash at a different address to the one reported here. That leaves the possibility that |library| is already 0xe5e5e5e5, and so the read of the vtbl pointer crashes on read from 0xe5e5e5e5, consistent with the address reported here. The use of the bad read for a function address may be sec-critical. sec-high may be more appropriate if the bug is difficult to trigger, but I don't know that. nsNPAPIPluginInstance uses a bare pointer mPlugin to call nsNPAPIPlugin::GetLibrary(). My suspicion is that this nsNPAPIPlugin has been freed and so the read of its mLibrary returns 0xe5e5e5e5. There is no documentation on mPlugin to indicate the ownership model for the nsNPAPIPlugin. The next step I suggest is getting someone familiar with nsNPAPIPlugin ownership to look.
Flags: needinfo?(karlt) → needinfo?(benjamin)
Keywords: sec-highsec-critical
You are almost certainly correct that the nsNPAPIPlugin is dead. It's suspicious and interesting that there is another plugin instance lower down the stack (I verified that it's not the same nsPluginInstanceOwner object). I will have to figure out on Monday the ownership cycle between nsPluginHost/nsNPAPIPlugin/nsNPAPIPluginInstance. I think the plugins are owned through the plugin tag array on the pluginhost. But if the plugin crashes that will go down, and perhaps the instances aren't notified. And I guess this is all non-e10s?
Assignee: nobody → benjamin
Flags: needinfo?(benjamin)
Attachment #8837134 - Flags: review?(kyle)
Comment on attachment 8837134 [details] [diff] [review] Hold nsNPAPIPlugin alive for active nsNPAPIPluginInstance objects. This should happen through the plugin tag, but apparently that isn't always working Review of attachment 8837134 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/plugins/base/nsNPAPIPlugin.h @@ +62,5 @@ > > static nsresult RetainStream(NPStream *pstream, nsISupports **aRetainedPeer); > > +public: > + // RefCounted requires a public destructor :-( I think you could do NS_INLINE_DECL_REFCOUNTING instead of inheriting RefCounted if you wanted to keep that protected? Since the destructor was virtual in the first place it's not like this is avoiding the vtable like RefCounted<> normally gets you.
Attachment #8837134 - Flags: review?(kyle) → review+
Attachment #8837134 - Attachment is obsolete: true
Comment on attachment 8837265 [details] [diff] [review] Hold nsNPAPIPlugin alive for active nsNPAPIPluginInstance objects. This should happen through the plugin tag, but apparently that isn't always working Approval Request Comment [Feature/Bug causing the regression]: unknown [User impact if declined]: more crashes, possible security issue [Is this code covered by automated tests?]: not effectively (we can't reproduce the problem) [Has the fix been verified in Nightly?]: no [Needs manual test from QE? If yes, steps to reproduce]: no STR available. Verification will be via crash-stats. [List of other uplifts needed for the feature/fix]: none [Is the change risky?]: not very; main risk is that this will introduce a cycle/memory leak, but that seems unlikely [String changes made/needed]: none [Security approval request comment] How easily could an exploit be constructed based on the patch? It would be difficult: I can't even figure out how to make the crash happen. Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem? They point to an ownership problem but nothing specific. Which older supported branches are affected by this flaw? All Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be? I don't know about ESR54; everything else should be trivial backports. How likely is this patch to cause regressions; how much testing does it need? If there were a regression, it would likely come in the form of a memory leak. But that's very unlikely if this passes automated tests.
Attachment #8837265 - Flags: sec-approval?
Attachment #8837265 - Flags: approval-mozilla-beta?
Attachment #8837265 - Flags: approval-mozilla-aurora?
sec-approval+ and branch approvals. We should investigate ESR45 patching.
Attachment #8837265 - Flags: sec-approval?
Attachment #8837265 - Flags: sec-approval+
Attachment #8837265 - Flags: approval-mozilla-beta?
Attachment #8837265 - Flags: approval-mozilla-beta+
Attachment #8837265 - Flags: approval-mozilla-aurora?
Attachment #8837265 - Flags: approval-mozilla-aurora+
Comment on attachment 8837265 [details] [diff] [review] Hold nsNPAPIPlugin alive for active nsNPAPIPluginInstance objects. This should happen through the plugin tag, but apparently that isn't always working See comment 8.
Attachment #8837265 - Flags: approval-mozilla-esr45?
Comment on attachment 8837265 [details] [diff] [review] Hold nsNPAPIPlugin alive for active nsNPAPIPluginInstance objects. This should happen through the plugin tag, but apparently that isn't always working Fix a sec-critical. ESR45+.
Attachment #8837265 - Flags: approval-mozilla-esr45? → approval-mozilla-esr45+
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
Group: dom-core-security → core-security-release
Flags: qe-verify-
Whiteboard: [post-critsmash-triage]
Whiteboard: [post-critsmash-triage] → [post-critsmash-triage][adv-main52+][adv-esr45.8+]
Group: core-security-release
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: