Skip to content
Info disclosure Write-up Intermediate

Google Photos : Theft of Database & Arbitrary Files Android Vulnerability

The Google Photos Android app exported an activity that accepted file URIs without validation, allowing a third-party app to read arbitrary files from the app's sandbox. An attacker could steal the Google Photos database and other sensitive files, or cause a permanent denial of service in the conversation module.

Rahul Kankrale Follow

Published on servicenger.com

Bounty$1,337 View original

Google Photos android app’s activity com.google.android.apps.photos.pager.HostPhotoPagerActivity has set to exported with intent filter has file scheme support which means third party app could use this exported activity to pass file from file uri without access validation.

Rahul Kankrale, on servicenger.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

Google Photos for Android exposes an activity, com.google.android.apps.photos.pager.HostPhotoPagerActivity, that is declared as exported and carries an intent filter with file scheme support. Because the activity is exported, any third-party app installed on the same device can start it. Because the filter accepts the file scheme, a caller can hand it a file:// URI pointing at a path inside Google Photos' own private data directory, and the activity will process that URI without validating that the caller is allowed to read the file.

The feature involved is the photo pager and its share flow: the activity renders a media preview and offers a bottom sheet of apps to share to. Normally the URI comes from content the user is viewing inside Google Photos. The bug is that the activity trusts whatever URI it is started with.

Setup

No accounts, roles or special tooling are described beyond building and running an Android APK. The precondition is simply that the attacker's app is installed on the same device as the Google Photos app, and that the victim interacts with the preview the attacker triggers. The proof of concept is delivered as an APK that the researcher compiles and runs.

Finding it

The researcher noticed the combination of two manifest properties on HostPhotoPagerActivity: it is exported, and its intent filter supports the file scheme. Exported means other apps can launch it; file scheme support means the URI it receives can be a local filesystem path rather than a content provider URI. Together these mean a third-party app can pass a file:// URI for a file it has no permission to read, and the exported activity will open it on the caller's behalf, without access validation.

Exploitation

Step 1: Build and run an APK that starts the activity with a private file URI

The researcher compiles and runs an APK using the following intent:

Java
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());

Uri uri = Uri.parse("file:///data/data/com.google.android.apps.photos/databases/gphotos0.db");

Intent intent = new Intent("android.intent.action.SEND");
intent.setClassName("com.google.android.apps.photos", "com.google.android.apps.photos.pager.HostPhotoPagerActivity");
intent.setDataAndType(uri, "image/*");
startActivity(intent);

Toast.makeText(this, "Click On Share and Select iPhotos", Toast.LENGTH_LONG).show();

The Uri points at gphotos0.db, the Google Photos database inside the app's private data directory at /data/data/com.google.android.apps.photos/databases/. The intent uses the android.intent.action.SEND action and targets the exported activity explicitly with setClassName, so no other handler is involved. setDataAndType attaches the file URI and declares the MIME type as image/*, which is what makes the activity treat the database file as an image to preview. The StrictMode policy is set with a default builder, and a toast tells the user to click Share and select iPhotos.

Step 2: The preview appears

When the APK runs, Google Photos shows a media preview of the file, and the attacker's toast (Click On Share and Select iPhotos) is displayed. The victim sees what looks like an ordinary image preview inside Google Photos.

Step 3: The attacker's app is offered in the share sheet

In the bottom sheet of SHARE TO APPS the victim selects more, and the attacker's app (iPhotos) appears in the list. The researcher notes that an android:label="aaaaaaa" kind of trick in the intent filter can be used to prioritise the app in the share sheet.

Step 4: The database is delivered to the attacker

After the victim selects the app, the database is sent to the attacker's app. The researcher states that this includes remote media, envelopes, backup, local media and other information.

There is an alternative path that does not need the attacker's app to receive the file. If the victim chooses email instead, image.jpg is attached to the email. Google Photos renames any file to image.jpg regardless of its real extension, so the victim has no reason to suspect the attachment, because of the file name.

Root cause

