Closed Bug 1230341 Opened 5 years ago Closed 5 years ago

potential UAF in service worker use of NS_NewRunnableMethodWithArg


(Core :: DOM: Service Workers, defect)

Not set



Tracking Status
firefox43 --- disabled
firefox44 + fixed
firefox45 + fixed
firefox-esr38 --- unaffected


(Reporter: bkelly, Assigned: bkelly)



(Keywords: csectype-uaf, sec-high, Whiteboard: [post-critsmash-triage])


(1 file)

Consider this code from ServiceWorkerManager.cpp:

    // Step 8 "Queue a task..." for updatefound.
    nsCOMPtr<nsIRunnable> upr =


This dispatches a runnable without holding a strong ref to the mRegistration argument.
Group: core-security → dom-core-security
Marking sec-high, because I don't think this is easily exploitable.
Keywords: sec-high
Fixed another case I found as well.
Attachment #8696031 - Flags: review?(ehsan)
Passes tests locally.
Attachment #8696031 - Flags: review?(ehsan) → review+
Comment on attachment 8696031 [details] [diff] [review]
Hold a strong ref in service worker NS_NewRunnableMethodWithArg uses. r=ehsan

[Security approval request comment]
How easily could an exploit be constructed based on the patch?

I think difficult.  Its hard to directly control the life cycle of these objects from script.  Even if this was possible, it would then need to force the race to fail.

Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?

Well, its obviously a potential UAF, but again I don't think its obviously exploitable.

Which older supported branches are affected by this flaw?

I believe we should fix this in 44.  Its probably been in the service worker code the entire time, but its disabled behind a pref on earlier branches.

If not all supported branches, which bug introduced the flaw?

Probably there from the first service worker manager impl.  Again, disabled on earlier branches.

Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be?

This patch should uplift cleanly to aurora 44.

How likely is this patch to cause regressions; how much testing does it need?

No risk.  Its simply holding a strong ref where the code expects the object to stay alive.  Tested locally using existing mochitests and wpt tests.
Attachment #8696031 - Flags: sec-approval?
Comment on attachment 8696031 [details] [diff] [review]
Hold a strong ref in service worker NS_NewRunnableMethodWithArg uses. r=ehsan

Approval Request Comment
[Feature/regressing bug #]: Service workers
[User impact if declined]: Probably minimal, since this seems hard to exploit.  It would be nice to close the UAF race, though, since we are shipping SW on 44.
[Describe test coverage new/current, TreeHerder]: Existing mochitests and wpt tests.
[Risks and why]: Minimal.  Service workers only.
[String/UUID change made/needed]: None.
Attachment #8696031 - Flags: approval-mozilla-aurora?
Comment on attachment 8696031 [details] [diff] [review]
Hold a strong ref in service worker NS_NewRunnableMethodWithArg uses. r=ehsan

Approvals given.
Attachment #8696031 - Flags: sec-approval?
Attachment #8696031 - Flags: sec-approval+
Attachment #8696031 - Flags: approval-mozilla-aurora?
Attachment #8696031 - Flags: approval-mozilla-aurora+
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Group: dom-core-security → core-security-release
Whiteboard: [post-critsmash-triage]
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.