Interacting with Samsung radio layer (RILD)

2023-10-07 21:30

本文主要是介绍Interacting with Samsung radio layer (RILD),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Interacting with Samsung radio layer (RILD)

Last February I tweeted a video showing how a local unprivileged applications can abuse an undisclosed vulnerability affecting Samsung Android phones to perform “stealth calls” (i.e., a voice call with no visible clue). This post discusses the technical details behind that bug.

Several Samsung Android smartphones expose a UNIX socket, named “Multiclient”, that can be used by selected local applications to interact with RILD, the Radio Interface Layer Daemon. Access to the “Multiclient” socket should be limited to privileged applications only, as activities which can be performed through this interface range from configuring low-level radio settings to placing & receiving SMS messages and phone calls.

Unfortunately, restrictions imposed by Samsung to limit access to the “Multiclient” socket can be bypassed, permitting any local application to interact with RILD, with no constraints.

Accessing the Multiclient socket

Applications are supposed to interact with “Multiclient” socket (and thus with RILD) by leveraging the APIs exposed by a user library, libsecril-client.so, which abstracts away the details connected with managing the UNIX socket. On the receiver-side, data sent through the socket is received by RILD using a second library, libsec-ril.so, which unmarshals the request and eventually delivers it to the underlying modem.

Library libsecril-client.so handles incoming socket connections through class OemClientReceiver. Security checks that prevent unprivileged clients from accessing the local socket are implemented right into OemClientReceiver::Accept(). In a nutshell, the access control algorithm is designed as follows:

  1. OemClientReceiver calls getsockopt(SOL_SOCKET, SO_PEERCRED) to retrieve the PID and GID of the client.

  2. Using the client PID, OemClientReceiver reads /proc/[pid]/cmdline to get the command-line associated to the client process. The string is tokenized on white spaces to get the process name (i.e., the first token).

  3. Finally, OemClientReceiver scans the allowedProcess global list, containing tuples (PID, GID, name) that identify authorized processed. If a matching entry is found, then the client is allowed to connect.

The global list of authorized processes (allowedProcess)

So, in order for an attacker app to impersonate an authorized process and connect to the “Multiclient” process, it must be able to spoof the PID, GID, and the name of a licit client.

The check on the PID/GID can be bypassed easily: a closer look at the allowedProcess list reveals a single process, com.expway.embmsserver, with both the PID and GID set to 0xffffffff (i.e., -1). As you probably imagine, this special value instructs OemClientReceiver to accept any PID/GID for this process.

However, the attacker still has to circumvent the last check, which involves the process name. However, this is also quite a lax check, as processes are free to alter the contents of /proc/[pid]/cmdline at their will. This is demonstrated by the following C program (cmdline.c).

#include <stdio.h>
#include <string.h>

static void get_cmdline(char *data, int size) {FILE *fp;fp = fopen("/proc/self/cmdline", "r");memset(data, 0, size);fread(data, size, 1, fp);
}int main(int argc, char **argv) {if (argc == 1) {char* const args[] = {"/a/b/c/whatsoever", "x", NULL};execv(argv[0], args);} else {char cmdline[512];get_cmdline(cmdline, sizeof(cmdline));printf("Hi, my command line is: %s\n", cmdline);}return 0;
}

The cmdline.c program above rewrites its own command line to /a/b/c/whatsoever, as demonstrated by the following execution:

$ ./cmdline
Hi, my command line is: /a/b/c/whatsoever

It should be clear that the contents of argv[0] cannot be trusted, and any security check based on the contents of /proc/[pid]/cmdline can then be bypassed. In our specific context, this approach can be abused by any local application to access the “Multiclient” UNIX socket and interact with RILD.

Level 1: Interacting with RILD

By leveraging the technique discussed in the previous section, we are now able to connect to the “Multiclient” local socket. Library libsecril-client.so provides some handy methods to establish the connection and perform some basic actions, but most of the actions we can perform are undocumented. The only notable exception of public documentation is the (unofficial) Samsung IPC library and the Replicant project.

Practically speaking, the core function for interacting with RILD is InvokeOemRequestHookRaw, which permits to invoke an OEM method through an RPC-like mechanism. The input structure to InvokeOemRequestHookRaw has the following format:

struct OEMRequestRawHeader {unsigned char main_cmd;unsigned char sub_cmd;unsigned short length;
};

The OEMRequestRawHeader header is then followed by zero or more bytes for method-specific arguments. Fields main_cmd and sub_cmd determine the actual RILD method being called; possible values are undocumented, and must be inferred by analyzing library libsec-ril.so.

Overall, InvokeOemRequestHookRaw permits to invoke tens of OEM methods. Possible actions range from sending raw APDUs to the UICC (SIM) card, to start capturing network traffic into a local PCAP file.

Level 2: Interacting with the modem

Under the hoods, each of the RPC-like methods exposed through the InvokeOemRequestHookRawinterface is translated into an additional, internal IPC call between RILD and the radio modem. One of the methods exposed, DoOemRawIpc, provides direct access to this IPC channel, permitting user-space clients to interact with the modem at a very low level.

Method DoOemRawIpc is basically another RPC layer. The input argument must adhere the following format:

struct OEMIPCHeader {uint16_t length;uint8_t msg_seq;uint8_t ack_seq;uint8_t main_cmd;uint8_t sub_cmd;uint8_t cmd_type;uint8_t data_len;
};

Here main_cmd and sub_cmd are completely different command IDs than those for OEMRequestRawHeader, while cmd_type specifies which kind of operation we’re going to perform (e.g., get/set/execute). Similarly to OEMRequestRawHeaderOEMIPCHeader can also be followed by zero or more data bytes, encoding method-specific arguments.

