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