android 注入system_server,Android system_server Code Loading Bypass

Android: Code loading bypasses in system_server

As of Android Nougat, a new set of SELinux rules have been added which are designed to prevent system_server from loading arbitrary code into its address-space. This has been enforced by adding the following rules to system_server's SELinux policy:

neverallow system_server self:process execmem;

neverallow system_server ashmem_device:chr_file execute;

neverallow system_server system_server_tmpfs:file execute;

However, as system_server is extremely privileged, there are a few vectors through which it may still load arbitrary code, thus bypassing the mitigation mentioned above.

1. The system user has read-write access to /data/app/*/oat/*. However, this directory and all files created within it have the SELinux context:

u:object_r:dalvikcache_data_file:s0

(see http://androidxref.com/7.0.0_r1/xref/system/sepolicy/file_contexts#252)

Since system_server is required to execute dalvik-cache files, its SELinux policy explicitly allows this by adding the rule:

allow system_server dalvikcache_data_file:file execute;

This means that system_server may create a file under the aforementioned path and mmap it with PROT_EXEC in order to load arbitrary code.

2. Much in the same way, system_server has read-write access to /data/app, including /data/app/vmdl*.tmp/*/oat/*. However, this directory and all files created within it have the SELinux context:

u:object_r:dalvikcache_data_file:s0

(see http://androidxref.com/7.0.0_r1/xref/system/sepolicy/file_contexts#254)

This allows the attacker to follow the same steps as in (1.) in order to map in arbitrary code.

Note that removing RW access to the oat directories is not always sufficient to fix this issue. For example, an attacker can also choose to store his code within the his application (i.e., in a large byte[] within the source code). This in turn will be compiled into the ODEX file under the "oat" directory, and can then be used to map in arbitrary code once more into system_server.

This bug is subject to a 90 day disclosure deadline. If 90 days elapse without a broadly available patch, then the bug report will automatically become visible to the public.

Found by: laginimaineb

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值