The exported activity accepts a caller-supplied file:// URI and processes it without checking that the caller has permission to read the referenced file. The file scheme support in the intent filter is what allows a path in Google Photos' private data directory to be passed in at all, and the export is what allows a third-party app to reach the activity. The activity then renders the file and hands it into the share flow as if it were media the user had opened, so the normal share mechanism becomes the exfiltration channel. The report does not describe any additional validation that was present and bypassed; the missing access validation on the URI is the flaw.

Impact

This could have allowed an attacker to steal sensitive information, including the Google Photos database and other sandbox files. The database contents named in the report are remote media, envelopes, backup, local media and other information. The same primitive also allows a denial of service: there is an option to share a file with Google contacts in Google Photos conversation, and if the victim selects a contact the app crashes with the exception lsy: java.lang.IllegalArgumentException: baseUrl is not a fife Url, after which the complete conversation module goes into permanent denial of service.

Fix

The report does not describe the fix that was applied.

Timeline

Date Event
Mar 20, 2021 Issue ticket created
Mar 23, 2021 Triaged: "Nice catch!"
Apr 2, 2021 Reward of $1337

Variants to test

  1. Other exported activities in the same app that declare file scheme support in their intent filters. A positive result is that a file:// URI pointing into the app's private data directory is rendered or shared by the activity when started from a different app.
  2. Exported activities that accept setDataAndType with a broad MIME type such as image/*. A positive result is that a non-image file, such as a database, is accepted and previewed under that type.
  3. Share flows reached from an exported preview activity. A positive result is that the file passed in by the caller is offered to share targets, including email, with a renamed attachment such as image.jpg.
  4. Intent filter labels used to sort an app to the top of a share sheet. A positive result is that the attacker's app appears ahead of legitimate targets when the victim opens the share sheet.
  5. Conversation or messaging modules that accept a shared file. A positive result is a crash with an exception naming a malformed base URL, followed by the module remaining unusable.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

What happened, in plain words

Every app on an Android phone lives in its own little walled garden. The phone's operating system gives each app a private folder for its data, and other apps are not supposed to be able to read what is inside. Google Photos keeps a database file in that private folder, and that database holds information about the user's photos and related data.

Android apps are built out of pieces called components. One common component is an activity, which is basically a single screen or a single piece of user interface. An app can mark an activity as exported, which is a formal way of saying "other apps on this phone are allowed to start this screen". That is normal and useful: it is how one app can open a screen in another app, for example when you tap a link and your browser hands it to a maps app.

The problem in this report is that a particular Google Photos activity, com.google.android.apps.photos.pager.HostPhotoPagerActivity, was exported and was also set up to accept a certain kind of address called a file:// URI. A URI is just an address, like a web address, but file:// means "a file on this device" rather than "a page on the internet". Because the activity was exported and accepted file addresses, any other app on the phone could start it and hand it the address of a file inside Google Photos' private folder. The activity would then open that file and treat it as a photo, without checking whether the app that asked for it had any right to read it.

The researcher built a small malicious app to demonstrate this. When the victim runs it, Google Photos opens a preview of the private database file as if it were an image, and the victim is nudged to use the share button. The share button then offers the attacker's app as a destination, and choosing it sends the database to the attacker. The same trick can also crash a part of Google Photos called the conversation module, which is a messaging-like feature, and leave it broken.

The report was triaged with a "Nice catch!" comment and a reward of $1337 was paid.

Background: the pieces involved

Before walking through the steps, here is what each moving part is, in everyday terms.

  • Android app: a program installed on a phone. Each app runs in its own sandbox, which is a security boundary that keeps its files and memory separate from other apps.
  • Sandbox / private data directory: the app's own folder on the device. For Google Photos the report refers to /data/data/com.google.android.apps.photos/, and the database sits in a databases subfolder. Think of it as a locked drawer that only that app has the key to.
  • Activity: one screen or one unit of user interface inside an app. Starting an activity is like opening a particular window in a particular program.
  • Exported activity: an activity the app has declared other apps may start. Compare it to a shop that puts a "public entrance" sign on one door while the rest of the building stays locked.
  • Intent: the message Android uses to ask a component to do something. It says what action you want (for example "send this") and which component should handle it. It is like an envelope with instructions inside.
  • Intent filter: a declaration in an app's manifest (its configuration file) saying which kinds of intents the component is willing to receive. It is the shop's list of "we accept these kinds of requests".
  • URI: a address that identifies a resource. file:///... points at a file on the device; content://... points at data managed by a content provider (a controlled way for apps to share data).
  • MIME type: a label describing what kind of data something is, such as image/* for any kind of image. It is like writing "photo" on the outside of an envelope so the recipient knows how to handle it.
  • Share sheet / bottom sheet: the panel that slides up from the bottom of the screen when you tap Share, listing the apps you can send something to.
  • Toast: a small pop-up message that appears briefly at the bottom of an Android screen.
  • APK: the installable file format of an Android app. Compiling an APK means turning source code into that installable file.
  • Denial of service (DoS): making a feature or service unusable, either temporarily or permanently, rather than stealing data.
  • Database: an organised file that stores structured records. Here it is gphotos0.db, which the report says contains remote media, envelopes, backup, local media and other information.

Finding it

The researcher noticed two properties of HostPhotoPagerActivity that, combined, are dangerous:

  1. It was exported, so any other app on the phone could launch it.
  2. Its intent filter supported the file scheme, so the address it receives could be a local filesystem path rather than a controlled content provider address.

Either property alone might be harmless. Together they mean a third-party app can pass a file:// address for a file it has no permission to read, and the exported activity will open that file on the caller's behalf. The activity performs no access validation: it does not check that the app asking is allowed to read the file.

The feature involved is the photo pager and its share flow. The activity renders a media preview and offers a bottom sheet of apps to share to. Normally the address comes from content the user is viewing inside Google Photos. The bug is that the activity trusts whatever address it is started with.

Exploitation

Step 1: Build and run an APK that starts the activity with a private file address

The researcher compiles and runs an APK using the following intent:

Java
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());

Uri uri = Uri.parse("file:///data/data/com.google.android.apps.photos/databases/gphotos0.db");

Intent intent = new Intent("android.intent.action.SEND");
intent.setClassName("com.google.android.apps.photos", "com.google.android.apps.photos.pager.HostPhotoPagerActivity");
intent.setDataAndType(uri, "image/*");
startActivity(intent);

Toast.makeText(this, "Click On Share and Select iPhotos", Toast.LENGTH_LONG).show();

Line by line, in plain words:

  • StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); and StrictMode.setVmPolicy(builder.build()); set Android's StrictMode policy to its default builder. StrictMode is a developer diagnostic tool; here it is simply set up with defaults.
  • Uri uri = Uri.parse("file:///data/data/com.google.android.apps.photos/databases/gphotos0.db"); creates the address of the target file. It points at gphotos0.db, the Google Photos database inside the app's private data directory at /data/data/com.google.android.apps.photos/databases/. This is the file the attacker wants to read but has no permission to read directly.
  • Intent intent = new Intent("android.intent.action.SEND"); creates an intent with the standard "send" action. This is the same action used when you share something from one app to another.
  • intent.setClassName("com.google.android.apps.photos", "com.google.android.apps.photos.pager.HostPhotoPagerActivity"); targets the exported activity explicitly, naming both the app package and the activity class. Because the target is named directly, no other handler is involved; the intent goes exactly where the attacker wants.
  • intent.setDataAndType(uri, "image/*"); attaches the file address and declares the MIME type as image/*. This is what makes the activity treat the database file as an image to preview. The database is not an image, but the label says it is, and the activity believes the label.
  • startActivity(intent); actually launches the activity with these instructions.
  • Toast.makeText(this, "Click On Share and Select iPhotos", Toast.LENGTH_LONG).show(); shows a toast telling the user to click Share and select the attacker's app, which is labelled iPhotos.

Why this step matters: the attacker's app cannot read the database itself, because of the sandbox. Instead it asks a more privileged app, Google Photos, to open the file, and Google Photos does so because the activity is exported and accepts file addresses.

Step 2: The preview appears

When the APK runs, Google Photos shows a media preview of the file, and the attacker's toast (Click On Share and Select iPhotos) is displayed. The victim sees what looks like an ordinary image preview inside Google Photos.

Step 3: The attacker's app is offered in the share sheet

In the bottom sheet of SHARE TO APPS the victim selects more, and the attacker's app (iPhotos) appears in the list. The researcher notes that an android:label="aaaaaaa" kind of trick in the intent filter can be used to prioritise the app in the share sheet.

Step 4: The database is delivered to the attacker

After the victim selects the app, the database is sent to the attacker's app. The researcher states that this includes remote media, envelopes, backup, local media and other information.

There is an alternative path that does not need the attacker's app to receive the file. If the victim chooses email instead, image.jpg is attached to the email. Google Photos renames any file to image.jpg regardless of its real extension, so the victim has no reason to suspect the attachment, because of the file name. A database file arriving as image.jpg looks like an ordinary photo.

Root cause

The exported activity accepts a caller-supplied file:// address and processes it without checking that the caller has permission to read the referenced file. The file scheme support in the intent filter is what allows a path in Google Photos' private data directory to be passed in at all, and the export is what allows a third-party app to reach the activity. The activity then renders the file and hands it into the share flow as if it were media the user had opened, so the normal share mechanism becomes the channel for stealing the file. The report does not describe any additional validation that was present and bypassed; the missing access validation on the address is the flaw.

Impact

This could have allowed an attacker to steal sensitive information, including the Google Photos database and other sandbox files. The database contents named in the report are remote media, envelopes, backup, local media and other information.

The same primitive also allows a denial of service. There is an option to share a file with Google contacts in Google Photos conversation, and if the victim selects a contact the app crashes with the exception lsy: java.lang.IllegalArgumentException: baseUrl is not a fife Url, after which the complete conversation module goes into permanent denial of service.

Fix

The report does not describe the fix that was applied.

Timeline

Date Event
Mar 20, 2021 Issue ticket created
Mar 23, 2021 Triaged: "Nice catch!"
Apr 2, 2021 Reward of $1337

Variants to test

These are follow-up checks in the same spirit, for anyone testing similar apps:

  1. Other exported activities in the same app that declare file scheme support in their intent filters. A positive result is that a file:// address pointing into the app's private data directory is rendered or shared by the activity when started from a different app.
  2. Exported activities that accept setDataAndType with a broad MIME type such as image/*. A positive result is that a non-image file, such as a database, is accepted and previewed under that type.
  3. Share flows reached from an exported preview activity. A positive result is that the file passed in by the caller is offered to share targets, including email, with a renamed attachment such as image.jpg.
  4. Intent filter labels used to sort an app to the top of a share sheet. A positive result is that the attacker's app appears ahead of legitimate targets when the victim opens the share sheet.
  5. Conversation or messaging modules that accept a shared file. A positive result is a crash with an exception naming a malformed base URL, followed by the module remaining unusable.

Glossary

  • Activity: a single screen or unit of user interface inside an Android app.
  • Bottom sheet / share sheet: the panel that slides up from the bottom of the screen listing apps you can share something to.
  • Database: an organised file storing structured records; here gphotos0.db inside Google Photos.
  • Denial of service (DoS): making a feature or service unusable, temporarily or permanently, rather than stealing data.
  • Exported activity: an activity the app has declared other apps are allowed to start.
  • Intent: the message Android uses to ask a component to perform an action, including which component should handle it.
  • Intent filter: a manifest declaration listing which kinds of intents a component accepts.
  • MIME type: a label describing the kind of data, such as image/* for any image.
  • Private data directory / sandbox: the app's own protected folder on the device, which other apps cannot read directly.
  • StrictMode: an Android developer diagnostic tool; here set to its default policy.
  • Toast: a small pop-up message shown briefly at the bottom of an Android screen.
  • URI: an address identifying a resource; file:// points at a file on the device, content:// at data managed by a content provider.

More by Rahul Kankrale

View all

12 more disclosed reports, best first.

More from Google

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.