Profit!

To sum up, unprivileged local applications can interact with the radio modem by leveraging the “Multiclient” socket. Existing mechanisms that protect this UNIX socket from unauthorized access attempts can be circumvented.

As a very simple example, on our Samsung Galaxy S6 we invoked DoOemRawIpc with main_cmd=1and sub_cmd=2. These parameters correspond to the “poweroff modem” method that, as the name implies, suddenly shuts down the radio modem (the modem is then restarted few seconds later). A proof-of-concept is available here.

For a more realistic example, we verified a local attacker can invoke DoOemRawIpc with main_cmd=2and sub_cmd=1 to issue a “silent call”, i.e., a phone call to an attacker-chosen destination number, but with no visual indication on the victim’s phone. This is obviously a very dangerous behavior, that could be easily exploited by a malicious application to perform really “stealth” phone calls, without requiring any specific Android permission.

We notified Samsung about this vulnerability on February 22, 2016. Initially, the deadline was set to May 22 (90 days), and then postponed to May 30. Samsung finally addressed the vulnerability with this security update (see SVE-2016-5733).

Affected devices

We confirm the issues described in this advisory affect the following device models. Other models and firmware versions are probably affected as well, but they were not tested.

  • SM-G920F, build G920FXXU2COH2 (Galaxy S6, patched with G920FXXU3DPDP)
  • SM-N9005, build N9005XXUGBOK6 (Galaxy Note 3)
  • GT-I9505, build I9505XXUHOJ2 (Galaxy S4)

这篇关于Interacting with Samsung radio layer (RILD)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/160578

相关文章

[Linux Kernel Block Layer第一篇] block layer架构设计

目录 1. single queue架构 2. multi-queue架构(blk-mq)  3. 问题 随着SSD快速存储设备的发展,内核社区越发发现,存储的性能瓶颈从硬件存储设备转移到了内核block layer,主要因为当时的内核block layer是single hw queue的架构,导致cpu锁竞争问题严重,本文先提纲挈领的介绍内核block layer的架构演进,然

Ajax中根据json数据不同,对页面上的单选框Radio进行回显

Ajax中根据json数据不同,对页面上的单选框Radio进行回显 js代码: $(document).ready(function(){$.ajax({type: "POST",url: path+"/pop/nowTodayMeet2",dataType: "json",success: function(data){$("#discussTopicsEdit").val(da

android xml之Drawable 篇 --------shape和selector和layer-list的

转自 : http://blog.csdn.net/brokge/article/details/9713041 <shape>和<selector>在Android UI设计中经常用到。比如我们要自定义一个圆角Button,点击Button有些效果的变化,就要用到<shape>和<selector>。 可以这样说,<shape>和<selector>在美化控件中的作用是至关重要。 在

前端百科---点击文字选中Radio

在进行Web过程中,Radio单选是必不可少的.但是如果用户只能通过点击Radio的圆圈才能实现选项的选择,这样就会导致交互不够好...       怎么解决呢?使用JavaScript当然可以,但是直接使用HTML5自带属性不是更好吗?       废话少说,直接上demo:       第一种:label标签使用for属性指向input:radio;       第二

Layer Normalization论文解读

基本信息 作者JL Badoi发表时间2016期刊NIPS网址https://arxiv.org/abs/1607.06450v1 研究背景 1. What’s known 既往研究已证实 batch Normalization对属于同一个Batch中的数据长度要求是相同的,不适合处理序列型的数据。因此它在NLP领域的RNN上效果并不显著,但在CV领域的CNN上效果显著。 2. What’s

ABAP Dialog Radio Button

额.妈了个巴子,整了一天,才发现,原来Dialog 的Radio Button 是要右键去设置组的 我就说为什么不行咧 误区:我以为是属性那里的组去设置的

区块链 链上扩容 链下扩容 Layer-2扩容

链上扩容,也常被称为layer-1扩容。 直接修改区块链的基础规则,包括区块大小、共识机制等。 链下扩容,也常被称为Layer-2扩容方案。 不直接改动区块链本身的规则(区块大小、共识机制等),而是在其之上再架设一层来做具体的活,只将必要信息、或需要共识参与(如数据出错、发生纠纷时)时才与区块链进行信息交互和传播。因为扩容本质上没有发生在区块链上,因此这类方案被直观地称为链下扩容

element ui 中checkbox或radio不可勾选/不可取消勾选/点击没有反应

不知道有没有小伙伴遇到过,动态生成的checkbox或radio会出现无法勾选或者不可取消勾选,或者点击没有反应的时候。   我v-model绑定了数据,而且设置是true,但是checkbox生成后,就无法点击了,也不触发这个字段的true和false的变化。   解决办法就是,设置的时候,需要使用vue的$set方法设置

深度学习-TensorFlow2 :构建DNN神经网络模型【构建方式:自定义函数、keras.Sequential、CompileFit、自定义Layer、自定义Model】

1、手工创建参数、函数–>利用tf.GradientTape()进行梯度优化(手写数字识别) import osos.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'import tensorflow as tffrom tensorflow.keras import datasets# 一、获取手写数字辨识训练数据集(X_train, Y_train), (X_

layer设置弹出层的位置

layer的弹出层我不想再正中显示,我们想在距离顶部10px,然后水平居中,设置offset,如下 更offset更多设置如下 看看效果,如下 滚动的时候我想固定弹出层,不随滚动条滚动而滚动,如下  设置fix是true就行了