Crash in android.os.FileUriExposedException: at android.os.StrictMode.onFileUriExposed(StrictMode.java)

VERIFIED FIXED in Firefox 63

Status

()

defect
--
critical
VERIFIED FIXED
6 months ago
5 months ago

People

(Reporter: gsvelto, Assigned: JanH)

Tracking

(Blocks 1 bug, {crash, regression})

Firefox 63
Firefox 65
All
Android
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox63+ verified, firefox64 verified, firefox65 verified)

Details

(crash signature)

Attachments

(2 attachments)

(Reporter)

Description

6 months ago
This bug was filed from the Socorro interface and is
report bp-1215d19c-321c-49ae-91a8-da30c0181021.
=============================================================

Java stack trace:

android.os.FileUriExposedException
	at android.os.StrictMode.onFileUriExposed(StrictMode.java:1796)
	at android.net.Uri.checkFileUriExposed(Uri.java:2354)
	at android.content.Intent.prepareToLeaveProcess(Intent.java:9026)
	at android.content.Intent.prepareToLeaveProcess(Intent.java:8987)
	at android.app.Instrumentation.execStartActivity(Instrumentation.java:1519)
	at android.app.Activity.startActivityForResult(Activity.java:4321)
	at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)
	at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:67)
	at android.app.Activity.startActivityForResult(Activity.java:4279)
	at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:720)
	at android.app.Activity.startActivity(Activity.java:4618)
	at android.app.Activity.startActivity(Activity.java:4586)
	at org.mozilla.gecko.ActivityHandlerHelper.startIntentAndCatch(ActivityHandlerHelper.java:33)
	at org.mozilla.gecko.IntentHelper.openUriExternal(IntentHelper.java:148)
	at org.mozilla.gecko.IntentHelper.open(IntentHelper.java:439)
	at org.mozilla.gecko.IntentHelper.handleMessage(IntentHelper.java:422)
	at org.mozilla.gecko.EventDispatcher$3.run(EventDispatcher.java:356)
	at android.os.Handler.handleCallback(Handler.java:751)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:154)
	at android.app.ActivityThread.main(ActivityThread.java:6351)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:896)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:786)

Looking at the exception message it seems that we're trying to create an Intent with a file:// URI which is not supported anymore starting with API 24. It seems that to get around this either we have to use a less restrictive VM policy or we have to only use Intents with content:// URIs.
(Assignee)

Comment 1

6 months ago
Right, I guess this might be possibly users browsing the local file system (or having opened some file type we support in Firefox from some other app) and then attempting to open that document/image/... in some other app using our helper app system.

