Closed
Bug 1478575
Opened 6 years ago
Closed 6 years ago
AddressSanitizer: heap-use-after-free [@ Id] with READ of size 4 through [@ mozilla::camera::PCamerasChild::SendGetCaptureDevice]
Categories
(Core :: WebRTC: Audio/Video, defect, P1)
Tracking
()
People
(Reporter: decoder, Assigned: pehrsons)
References
(Blocks 1 open bug)
Details
(4 keywords, Whiteboard: [adv-main62+][adv-esr60.2+][post-cristsmash-triage])
Attachments
(2 files)
(deleted),
text/plain
|
Details | |
(deleted),
patch
|
gcp
:
review+
RyanVM
:
approval-mozilla-beta+
RyanVM
:
approval-mozilla-esr60+
abillings
:
sec-approval+
|
Details | Diff | Splinter Review |
The attached crash information was submitted via the ASan Nightly Reporter on mozilla-central-asan-nightly revision 63.0a1-20180724100052-https://hg.mozilla.org/mozilla-central/rev/1e5fa52a612e8985e12212d1950a732954e00e45.
For detailed crash information, see attachment.
Reporter | ||
Comment 1•6 years ago
|
||
Reporter | ||
Updated•6 years ago
|
Group: core-security
Reporter | ||
Comment 2•6 years ago
|
||
:gcp, could this be something for you to look at? Thanks!
Flags: needinfo?(gpascutto)
Updated•6 years ago
|
Keywords: csectype-uaf,
sec-high
Comment 3•6 years ago
|
||
This looks like the runnable in CamerasChild::GetCaptureDevice:
nsCOMPtr<nsIRunnable> runnable =
mozilla::NewRunnableMethod<CaptureEngine, unsigned int>(
"camera::PCamerasChild::SendGetCaptureDevice",
this,
&CamerasChild::SendGetCaptureDevice,
aCapEngine,
list_number);
|this| is presumably the dead pointer.
Comment 4•6 years ago
|
||
Bug 1426129 is a previous similar looking crash.
Comment 5•6 years ago
|
||
We probably need to hold a strong reference there for the length of life of the runnable.
Updated•6 years ago
|
Group: core-security → media-core-security
Reporter | ||
Updated•6 years ago
|
No longer blocks: asan-nightly-project
Comment 6•6 years ago
|
||
I am noticing that this bug is marked as sec-high but has no assignee set nor any activity since it was filed 2 weeks ago, David could you help us find somebody to work on it please? Thanks!
tracking-firefox63:
--- → +
Flags: needinfo?(ddurst)
Comment 7•6 years ago
|
||
Andreas, Paul, you guys fixed the previous case of this, could you take this one?
I could take it if no-one else can but at this point the review (checking all the threading issues noted in bug 1426129) is going to take as long as the actual fix.
Flags: needinfo?(padenot)
Flags: needinfo?(gpascutto)
Flags: needinfo?(apehrson)
Comment 8•6 years ago
|
||
Tentatively taking, but I could do with someone stealing this from me :-)
Assignee: nobody → padenot
Flags: needinfo?(padenot)
Assignee | ||
Comment 9•6 years ago
|
||
(In reply to Alex Gaynor [:Alex_Gaynor] from comment #5)
> We probably need to hold a strong reference there for the length of life of
> the runnable.
NewRunnableMethod already keeps a strong ref to the instance. CamerasChild::GetCaptureDevice must have been called on an already destroyed CamerasChild.
All calls to GetCaptureDevice go through the static CamerasChild::GetChildAndCall.
GetChildAndCall does operate on a rawptr, though behind a locked mutex:
https://searchfox.org/mozilla-central/rev/83562422ecb0f5683da7a9a26ce05ce62bc0c882/dom/media/systemservices/CamerasChild.h#142-145
DeallocPCamerasChild which releases the CamerasChild in this case (thanks asan) doesn't grab this mutex:
https://searchfox.org/mozilla-central/rev/83562422ecb0f5683da7a9a26ce05ce62bc0c882/ipc/glue/BackgroundChildImpl.cpp#401-403
This appears to be the hole we're looking for.
Assignee: padenot → apehrson
Status: NEW → ASSIGNED
Component: Audio/Video → WebRTC: Audio/Video
Flags: needinfo?(apehrson)
Priority: -- → P1
Assignee | ||
Comment 10•6 years ago
|
||
Attachment #9002412 -
Flags: review?(gpascutto)
Assignee | ||
Updated•6 years ago
|
Flags: needinfo?(ddurst)
Updated•6 years ago
|
Attachment #9002412 -
Flags: review?(gpascutto) → review+
Assignee | ||
Comment 11•6 years ago
|
||
Comment on attachment 9002412 [details] [diff] [review]
Unify CamerasChild shutdown paths
[Security approval request comment]
How easily could an exploit be constructed based on the patch?
Very hard.
Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?
Well, shutdown is bulls-eye but the specific shutdown mode needed here (see stack in comment 0) is unclear. We're not sure how to trigger this for repro either.
Which older supported branches are affected by this flaw?
All
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?
I expect them to go cleanly. Relevant code appears to have been mostly stable (a few sec fixes) since way before 52.
How likely is this patch to cause regressions; how much testing does it need?
Unlikely, the added path is thread safe.
Attachment #9002412 -
Flags: sec-approval?
Comment 12•6 years ago
|
||
I'd love to take this but we only have a single beta left, building tomorrow. I need to ni? release management and get their approval.
status-firefox61:
--- → wontfix
status-firefox62:
--- → affected
status-firefox-esr52:
--- → wontfix
status-firefox-esr60:
--- → affected
tracking-firefox62:
--- → +
tracking-firefox-esr60:
--- → 62+
Flags: needinfo?(rkothari)
Flags: needinfo?(lhenry)
Flags: needinfo?(jcristau)
Comment 13•6 years ago
|
||
We can take it if it hits m-c today still.
Flags: needinfo?(rkothari)
Flags: needinfo?(lhenry)
Flags: needinfo?(jcristau)
Comment 14•6 years ago
|
||
Comment on attachment 9002412 [details] [diff] [review]
Unify CamerasChild shutdown paths
Sec-approval+ for trunk. We'll need a beta patch and an ESR60 patch nominated ASAP to try to get tomorrow's final beta for 62.
Flags: needinfo?(apehrson)
Attachment #9002412 -
Flags: sec-approval? → sec-approval+
Comment 15•6 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/366a2aa802b5a7bd06328a7162f10292cbde3411
This grafts cleanly to Beta and ESR60 as-is, so it just needs the approval requests made after it's merged to m-c.
Comment 16•6 years ago
|
||
Group: media-core-security → core-security-release
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
Assignee | ||
Comment 17•6 years ago
|
||
Comment on attachment 9002412 [details] [diff] [review]
Unify CamerasChild shutdown paths
[Approval Request Comment]
If this is not a sec:{high,crit} bug, please state case for ESR consideration: sec-high
User impact if declined: Possible crash/UAF during shutdown or after an ipc error. Errors are likely connected to shutdown.
Fix Landed on Version: 63
Risk to taking this patch (and alternatives if risky): Low risk as it makes a rare shutdown path go through normal (and well-tested) shutdown. I haven't seen any big numbers for this crash in the wild.
String or UUID changes made by this patch: None
Flags: needinfo?(apehrson)
Attachment #9002412 -
Flags: approval-mozilla-esr60?
Attachment #9002412 -
Flags: approval-mozilla-beta?
Reporter | ||
Comment 18•6 years ago
|
||
When you find some time, it would be very helpful if you could answer the following questions so I can work on improving ASan Nightly further. In particular, many of the reports we saw about use-after-free were sent only once, not multiple times. So I'm asking myself what changes to ASan Nightly I can make to improve overall uaf detection rate:
1) Do you think more frequent GC/CC would have helped detecting this problem more frequently?
2) Do you think GC/CC on specific DOM events (e.g. beforeunload, pagehide, DOMContentLoaded) would have helped?
3) Do you think triggering the event loop in the specific child processes would have helped here? (e.g. dummy XMLHttpRequest onbeforeunload, useful in fuzzing).
4) Do you have any other ideas to reproduce this particular problem better or do you think any of the above points (or other approaches) might help to find other use-after-free issues in areas that you work in?
Any feedback would be greatly appreciated. Thanks!
Flags: needinfo?(apehrson)
Comment 19•6 years ago
|
||
Comment on attachment 9002412 [details] [diff] [review]
Unify CamerasChild shutdown paths
Fixes a WebRTC sec-high. Approved for 62.0b20 and ESR 60.2.
Attachment #9002412 -
Flags: approval-mozilla-esr60?
Attachment #9002412 -
Flags: approval-mozilla-esr60+
Attachment #9002412 -
Flags: approval-mozilla-beta?
Attachment #9002412 -
Flags: approval-mozilla-beta+
Comment 20•6 years ago
|
||
uplift |
Comment 21•6 years ago
|
||
uplift |
Updated•6 years ago
|
Whiteboard: [adv-main62+][adv-esr60.2+]
Comment 22•6 years ago
|
||
decoder: I doubt this sort of problem is strongly influenced by GC/CC timing; this is in IPC and pure refcounted objects.
This is influenced by thread timing, ordering, load, etc. some form of thread 'chaos' mode may expose more (see rr's chaos mode, etc). Especially timing around IPC; typically on multicore an IPC may not force an immediate yield by the caller; conversely a receiver may run immediately and finish before the caller has done "a lot". Ditto Dispatch() (perhaps even more in Dispatch). Having the sender or receiver occasionally (randomly) yield for a short time might increase the odds of an IPC/Dispatch-related UAF.
Flags: needinfo?(choller)
Updated•6 years ago
|
Flags: qe-verify-
Whiteboard: [adv-main62+][adv-esr60.2+] → [adv-main62+][adv-esr60.2+][post-cristsmash-triage]
Reporter | ||
Updated•6 years ago
|
Flags: needinfo?(choller)
Flags: needinfo?(apehrson)
Updated•5 years ago
|
Group: core-security-release
Updated•5 years ago
|
Blocks: asan-maintenance
You need to log in
before you can comment on or make changes to this bug.
Description
•