what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Android system_server Code Loading Bypass

Android system_server Code Loading Bypass
Posted Dec 2, 2016
Authored by Google Security Research, laginimaineb

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. 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.

tags | advisory, arbitrary
SHA-256 | 24c10a0d6f4d42cf96eb11a1f2c3700f98a0275e04324e2cd9fff3a0af399fed

Android system_server Code Loading Bypass

Change Mirror Download
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 <a href="http://androidxref.com/7.0.0_r1/xref/system/sepolicy/file_contexts#252" title="" class="" rel="nofollow">http://androidxref.com/7.0.0_r1/xref/system/sepolicy/file_contexts#252</a>)

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 <a href="http://androidxref.com/7.0.0_r1/xref/system/sepolicy/file_contexts#254" title="" class="" rel="nofollow">http://androidxref.com/7.0.0_r1/xref/system/sepolicy/file_contexts#254</a>)

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

Login or Register to add favorites

File Archive:

July 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jul 1st
    27 Files
  • 2
    Jul 2nd
    10 Files
  • 3
    Jul 3rd
    35 Files
  • 4
    Jul 4th
    27 Files
  • 5
    Jul 5th
    18 Files
  • 6
    Jul 6th
    0 Files
  • 7
    Jul 7th
    0 Files
  • 8
    Jul 8th
    28 Files
  • 9
    Jul 9th
    44 Files
  • 10
    Jul 10th
    24 Files
  • 11
    Jul 11th
    25 Files
  • 12
    Jul 12th
    11 Files
  • 13
    Jul 13th
    0 Files
  • 14
    Jul 14th
    0 Files
  • 15
    Jul 15th
    28 Files
  • 16
    Jul 16th
    0 Files
  • 17
    Jul 17th
    0 Files
  • 18
    Jul 18th
    0 Files
  • 19
    Jul 19th
    0 Files
  • 20
    Jul 20th
    0 Files
  • 21
    Jul 21st
    0 Files
  • 22
    Jul 22nd
    0 Files
  • 23
    Jul 23rd
    0 Files
  • 24
    Jul 24th
    0 Files
  • 25
    Jul 25th
    0 Files
  • 26
    Jul 26th
    0 Files
  • 27
    Jul 27th
    0 Files
  • 28
    Jul 28th
    0 Files
  • 29
    Jul 29th
    0 Files
  • 30
    Jul 30th
    0 Files
  • 31
    Jul 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close