(In reply to Gabriele Svelto [:gsvelto] from comment #0)
> It seems that to get around this either we have to use a less
> restrictive VM policy or we have to only use Intents with content:// URIs.

We do the former, because for world-accessible files in the public storage content:// URIs aren't as great as Googles makes them out to be (just look at what we have to do in order to properly display an HTML file we receive via a content:// URI). I handled downloads, and know that normal sharing doesn't work for file:// URIs, but didn't think of the helper app system.
Assignee: nobody → jh+bugzilla
Hardware: Unspecified → All
See Also: → 1450449
Version: unspecified → Firefox 63
(Assignee)

Comment 2

6 months ago
Sharing tabs with file:// URIs is not possible, but users can still send them to
other apps via the helper app system in the URL bar/context menu. "Intent:Open"
and "Intent:OpenForResult" are both sent from Gecko by HelperApps.jsm.

The same reasoning as in bug 1450449 applies as to why for publicly accessible
files content:// URIs are more trouble than they're worth.
(Assignee)

Comment 3

6 months ago
I guess this could count as a regression caused by the target API26 migration.
Keywords: regression
Tracking for a potential 63 dot release.
(Assignee)

Updated

6 months ago
(Assignee)

Comment 5

6 months ago
Sharing tabs with file:// URIs is not possible, but users can still send them to
other apps via the helper app system in the URL bar/context menu. "Intent:Open"
and "Intent:OpenForResult" are both sent from Gecko by HelperApps.jsm.

The same reasoning as in bug 1450449 applies as to why for publicly accessible
files content:// URIs are more trouble than they're worth.

Comment 6

6 months ago
Pushed by mozilla@buttercookie.de:
https://hg.mozilla.org/integration/autoland/rev/73cfb79f183a
Suppress FileUriExposedExceptions when launching helper apps. r=jchen
(Assignee)

Comment 7

6 months ago
Comment on attachment 9019105 [details]
Bug 1500906 - Suppress FileUriExposedExceptions when launching helper apps. r?esawin

[Beta/Release Uplift Approval Request]

Feature/Bug causing the regression: Bug 1485151

User impact if declined: Firefox will crash on Android N and later if viewing a locally stored file and attempting to use our helper app system (context menu link or the Android icon in the URL bar) to launch that file in an external app.

Is this code covered by automated tests?: No

Has the fix been verified in Nightly?: No

Needs manual test from QE?: Yes

If yes, steps to reproduce: Open a local file in Firefox (so you get a file://-URI in the URLbar) that can also be opened in some other locally installed app - some media file is most likely to work. Using the Android icon in the URLbar to launch the current page in Firefox in an external app using a file:// URI should no longer trigger a crash.

List of other uplifts needed: None

Risk to taking this patch: Low

Why is the change risky/not risky? (and alternatives if risky): Trivial change to temporarily disable the corresponding strict mode checks when launching helper apps - we also do the same thing for downloads already.

String changes made/needed: none
Attachment #9019105 - Flags: approval-mozilla-beta?
(Assignee)

Comment 8

6 months ago
Comment on attachment 9019807 [details]
Bug 1500906 - Suppress FileUriExposedExceptions when launching helper apps. r?esawin

[Beta/Release Uplift Approval Request]

Feature/Bug causing the regression: Bug 1473872

User impact if declined: Firefox will crash on Android N and later if viewing a locally stored file and attempting to use our helper app system (context menu link or the Android icon in the URL bar) to launch that file in an external app.

Is this code covered by automated tests?: No

Has the fix been verified in Nightly?: No

Needs manual test from QE?: Yes

If yes, steps to reproduce: Open a local file in Firefox (so you get a file://-URI in the URL bar) that can also be opened in some other locally installed app - some media file is most likely to work. Using the Android icon in the URL bar to launch the current page in Firefox in an external app using a file:// URI should no longer trigger a crash.

List of other uplifts needed: None

Risk to taking this patch: Low

Why is the change risky/not risky? (and alternatives if risky): Trivial change to temporarily disable the corresponding strict mode checks when launching helper apps - we also do the same thing for downloads already.

String changes made/needed: none
Attachment #9019807 - Attachment description: Bug 1500906 - Suppress FileUriExposedExceptions when launching helper apps. r?jchen → Bug 1500906 - Suppress FileUriExposedExceptions when launching helper apps. r?esawin
Attachment #9019807 - Attachment filename: phabricator-D9697-url.txt → phabricator-D9420-url.txt
Attachment #9019807 - Flags: approval-mozilla-beta?
(Assignee)

Comment 9

6 months ago
Comment on attachment 9019807 [details]
Bug 1500906 - Suppress FileUriExposedExceptions when launching helper apps. r?esawin

[Beta/Release Uplift Approval Request]

Feature/Bug causing the regression: None

User impact if declined: 

Is this code covered by automated tests?: Yes

Has the fix been verified in Nightly?: Yes

Needs manual test from QE?: Yes

If yes, steps to reproduce: 

List of other uplifts needed: None

Risk to taking this patch: Low

Why is the change risky/not risky? (and alternatives if risky): 

String changes made/needed:
Attachment #9019807 - Flags: approval-mozilla-beta? → approval-mozilla-release?
(Assignee)

Comment 10

6 months ago
Release requires a separate patch because bug 1485151, which allows a more concise way of temporarily disabling strict mode, is only in Firefox 64.

Comment 11

6 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/73cfb79f183a
Status: NEW → RESOLVED
Last Resolved: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 65
Comment on attachment 9019105 [details]
Bug 1500906 - Suppress FileUriExposedExceptions when launching helper apps. r?esawin

Fixes a Fennec crash. Approved for 64.0b4 (or b5, I haven't decided yet if I'm going to spin a Fennec b4 or not yet).
Attachment #9019105 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Verified as fixed on Nightly build 65.0a1 and 64.0b4 with the following devices: Huawei Honor 8(Android 7.0) and Samsung Galaxy Note 8(Android 8.0.0).
Status: RESOLVED → VERIFIED
Comment on attachment 9019807 [details]
Bug 1500906 - Suppress FileUriExposedExceptions when launching helper apps. r?esawin

Patch already on Nightly 65 and uplifted to 64 with no regression reported. The last 2 betas with this patch have seen crashes reduced very significantly for this signature. Uplift approved to release for our next dot release for 63. Thanks.
Attachment #9019807 - Flags: approval-mozilla-release? → approval-mozilla-release+
Flags: qe-verify+
Verified as fixed on RC build 63.0.2 following the steps from comment 8.
Devices: Nokia 6(Android 7.1.1) and Samsung Galaxy Tab S3(Android 8.0).
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.