Alex Klyubin | a390397 | 2017-01-05 16:06:54 -0800 | [diff] [blame] | 1 | ### |
| 2 | ### Services with isolatedProcess=true in their manifest. |
| 3 | ### |
| 4 | ### This file defines the rules for isolated apps. An "isolated |
| 5 | ### app" is an APP with UID between AID_ISOLATED_START (99000) |
| 6 | ### and AID_ISOLATED_END (99999). |
| 7 | ### |
| 8 | |
Alex Klyubin | f5446eb | 2017-03-23 14:27:32 -0700 | [diff] [blame] | 9 | typeattribute isolated_app coredomain; |
| 10 | |
dcashman | 3e8dbf0 | 2016-12-08 11:23:34 -0800 | [diff] [blame] | 11 | app_domain(isolated_app) |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 12 | |
Alex Klyubin | a390397 | 2017-01-05 16:06:54 -0800 | [diff] [blame] | 13 | # Access already open app data files received over Binder or local socket IPC. |
Nick Kralevich | 0025220 | 2018-10-31 12:47:27 -0700 | [diff] [blame] | 14 | allow isolated_app { app_data_file privapp_data_file }:file { append read write getattr lock map }; |
Alex Klyubin | a390397 | 2017-01-05 16:06:54 -0800 | [diff] [blame] | 15 | |
| 16 | allow isolated_app activity_service:service_manager find; |
| 17 | allow isolated_app display_service:service_manager find; |
| 18 | allow isolated_app webviewupdate_service:service_manager find; |
| 19 | |
| 20 | # Google Breakpad (crash reporter for Chrome) relies on ptrace |
| 21 | # functionality. Without the ability to ptrace, the crash reporter |
| 22 | # tool is broken. |
| 23 | # b/20150694 |
| 24 | # https://code.google.com/p/chromium/issues/detail?id=475270 |
| 25 | allow isolated_app self:process ptrace; |
| 26 | |
| 27 | # b/32896414: Allow accessing sdcard file descriptors passed to isolated_apps |
| 28 | # by other processes. Open should never be allowed, and is blocked by |
| 29 | # neverallow rules below. |
Alex Klyubin | a390397 | 2017-01-05 16:06:54 -0800 | [diff] [blame] | 30 | # media_rw_data_file is included for sdcardfs, and can be removed if sdcardfs |
| 31 | # is modified to change the secontext when accessing the lower filesystem. |
Nick Kralevich | 0025220 | 2018-10-31 12:47:27 -0700 | [diff] [blame] | 32 | allow isolated_app { sdcard_type media_rw_data_file }:file { read write append getattr lock map }; |
Alex Klyubin | a390397 | 2017-01-05 16:06:54 -0800 | [diff] [blame] | 33 | |
| 34 | # For webviews, isolated_app processes can be forked from the webview_zygote |
| 35 | # in addition to the zygote. Allow access to resources inherited from the |
| 36 | # webview_zygote process. These rules are specialized copies of the ones in app.te. |
| 37 | # Inherit FDs from the webview_zygote. |
| 38 | allow isolated_app webview_zygote:fd use; |
| 39 | # Notify webview_zygote of child death. |
| 40 | allow isolated_app webview_zygote:process sigchld; |
| 41 | # Inherit logd write socket. |
| 42 | allow isolated_app webview_zygote:unix_dgram_socket write; |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 43 | # Read system properties managed by webview_zygote. |
| 44 | allow isolated_app webview_zygote_tmpfs:file read; |
Alex Klyubin | a390397 | 2017-01-05 16:06:54 -0800 | [diff] [blame] | 45 | |
Dan Cashman | 91d398d | 2017-09-26 12:58:29 -0700 | [diff] [blame] | 46 | # TODO (b/63631799) fix this access |
| 47 | # suppress denials to /data/local/tmp |
| 48 | dontaudit isolated_app shell_data_file:dir search; |
| 49 | |
Primiano Tucci | c80f9e0 | 2017-12-21 03:51:15 +0100 | [diff] [blame] | 50 | # Write app-specific trace data to the Perfetto traced damon. This requires |
| 51 | # connecting to its producer socket and obtaining a (per-process) tmpfs fd. |
| 52 | allow isolated_app traced:fd use; |
| 53 | allow isolated_app traced_tmpfs:file { read write getattr map }; |
| 54 | unix_socket_connect(isolated_app, traced_producer, traced) |
| 55 | |
Alex Klyubin | a390397 | 2017-01-05 16:06:54 -0800 | [diff] [blame] | 56 | ##### |
| 57 | ##### Neverallow |
| 58 | ##### |
| 59 | |
Alex Klyubin | a390397 | 2017-01-05 16:06:54 -0800 | [diff] [blame] | 60 | # Isolated apps should not directly open app data files themselves. |
Nick Kralevich | 23c9d91 | 2018-08-02 15:54:23 -0700 | [diff] [blame] | 61 | neverallow isolated_app { app_data_file privapp_data_file }:file open; |
Alex Klyubin | a390397 | 2017-01-05 16:06:54 -0800 | [diff] [blame] | 62 | |
| 63 | # Only allow appending to /data/anr/traces.txt (b/27853304, b/18340553) |
| 64 | # TODO: are there situations where isolated_apps write to this file? |
| 65 | # TODO: should we tighten these restrictions further? |
| 66 | neverallow isolated_app anr_data_file:file ~{ open append }; |
| 67 | neverallow isolated_app anr_data_file:dir ~search; |
| 68 | |
Dan Cashman | 91d398d | 2017-09-26 12:58:29 -0700 | [diff] [blame] | 69 | # Isolated apps must not be permitted to use HwBinder |
| 70 | neverallow isolated_app hwbinder_device:chr_file *; |
| 71 | neverallow isolated_app *:hwservice_manager *; |
| 72 | |
| 73 | # Isolated apps must not be permitted to use VndBinder |
| 74 | neverallow isolated_app vndbinder_device:chr_file *; |
| 75 | |
| 76 | # Isolated apps must not be permitted to perform actions on Binder and VndBinder service_manager |
| 77 | # except the find actions for services whitelisted below. |
| 78 | neverallow isolated_app *:service_manager ~find; |
| 79 | |
Alex Klyubin | a390397 | 2017-01-05 16:06:54 -0800 | [diff] [blame] | 80 | # b/17487348 |
| 81 | # Isolated apps can only access three services, |
| 82 | # activity_service, display_service and webviewupdate_service. |
| 83 | neverallow isolated_app { |
| 84 | service_manager_type |
| 85 | -activity_service |
| 86 | -display_service |
| 87 | -webviewupdate_service |
| 88 | }:service_manager find; |
| 89 | |
| 90 | # Isolated apps shouldn't be able to access the driver directly. |
| 91 | neverallow isolated_app gpu_device:chr_file { rw_file_perms execute }; |
| 92 | |
| 93 | # Do not allow isolated_app access to /cache |
| 94 | neverallow isolated_app cache_file:dir ~{ r_dir_perms }; |
| 95 | neverallow isolated_app cache_file:file ~{ read getattr }; |
| 96 | |
Alex Klyubin | a390397 | 2017-01-05 16:06:54 -0800 | [diff] [blame] | 97 | # Do not allow isolated_app to access external storage, except for files passed |
| 98 | # via file descriptors (b/32896414). |
| 99 | neverallow isolated_app { storage_file mnt_user_file sdcard_type }:dir ~getattr; |
| 100 | neverallow isolated_app { storage_file mnt_user_file }:file_class_set *; |
| 101 | neverallow isolated_app sdcard_type:{ devfile_class_set lnk_file sock_file fifo_file } *; |
Nick Kralevich | 0025220 | 2018-10-31 12:47:27 -0700 | [diff] [blame] | 102 | neverallow isolated_app sdcard_type:file ~{ read write append getattr lock map }; |
Alex Klyubin | a390397 | 2017-01-05 16:06:54 -0800 | [diff] [blame] | 103 | |
| 104 | # Do not allow USB access |
| 105 | neverallow isolated_app { usb_device usbaccessory_device }:chr_file *; |
| 106 | |
| 107 | # Restrict the webview_zygote control socket. |
Robert Sesek | 869562e | 2018-01-30 10:54:33 -0500 | [diff] [blame] | 108 | neverallow isolated_app webview_zygote:sock_file write; |
Nick Kralevich | 62d3b4f | 2017-10-09 15:10:30 -0700 | [diff] [blame] | 109 | |
| 110 | # Limit the /sys files which isolated_app can access. This is important |
| 111 | # for controlling isolated_app attack surface. |
| 112 | neverallow isolated_app { |
| 113 | sysfs_type |
| 114 | -sysfs_devices_system_cpu |
| 115 | -sysfs_usb # TODO: check with audio team if needed for isolated_app (b/28417852) |
| 116 | }:file no_rw_file_perms; |
Nick Kralevich | 8f08456 | 2018-10-02 21:43:20 -0700 | [diff] [blame] | 117 | |
| 118 | # No creation of sockets families other than AF_UNIX sockets. |
| 119 | # List taken from system/sepolicy/public/global_macros - socket_class_set |
| 120 | # excluding unix_stream_socket and unix_dgram_socket. |
| 121 | # Many of these are socket families which have never and will never |
| 122 | # be compiled into the Android kernel. |
| 123 | neverallow isolated_app self:{ |
| 124 | socket tcp_socket udp_socket rawip_socket netlink_socket packet_socket |
| 125 | key_socket appletalk_socket netlink_route_socket |
| 126 | netlink_tcpdiag_socket netlink_nflog_socket netlink_xfrm_socket |
| 127 | netlink_selinux_socket netlink_audit_socket netlink_dnrt_socket |
| 128 | netlink_kobject_uevent_socket tun_socket netlink_iscsi_socket |
| 129 | netlink_fib_lookup_socket netlink_connector_socket netlink_netfilter_socket |
| 130 | netlink_generic_socket netlink_scsitransport_socket netlink_rdma_socket |
| 131 | netlink_crypto_socket sctp_socket icmp_socket ax25_socket ipx_socket |
| 132 | netrom_socket atmpvc_socket x25_socket rose_socket decnet_socket atmsvc_socket |
| 133 | rds_socket irda_socket pppox_socket llc_socket can_socket tipc_socket |
| 134 | bluetooth_socket iucv_socket rxrpc_socket isdn_socket phonet_socket |
| 135 | ieee802154_socket caif_socket alg_socket nfc_socket vsock_socket kcm_socket |
Nick Kralevich | a194d37 | 2018-11-16 02:48:03 -0800 | [diff] [blame^] | 136 | qipcrtr_socket smc_socket xdp_socket |
Nick Kralevich | 8f08456 | 2018-10-02 21:43:20 -0700 | [diff] [blame] | 137 | } create; |