Crash in [@ mozilla::dom::Directory::GetFullRealPath]
Categories
(Core :: DOM: Forms, defect)
Tracking
()
People
(Reporter: gsvelto, Assigned: mccr8)
Details
(Keywords: crash, csectype-uaf, sec-high, Whiteboard: [sec-survey][adv-main92+r][adv-esr78.14+r][adv-esr91.1+r])
Crash Data
Attachments
(1 external file)
Crash report: https://crash-stats.mozilla.org/report/index/40615982-1e66-4a24-8afc-ea0cf0210712
Reason: EXC_BAD_ACCESS / KERN_INVALID_ADDRESS
Top 10 frames of crashing thread:
0 XUL mozilla::dom::Directory::GetFullRealPath dom/filesystem/Directory.cpp:133
1 XUL mozilla::dom::HTMLInputElement::AfterSetFilesOrDirectories dom/html/HTMLInputElement.cpp:2508
2 XUL mozilla::dom::HTMLInputElement::AfterSetFilesOrDirectories dom/html/HTMLInputElement.cpp:2508
3 XUL mozilla::dom::DispatchChangeEventCallback::Callback dom/html/HTMLInputElement.cpp:234
4 XUL mozilla::dom::GetFilesHelper::OperationCompleted dom/filesystem/GetFilesHelper.cpp:232
5 XUL mozilla::dom::ContentChild::RecvGetFilesResponse dom/ipc/ContentChild.cpp:3251
6 XUL mozilla::dom::PContentChild::OnMessageReceived ipc/ipdl/PContentChild.cpp:11689
7 XUL mozilla::ipc::MessageChannel::DispatchMessage ipc/glue/MessageChannel.cpp:2012
8 XUL mozilla::ipc::MessageChannel::MessageTask::Run ipc/glue/MessageChannel.cpp:1891
9 XUL mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal xpcom/threads/TaskController.cpp:805
I just stumbled upon this because the new exception handler I rolled out on macOS (bug 1035892) is printing out the poison pattern correctly when the crash was caused by an UAF. From the looks of it HTMLInputElement::AfterSetFilesOrDirectories() is calling Directory::GetFullRealPath() with a dead Directory object. In particular it seems to me that mFileData->mFilesOrDirectories[0] here is the source of the dead object.
The crash stack seems consistent in versions going back to ESR78.
| Assignee | ||
Updated•5 years ago
|
Comment 1•5 years ago
|
||
Hmm, this isn't super obvious. Objects should be kept alive by strong pointers.
| Reporter | ||
Comment 2•5 years ago
|
||
I found an hint that might be useful by looking at the crash comments: it seems that this is triggered by uploading large number of files to various cloud storage services:
Crashed whilst uploading a large directory from a WSL drive to a sharepoint directory>
Tried to upload Folder
TRying to send a folder using wetransfer.com
onedrive hack remote reboot manage it is off
I tried to upload too much on a google drive
I was downloading all my Pictures from my Computer C: Drive to Dropbox when the process stopped/crashed.
Presumably the last one meant "uploading".
The URLs in the crashes seem to confirm this hypothesis, there's Google Drive, WeTransfer, etc...
| Assignee | ||
Comment 3•5 years ago
|
||
From ContentChild::RecvGetFilesResponse: GetFilesHelperChild* child = mGetFilesPendingRequests.GetWeak(aUUID);
Then later child->Finished(), where Finished will call into GetFilesHelper::ResolveOrRejectPromise(), which can run JS, which could trigger GC/CC (and do more IPC?). However, we should still have a strong reference from mGetFilesPendingRequests. Could we get multiple GetFilesResponse for the same UUID?
| Assignee | ||
Comment 4•5 years ago
|
||
I tried uploading a folding containing the files in dom/base/tests/*.html (around 600 files) and it didn't crash. I tried deleting the directory when it was about 75% of the way through to provoke an error but that didn't crash either.
| Assignee | ||
Updated•5 years ago
|
| Assignee | ||
Comment 5•5 years ago
|
||
Nika pointed out that HTMLInputElement's Unlink method can remove GetFilesHelperChilds from mGetFilesPendingRequests, and GetFilesHelperChild does not hold alive input elements, so it is plausible that doing a CC/GC leads to this. She also suggested that in addition to rooting the child we should remove it from mGetFilesPendingRequests immediately rather than waiting until RecvGetFilesResponse is done. I don't know if it matters from a safety perspective, but it does look more consistent.
| Assignee | ||
Comment 6•5 years ago
|
||
I'm not sure how to test this code. The test that was added when RecvGetFilesResponse was added doesn't seem to hit this method at all.
| Assignee | ||
Comment 7•5 years ago
|
||
browser_confirmFolderUpload.js does seem to at least run RecvGetFilesResponse. I'm still not sure how to write at test for this. The basic idea would be to get a test case that will run a callback or promise from the GetFilesHelperChild, then in the callback remove the input element from the DOM, clear all references to it (including local variables in JS), then call SpecialPowers.forceGC and forceCC.
| Assignee | ||
Comment 8•5 years ago
|
||
| Assignee | ||
Updated•5 years ago
|
| Assignee | ||
Comment 9•5 years ago
|
||
Comment on attachment 9235715 [details]
Bug 1723391 - Use RefPtr in ContentChild::RecvGetFilesResponse.
Security Approval Request
- How easily could an exploit be constructed based on the patch?: Pretty easily.
- Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?: No
- Which older supported branches are affected by this flaw?: all
- If not all supported branches, which bug introduced the flaw?: None
- Do you have backports for the affected branches?: No
- If not, how different, hard to create, and risky will they be?: Should be easy. ContentChild::RecvGetFilesResponse hasn't changed since 2017.
- How likely is this patch to cause regressions; how much testing does it need?: The patch is very simple, so it shouldn't cause any issues.
Comment 10•5 years ago
|
||
Comment on attachment 9235715 [details]
Bug 1723391 - Use RefPtr in ContentChild::RecvGetFilesResponse.
sec-approval = dveditz
Updated•5 years ago
|
Comment 11•5 years ago
|
||
Use RefPtr in ContentChild::RecvGetFilesResponse. r=smaug
https://hg.mozilla.org/integration/autoland/rev/bdb1946432c419386caab8ba0acd63184bd916bc
https://hg.mozilla.org/mozilla-central/rev/bdb1946432c4
Comment 12•5 years ago
|
||
The patch landed in nightly and beta is affected.
:mccr8, is this bug important enough to require an uplift?
If not please set status_beta to wontfix.
For more information, please visit auto_nag documentation.
| Assignee | ||
Comment 13•5 years ago
|
||
Comment on attachment 9235715 [details]
Bug 1723391 - Use RefPtr in ContentChild::RecvGetFilesResponse.
Beta/Release Uplift Approval Request
- User impact if declined: possible sec issues (there are crashes in the wild, but the volume is extremely low)
- Is this code covered by automated tests?: Yes
- Has the fix been verified in Nightly?: No
- Needs manual test from QE?: No
- If yes, steps to reproduce: No known steps to reproduce, unfortunately. The fix was made based on code inspection from a crash report.
- List of other uplifts needed: None
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): This just adds a strong stack reference.
- String changes made/needed: none
ESR Uplift Approval Request
- If this is not a sec:{high,crit} bug, please state case for ESR consideration:
- User impact if declined:
- Fix Landed on Version: 93
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky):
- String or UUID changes made by this patch:
Comment 14•5 years ago
|
||
Comment on attachment 9235715 [details]
Bug 1723391 - Use RefPtr in ContentChild::RecvGetFilesResponse.
Approved for 92.0b5, 91.1esr, and 78.14esr.
Comment 15•5 years ago
|
||
| uplift | ||
Comment 16•5 years ago
|
||
| uplift | ||
Comment 17•5 years ago
|
||
| uplift | ||
Comment 18•5 years ago
|
||
As part of a security bug pattern analysis, we are requesting your help with a high level analysis of this bug. It is our hope to develop static analysis (or potentially runtime/dynamic analysis) in the future to identify classes of bugs.
Please visit this google form to reply.
| Assignee | ||
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•4 years ago
|
Description
•