Closed Bug 1417797 Opened 3 years ago Closed 3 years ago

UAF in H264 decoder shutdown in VCMDecodedFrameCallback::Decoded()


(Core :: WebRTC: Audio/Video, defect, P1)

55 Branch



Tracking Status
firefox-esr52 58+ fixed
firefox57 --- wontfix
firefox58 + fixed
firefox59 + fixed


(Reporter: jesup, Assigned: dminor)




(Keywords: crash, csectype-uaf, sec-high, Whiteboard: [adv-main58+][adv-esr52.6+][post-critsmash-triage])


(2 files)

Attached file gmp.asan
During shutdown of a PeerConnection (in this case navigating away from to see other channels), it's possible that the "external" H264 decoder is released and destroyed while a frame decode is still pending from the GMP decoder, which is asynchronous.

Fairly certain this affects all current versions.
Managed to repro the failure (again by leaving a channel using the << in the upper-left)
Rank: 15
Priority: -- → P2
I'll have a look.
Assignee: nobody → dminor
sec-high should be P1
Priority: P2 → P1
Rank: 15 → 5
I was able to reproduce the bug several times in an ASAN build but never with this patch applied.

The locking in RegisterDecodeCompleteCallback and Decoded should ensure that callbacks stop prior to GMP shutdown. mCallback is already nullchecked prior to use, so this should be safe.
Attachment #8930156 - Flags: review?(rjesup)
Attachment #8930156 - Flags: review?(rjesup) → review+
Comment on attachment 8930156 [details] [diff] [review]
Stop decode callback in WebrtcGmpVideoDecoder::ReleaseGmp

[Security approval request comment]
How easily could an exploit be constructed based on the patch?
You could infer from the patch we were getting a late callback during shutdown, but I don't think it would be that easy to exploit because it is timing dependent.
Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?
Which older supported branches are affected by this flaw?
If not all supported branches, which bug introduced the flaw?

Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be?
Easy to create.
How likely is this patch to cause regressions; how much testing does it need?
Unlikely, this should be a safe change given that we already allow mCallback to be nullptr.
Attachment #8930156 - Flags: sec-approval?
sec-approval+ for checkin on November 28. We'll want branch patches nominated at this time as well.
Whiteboard: [checkin on 11/28]
Attachment #8930156 - Flags: sec-approval? → sec-approval+
Comment on attachment 8930156 [details] [diff] [review]
Stop decode callback in WebrtcGmpVideoDecoder::ReleaseGmp

Approval Request Comment
[Feature/Bug causing the regression]:
[User impact if declined]:
Crashes / security problems.
[Is this code covered by automated tests?]:
This is a shutdown bug so it is covered by the existing tests.
[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?]:
[Why is the change risky/not risky?]:
Locking ensures that all callbacks will end before we can set the callback to null and we already allowed a null callback in the existing code.
[String changes made/needed]:
Attachment #8930156 - Flags: approval-mozilla-beta?
Whiteboard: [checkin on 11/28]
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
This grafts cleanly to ESR52 also. Is it ready for an uplift approval there too or does it need more rebasing?
Flags: needinfo?(dminor)
Comment on attachment 8930156 [details] [diff] [review]
Stop decode callback in WebrtcGmpVideoDecoder::ReleaseGmp

[Approval Request Comment]
If this is not a sec:{high,crit} bug, please state case for ESR consideration:
User impact if declined:
Crashes / security problems. 
Fix Landed on Version:
Risk to taking this patch (and alternatives if risky):
Low risk. This grafts cleanly and I ran manual tests on ESR52 yesterday.
String or UUID changes made by this patch: 

See for more info.
Flags: needinfo?(dminor)
Attachment #8930156 - Flags: approval-mozilla-esr52?
Group: media-core-security → core-security-release
Comment on attachment 8930156 [details] [diff] [review]
Stop decode callback in WebrtcGmpVideoDecoder::ReleaseGmp

Fix a sec-high. Beta58+ & ESR52+.
Attachment #8930156 - Flags: approval-mozilla-esr52?
Attachment #8930156 - Flags: approval-mozilla-esr52+
Attachment #8930156 - Flags: approval-mozilla-beta?
Attachment #8930156 - Flags: approval-mozilla-beta+
Whiteboard: [adv-main58+][adv-esr52.6+]
Flags: qe-verify-
Whiteboard: [adv-main58+][adv-esr52.6+] → [adv-main58+][adv-esr52.6+][post-critsmash-triage]
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.