Closed Bug 1472925 Opened 5 years ago Closed 5 years ago

Potential UaF of MSG from CompleteAudioContextOperations


(Core :: Audio/Video: MediaStreamGraph, defect, P2)

59 Branch



Tracking Status
firefox-esr52 --- wontfix
firefox-esr60 62+ fixed
firefox61 --- wontfix
firefox62 + fixed
firefox63 + fixed


(Reporter: karlt, Assigned: karlt)



(Keywords: csectype-uaf, regression, sec-high, Whiteboard: [post-critsmash-triage][adv-main62+][adv-esr60.2+])


(3 files)

+++ This bug was initially created as a clone of Bug #1471953 +++

On ThreadedDriver thread:

1. MediaStreamGraphInitThreadRunnable::Run()
   dispatches AsyncCubebOperation::SHUTDOWN to an AsyncCubebTask thread.

2. ThreadedDriver::RunThread() can hand the graph back to the main thread.

On the main thread:

3. MediaStreamGraphShutDownRunnable::Run() waits for shutdown of the
   ThreadedDriver thread and then deletes the graph.

On the AsyncCubebTask thread:

4. CompleteAudioContextOperations tries to use the graph and calls a virtual
   function on a stale reference.

This is a very unlikely sequence of events, but I don't see anything to
guarantee it won't happen.

Detected by resetting GraphDriver::mGraphImpl when no longer safe to use
Summary: AddressSanitizer: heap-use-after-free /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/RefPtr.h:296:27 in get → Potential UaF of MSG from CompleteAudioContextOperations
This should work provided nothing tries to wake up the MSG again.  I think
we're safe from that because mPendingUpdateRunnables will not be run.
Attachment #8989339 - Flags: review?(padenot)
Attachment #8989339 - Flags: review?(padenot) → review+
Comment on attachment 8989339 [details] [diff] [review]
keep a strong reference to MediaStreamGraph from GraphDriver

[Security approval request comment]
How easily could an exploit be constructed based on the patch?
Not easily.  We don't have any evidence that this crash can happen in
practice, but the existence of bug 1471953 is evidence that similar races can
have unexpected winners.

Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?
The patch identifies the security problem.  It does not identify exactly where
the stale pointer is referenced, but
would identify one case if landed at the same time.

Which older supported branches are affected by this flaw?
All branches since 40 may be affected.

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

Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be?
The patch would need to be modified for other branches, but this would be
There is a low risk of introducing a leak, but automated tests should catch if
there is such a problem.

How likely is this patch to cause regressions; how much testing does it need?
Automated testing is sufficient.
Attachment #8989339 - Flags: sec-approval?
sec-approval+ for trunk.
Can I get Beta and ESR60 patches made and nominated as well, please?
Attachment #8989339 - Flags: sec-approval? → sec-approval+
Attached patch beta patchSplinter Review
Approval Request Comment
[Feature/Bug causing the regression]:
Possibly bug 1094764.
[User impact if declined]:
Potential sec-high.
[Is this code covered by automated tests?]:
The code is exercised by automated tests,
but we do not have a way to cause the race to be run in a way that
reproduces the bug.
[Has the fix been verified in Nightly?]:
[Needs manual test from QE? If yes, steps to reproduce]:
[List of other uplifts needed for the feature/fix]:
[Is the change risky?]:
There is a low risk of introducing a leak, but automated tests should catch if
there is such a problem.
[Why is the change risky/not risky?]:
It changes object lifetimes.
[String changes made/needed]:
Attachment #8990798 - Flags: approval-mozilla-beta?
Attached patch esr60 patchSplinter Review
[Approval Request Comment]
If this is not a sec:{high,crit} bug, please state case for ESR consideration:
User impact if declined:
Potential sec-high.
Fix Landed on Version:
Risk to taking this patch (and alternatives if risky):
There is a low risk of introducing a leak, but automated tests should catch if
there is such a problem.
String or UUID changes made by this patch:
Attachment #8990799 - Flags: approval-mozilla-esr60?
Group: media-core-security → core-security-release
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
From talking with Karl on irc, sounds like this fixes both this and bug 1471953.  Let's uplift this for beta and esr60 since it already landed on trunk.
Comment on attachment 8990798 [details] [diff] [review]
beta patch

Fix for UAF, let's uplift for beta 8.
Attachment #8990798 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Comment on attachment 8990799 [details] [diff] [review]
esr60 patch

Approved for ESR 60.2 also.
Attachment #8990799 - Flags: approval-mozilla-esr60? → approval-mozilla-esr60+
Flags: qe-verify-
Whiteboard: [post-critsmash-triage]
Whiteboard: [post-critsmash-triage] → [post-critsmash-triage][adv-main62+][adv-esr60.2+]
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.