[CVE-2021-25414] [Samsung] [Contacts] SetProfilePhotoActivity导出存在任意私有文件读写漏洞

Date
Version
Description
Author

2022.11.25

1.0

完整的漏洞分析与利用

wnagzihxa1n

0x00 漏洞概述

0x01 触发条件

上线日期
应用名
包名
版本号
MD5
下载链接

Contacts

com.samsung.android.app.contacts

12.1.10.30

60579c925977ca29b889d32085a0c350

0x02 PoC

0x03 前置知识

0x04 Root Cause Analysis

组件com.samsung.android.contacts.editor.SetProfilePhotoActivity导出

<activity 
        android:configChanges="keyboardHidden|orientation|screenSize" 
        android:hardwareAccelerated="false" 
        android:icon="@mipmap/ic_launcher_contacts" 
        android:label="@string/share_my_profile" 
        android:name="com.samsung.android.contacts.editor.SetProfilePhotoActivity" 
        android:taskAffinity="" 
        android:theme="@style/BackgroundOnlyTheme">
    <intent-filter>
        <action android:name="android.intent.action.SEND"/>
        <data android:mimeType="image/*"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
    <intent-filter>
        <action android:name="com.samsung.contacts.action.SET_AS_PROFILE_PICTURE"/>
        <data android:mimeType="image/*"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</activity>

前面的分析和漏洞《[CVE-2021-25413] [Samsung] [Contacts] SetProfilePhotoActivity导出存在任意私有组件启动漏洞可获取ContentProvider数据》一样

  • https://wnagzihxa1n.gitbook.io/happy-android-security/application_security/cve202125413samsungcontactscomsamsungandroidappcontacts1211030setprofilephotoactivity-dao-chu-cun-za

在调用异步任务的时候,方法doInBackground()事实上被我们构造数据退出去了

方法a()调用savePhotoFromUriToUri()

跟另外一个漏洞不一样的是,本次走的是[6]调用方法S()

方法S()初始化了PhotoDataUtils实例后调用方法T()

[1]构造文件写出的位置,路径外部可控,[2]构造文件读取的位置,路径外部可控,[3]进行读,[4]进行写,读和写两个文件路径都可控,所以此处存在任意私有文件读写漏洞

完整的逻辑调用图

逻辑调用图

0x05 调试与利用

Oversecured实验室的PoC

构造一个ContentProvider用于文件操作

Manifest配置为导出,这样才可以被三方应用调用

0x06 漏洞研究

0x07 References

《Two weeks of securing Samsung devices: Part 2》

  • https://blog.oversecured.com/Two-weeks-of-securing-Samsung-devices-Part-2/

附录:调试过程记录

Last updated