Closed Bug 1658672 Opened 6 years ago Closed 6 years ago

CRASH intent in Fenix allows other apps to delete arbitrary private files

Categories

(Firefox for Android :: General, task)

Unspecified
Android
task

Tracking

()

RESOLVED FIXED

People

(Reporter: sdna.muneaki.nishimura, Assigned: roger)

Details

(4 keywords, Whiteboard: [reporter-external] [client-bounty-form] [verif?])

Attachments

(2 files, 2 obsolete files)

Any intent that has key mozilla.components.lib.crash.CRASH is handled as CrashReporter intent and Fenix shows CrashReporterFragment on the screen (below).
https://github.com/mozilla-mobile/fenix/blob/master/app/src/main/java/org/mozilla/fenix/home/intent/CrashReporterIntentProcessor.kt#L20

The CRASH intent can contain a local file path in minidumpPath or extrasPath key and the specified file pathes are finally sent to the crash-stats server and deleted (below).
https://github.com/mozilla-mobile/android-components/blob/master/components/lib/crash/src/main/java/mozilla/components/lib/crash/service/MozillaSocorroService.kt#L245

This means that other application can delete arbitrary Fenix's private files in the device (e.g., profiles.ini) by sending a crafted CRASH intent.

The following Kotlin code is the demonstration. Also see the attahed animation gif.

var intent = Intent("android.intent.action.VIEW", Uri.parse("https://example.com/"))
intent.putExtra("mozilla.components.lib.crash.CRASH", Bundle().apply {
    putString("uuid", "DUMMY")
    putString("minidumpPath", "/data/data/org.mozilla.fenix.debug/files/mozilla/profiles.ini")
    putBoolean("minidumpSuccess", true)
    putBoolean("fatal", false)
})
startActivity(intent)
Flags: sec-bounty?
Group: firefox-core-security → mobile-core-security
Component: Security → Security: Android
Product: Firefox → Fenix

Could this intent be sent from Fenix itself? I think we finally blocked self-intents, but this one may go to a separate component or service. If it could be a self-intent then users could be exposed to a pretty bad DOS from web content, not just a local malicious app.

Flags: needinfo?(s.kaspari)

(In reply to Daniel Veditz [:dveditz] from comment #1)

Could this intent be sent from Fenix itself? I think we finally blocked self-intents, but this one may go to a separate component or service. If it could be a self-intent then users could be exposed to a pretty bad DOS from web content, not just a local malicious app.

I think it would be partially yes.
Fenix allows to send a CRASH intent from web contents by intent: link and that makes Fenix crash easily.

<a href="intent://csrf.jp#Intent;scheme=http;S.mozilla.components.lib.crash.CRASH=XXX;end">Crash Fenix</a>

You can try this here.
https://csrf.jp/2020/crash.html

But I don't know how to set minidumpPath in that intent URL because that parameter is in a Bundle type extras...

Flags: needinfo?(s.kaspari)
Flags: needinfo?(royang)

After looking into this issue. The safest (smallest) change is to check the crash dump file extensions before parsing / deleting the files.

Flags: needinfo?(royang)
Attached patch check_crash_file_extension.patch (obsolete) — — Splinter Review
Assignee: nobody → royang
Attachment #9178820 - Flags: review?(s.kaspari)

You can make the filename check even tighter, see the regex we use in the crash manager.

(In reply to Gabriele Svelto [:gsvelto] from comment #5)

You can make the filename check even tighter, see the regex we use in the crash manager.

Nice, I'll update. Thanks!

Attached patch check_crash_file_extension.patch (obsolete) — — Splinter Review

Update with regex from GV

Attachment #9178820 - Attachment is obsolete: true
Attachment #9178820 - Flags: review?(s.kaspari)
Attachment #9178858 - Flags: review?(s.kaspari)
Comment on attachment 9178858 [details] [diff] [review] check_crash_file_extension.patch Review of attachment 9178858 [details] [diff] [review]: ----------------------------------------------------------------- This looks good and prevents the file removal as described. In this case the Intent was a "public" API that other apps could have invoked too (exported activity). But I do wonder if we prevent "intent://" URLs from invoking internal components that are usually not marked as exported in the manifest? ::: components/lib/crash/src/main/java/mozilla/components/lib/crash/service/MozillaSocorroService.kt @@ +9,4 @@ > import android.content.pm.PackageManager > import android.net.Uri > import android.os.Build > +import android.util.Log Left over from testing? :) @@ +51,5 @@ > > private const val KEY_CRASH_ID = "CrashID" > > +private const val MINI_DUMP_FILE_EXT = ".dmp" > +private const val EXTRAS_FILE_EXT = ".extra" Do we need to escape the dots here to avoid them being interpreted as "any character"?
Attachment #9178858 - Flags: review?(s.kaspari) → review+

(In reply to Sebastian Kaspari (:sebastian; :pocmo) from comment #8)

Left over from testing? :)

oops I'll remove.

Do we need to escape the dots here to avoid them being interpreted as "any
character"?

You're correct. This is interpreted as "any", not what I wanted. I'll fix.

(In reply to Sebastian Kaspari (:sebastian; :pocmo) from comment #8)

In this case the Intent was a "public" API that other apps could have
invoked too (exported activity). But I do wonder if we prevent "intent://"
URLs from invoking internal components that are usually not marked as
exported in the manifest?

I'll investigate.

Attachment #9178858 - Attachment is obsolete: true
Attachment #9179012 - Flags: review?(s.kaspari)
Attachment #9179012 - Flags: review?(s.kaspari) → review+

(In reply to Daniel Veditz [:dveditz] from comment #1)

Could this intent be sent from Fenix itself? I think we finally blocked self-intents, but this one may go to a separate component or service. If it could be a self-intent then users could be exposed to a pretty bad DOS from web content, not just a local malicious app.

I've confirmed that web content cannot trigger this issue. Current implementation filters out all browsers (including ourselves) when looking for a third party app to handle the intent. If there is no third party app that handles this, we extract the URL from the data (without the "mozilla.components.lib.crash.CRASH" extra) and just loads the URL. In this case the result will see Fenix loading "https://www.example.com" without handling the crash bundle.

Patch applied and merged in A-C. Marking this issue as resolved.

Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Flags: sec-bounty? → sec-bounty+
Keywords: dataloss
Group: core-security-release
Group: mobile-core-security
Group: core-security-release
Component: Security: Android → General
OS: Unspecified → Android
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: