Kamil Vavra | @vavkamil

Offensive Web Application Security | Ethical Hacking | Security Research

📖Blog 📢Talks 💰Bug bounty 🕵️Whoami 📩Contact | 💻GitHub 🏆LinkedIn

Breaking an Android Trust Boundary: Reading Reddit's Private Cache

Breaking an Android Trust Boundary: Reading Reddit's Private Cache

Ethical hacking - Bug bounty

| 12 minutes to read | by vavkamil
Tags: hackerone - android - bugbounty - reddit - privacy

Recently, I had a dumb idea of doing a security assessment of apps installed on my Android phone. Oh boy, I wish I had never done that :)

You can take the red pill and keep reading, or take the blue and keep living a happy life without knowing how bad the whole ecosystem is.


Since working in AppSec, I try to minimize installed applications and their permissions, and update everything daily. I also use a Pixel phone with the latest stock Android, so in theory, everything should be great.

Anyways, I created a very simple LLM harness with tools like Apktool/JADX/ADB/AAPT2/D8/zipalign/apksigner/keytool …

Some great bug bounty write-ups, mostly around exported Activities for reference. Bug bounty scope, out-of-scope stuff and bounty table for some vuln classes. It’s nice to motivate agents with some rewards after all.

I then enabled USB debugging, connected my phone and told the AI agents to pull the APKs and verify if the apps I use align with my OPSEC. The goal was to create a zero-permission Android application that could query other installed apps and make use of them. Then I let the agents do their thing for like a week.


What the fuck! The result was both scary and somber. My favorite apps are broken. I ended up with a zero-permission apk that, when opened on my phone, could:

All that pretty much just by tapping a button, entering via exported components, supplying intents or URIs, and chaining them to access internal components and/or private resources. In several cases, the targeted app became a confused deputy, using its own permissions.

So classic confused-deputy/URI-grant laundering, using internal components or protected resources on our behalf. Most of the bugs followed the same patterns and were very simple. For example, a simple WebView origin-confusion chain to XSS, leading to ATOs.

Just enter through an exported activity, feed it something it trusted too much and take the goodies.

In theory, a malicious app like that would never be allowed on the Play Store, or hopefully Play Protect would flag and disable it. At least I hope so. I reported most of the bugs. Some were fixed, some weren’t, and some were ignored or out of scope. Most of them were duplicates anyways. Bug bounty rewards - $0.

But I wanted to share at least one report. The Reddit one was interesting, simple to understand and closed as won’t fix. So let’s take a look at that one.

Exported ShareActivity exposes Reddit’s private Apollo cache database

When you want to share an image post on Reddit, the Android app offers a convenient Copy image button.

From the user’s perspective, this only copies the image to the clipboard. Internally, however, Android doesn’t necessarily place the entire image on the clipboard. It can copy a content:// URI instead: a reference to a file managed by another app, together with permission to read it.

Reddit handles this through an activity named ShareActivity. Its relevant logic, simplified from the decompiled code, looks roughly like this:

if (target == CopyImage) {
    ClipData clip = getIntent().getClipData();

    if (clip != null) {
        clipboard.setPrimaryClip(clip);
    }

    finish();
}
Reddit's share menu showing the Copy image option

The important detail is that the clipboard data comes from the incoming intent and is copied without validation.

For normal use, Reddit supplies a URI pointing to the image the user wants to copy. The problem is that ShareActivity is exported, meaning other installed apps can launch it too. It does not verify who launched it or whether the supplied URI is safe to publish.

Crossing the trust boundary

Android applications are normally isolated from each other. One app cannot simply open another app’s private files. Applications can, however, expose individual components as entry points for other apps.

Reddit explicitly exposes its sharing activity:

<activity
    android:name="com.reddit.sharing.ShareActivity"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.SEND" />
    </intent-filter>
</activity>

Being exported isn’t a vulnerability by itself. A sharing activity needs to receive requests from outside the app. The security boundary depends on what it does with those requests.

Reddit also has a separate file provider used for files belonging to the app:

<provider
    android:name="org.matrix.android.sdk.api.session.file.MatrixSDKFileProvider"
    android:authorities="com.reddit.frontpage.mx-sdk.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true" />

Unlike ShareActivity, this provider is not exported, so an external app cannot open it directly. The provider can still grant temporary access to individual URIs. Its path configuration maps the URI segment downloads to the root of Reddit’s private cache directory:

<paths>
    <cache-path name="downloads" path="/" />
</paths>

Here, downloads is only an alias used inside the provider URI. For example, a URI such as:

content://com.reddit.frontpage.mx-sdk.fileprovider/downloads/foo

roughly refers to:

/data/user/0/com.reddit.frontpage/cache/foo

Reddit uses this provider in the Matrix-based file-handling layer behind its messaging features. It allows individual cached files to be shared through temporary content:// URIs without making the whole cache public.

These two components are individually reasonable: one accepts sharing requests, while the other keeps Reddit’s cached files private but supports narrowly scoped grants. The problem appears when we chain them together.

Asking Reddit to copy a different URI

The earlier cache-path mapping gives us a predictable URI format for files under Reddit’s cache directory. Once we know a relative path, we can create its URI and pass it to Reddit’s exported ShareActivity:

Uri privateUri = Uri.parse(
    "content://com.reddit.frontpage.mx-sdk.fileprovider/" +
    "downloads/" + relativePath
);

void grantThroughReddit(Uri privateUri) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setClassName(
        "com.reddit.frontpage",
        "com.reddit.sharing.ShareActivity"
    );

    intent.setType("image/png");
	intent.putExtra(
	    "extra_share_target",
	    CopyImage // Select Reddit's Copy image branch
	);
	intent.setClipData(
	    ClipData.newRawUri("cache", privateUri) // Supply the URI Reddit will copy
	);
    startActivity(intent);
}

Creating a URI does not require access to the file it names.

setClassName() directs the request to Reddit, extra_share_target selects the Copy image branch, and setClipData() attaches the provider URI. The URI now identifies a private file, although our app still lacks permission to open it.

ShareActivity accepts the URI and places the supplied ClipData on the clipboard. Reddit is now publishing a URI belonging to its own provider. Android attaches a temporary read grant, allowing the clipboard recipient to open something it could not access before.

Reading the clipboard requires no declared Android permission. Clipboard access is generally limited to the app currently in focus, so our app reads the URI after ShareActivity finishes and returns control to it.

This is a confused-deputy problem. Our app has no authority to read Reddit’s files, but it persuades Reddit to use its own authority and republish access to one of them.

Finding the Apollo database

At this point, we can ask Reddit to grant us read access to anything under its private cache directory. The next challenge is knowing what to ask for. Reading a private file still requires knowing its path.

Reddit uses Apollo, a GraphQL client, to communicate with parts of its API. Apollo stores some responses in a local SQLite cache so the app can reuse recently loaded data instead of downloading it again.

There is one obstacle: we cannot ask the provider for the cache root itself. Android’s FileProvider only accepts paths below the configured root, so a URI ending in downloads/. is rejected.

Luckily for us, AndroidX’s database-locking code creates a predictable child directory beneath Reddit’s cache root:

/data/user/0/com.reddit.frontpage/cache/
└── data/user/0/com.reddit.frontpage/cache/
    ├── apollo_cache_alice.lck
    └── apollo_cache_bob.lck

Each Apollo cache leaves an empty lock file with the account name in its filename. The corresponding provider URI is:

content://com.reddit.frontpage.mx-sdk.fileprovider/downloads/data/user/0/com.reddit.frontpage/cache/.

This directory is below the configured provider root, so FileProvider accepts it.

At this point, our app can use the same clipboard trick to request read access to the directory. Once the URI returns with a read grant, our app opens it through Android’s ContentResolver. Android returns a file descriptor, which our app uses to list the lock files. Their names reveal the usernames associated with Reddit’s cached accounts.

That reveals the cache identity and therefore the database filename. The database sits directly in the cache root, which we still cannot list. With the exact filename known, our app can request it directly and pass its URI through ShareActivity a second time:

Uri database = Uri.parse(
    "content://com.reddit.frontpage.mx-sdk.fileprovider/" +
    "downloads/apollo_cache_" + username
);

grantThroughReddit(database);

After that, our app has read access to Reddit’s private Apollo cache databases. It copies each SQLite file into its own private storage and opens it in read-only mode.

My recovered database contains 851 cached GraphQL records. They include the account username, private email address, city and country, subscribed and moderated communities, followed accounts, profiles, and other community metadata. The exact contents depend on what Reddit has cached for your account; this copy contains no access token, refresh token, or session cookie.

One detail is especially interesting: after I deleted a throwaway Reddit account, the app removed it from the account list but left its Apollo cache database on the device. The stale cache still preserved the old username and other retained account data. An app using the same technique could therefore recover evidence of previous Reddit identities that the user believes are gone.

So the complete chain works without declaring a single Android permission:

  1. Construct a URI for the predictable Apollo lock directory.
  2. Send it to Reddit’s exported ShareActivity using the Copy image branch.
  3. Read the republished URI from the clipboard with its new read grant.
  4. Enumerate the lock filenames to recover cached account names.
  5. Construct the corresponding database URIs and repeat the grant for each reachable database.
  6. Copy each SQLite file into our app’s private storage and open it in read-only mode.
  7. Learn more about the Reddit accounts on the device than a zero-permission app ever should.
Reddit private cache PoC ready to run without Android permissions
Successful PoC showing recovered Reddit account data and 851 cached records

hackerone-agent closed the report and changed the status to Duplicate of (Informative)

Thank you for your submission and the thorough research behind it.

After review, this report describes the same underlying vulnerability already captured in a prior report (#REDACTED). Both reports target the same exported Android component, exploit the same unvalidated file access path, and reach the same sensitive data — the lock-file enumeration technique you've described is a clever addition, but it builds on the same root cause and affected code as the original report.

Because this issue has already been reported to this program, it is being closed as a duplicate of #REDACTED.

How this could be prevented

Reddit could break this chain in several places:

Any one of these changes would stop this particular attack.

Timeline