1*e4a36f41SAndroid Build Coastguard Worker### 2*e4a36f41SAndroid Build Coastguard Worker### isolated_app_all. 3*e4a36f41SAndroid Build Coastguard Worker### 4*e4a36f41SAndroid Build Coastguard Worker### Services with isolatedProcess=true in their manifest. 5*e4a36f41SAndroid Build Coastguard Worker### 6*e4a36f41SAndroid Build Coastguard Worker### This file defines the rules shared by all isolated apps. An "isolated 7*e4a36f41SAndroid Build Coastguard Worker### app" is an APP with UID between AID_ISOLATED_START (99000) 8*e4a36f41SAndroid Build Coastguard Worker### and AID_ISOLATED_END (99999). 9*e4a36f41SAndroid Build Coastguard Worker### 10*e4a36f41SAndroid Build Coastguard Worker 11*e4a36f41SAndroid Build Coastguard Worker# Access already open app data files received over Binder or local socket IPC. 12*e4a36f41SAndroid Build Coastguard Workerallow isolated_app_all { app_data_file privapp_data_file sdk_sandbox_data_file}:file { append read write getattr lock map }; 13*e4a36f41SAndroid Build Coastguard Worker 14*e4a36f41SAndroid Build Coastguard Workerallow isolated_app_all activity_service:service_manager find; 15*e4a36f41SAndroid Build Coastguard Workerallow isolated_app_all display_service:service_manager find; 16*e4a36f41SAndroid Build Coastguard Worker 17*e4a36f41SAndroid Build Coastguard Worker# Google Breakpad (crash reporter for Chrome) relies on ptrace 18*e4a36f41SAndroid Build Coastguard Worker# functionality. Without the ability to ptrace, the crash reporter 19*e4a36f41SAndroid Build Coastguard Worker# tool is broken. 20*e4a36f41SAndroid Build Coastguard Worker# b/20150694 21*e4a36f41SAndroid Build Coastguard Worker# https://code.google.com/p/chromium/issues/detail?id=475270 22*e4a36f41SAndroid Build Coastguard Workerallow isolated_app_all self:process ptrace; 23*e4a36f41SAndroid Build Coastguard Worker 24*e4a36f41SAndroid Build Coastguard Worker# Inherit FDs from the app_zygote. 25*e4a36f41SAndroid Build Coastguard Workerallow isolated_app_all app_zygote:fd use; 26*e4a36f41SAndroid Build Coastguard Worker# Notify app_zygote of child death. 27*e4a36f41SAndroid Build Coastguard Workerallow isolated_app_all app_zygote:process sigchld; 28*e4a36f41SAndroid Build Coastguard Worker# Inherit logd write socket. 29*e4a36f41SAndroid Build Coastguard Workerallow isolated_app_all app_zygote:unix_dgram_socket write; 30*e4a36f41SAndroid Build Coastguard Worker 31*e4a36f41SAndroid Build Coastguard Worker# TODO (b/63631799) fix this access 32*e4a36f41SAndroid Build Coastguard Worker# suppress denials to /data/local/tmp 33*e4a36f41SAndroid Build Coastguard Workerdontaudit isolated_app_all shell_data_file:dir search; 34*e4a36f41SAndroid Build Coastguard Worker 35*e4a36f41SAndroid Build Coastguard Worker# Allow to read, map (but not open) staged apks. 36*e4a36f41SAndroid Build Coastguard Workerallow isolated_app_all { apk_tmp_file apk_private_tmp_file }:file { read getattr map }; 37*e4a36f41SAndroid Build Coastguard Worker 38*e4a36f41SAndroid Build Coastguard Worker##### 39*e4a36f41SAndroid Build Coastguard Worker##### Neverallow 40*e4a36f41SAndroid Build Coastguard Worker##### 41*e4a36f41SAndroid Build Coastguard Worker 42*e4a36f41SAndroid Build Coastguard Worker# Isolated apps should not directly open app data files themselves. 43*e4a36f41SAndroid Build Coastguard Workerneverallow isolated_app_all app_data_file_type:file open; 44*e4a36f41SAndroid Build Coastguard Worker 45*e4a36f41SAndroid Build Coastguard Worker# Only allow appending to /data/anr/traces.txt (b/27853304, b/18340553) 46*e4a36f41SAndroid Build Coastguard Worker# TODO: are there situations where isolated_apps write to this file? 47*e4a36f41SAndroid Build Coastguard Worker# TODO: should we tighten these restrictions further? 48*e4a36f41SAndroid Build Coastguard Workerneverallow isolated_app_all anr_data_file:file ~{ open append }; 49*e4a36f41SAndroid Build Coastguard Workerneverallow isolated_app_all anr_data_file:dir ~search; 50*e4a36f41SAndroid Build Coastguard Worker 51*e4a36f41SAndroid Build Coastguard Worker# Isolated apps must not be permitted to use HwBinder 52*e4a36f41SAndroid Build Coastguard Workerneverallow { isolated_app_all -isolated_compute_app } hwbinder_device:chr_file *; 53*e4a36f41SAndroid Build Coastguard Workerneverallow { isolated_app_all -isolated_compute_app } *:hwservice_manager *; 54*e4a36f41SAndroid Build Coastguard Worker 55*e4a36f41SAndroid Build Coastguard Worker# Isolated apps must not be permitted to use VndBinder 56*e4a36f41SAndroid Build Coastguard Workerneverallow isolated_app_all vndbinder_device:chr_file *; 57*e4a36f41SAndroid Build Coastguard Worker 58*e4a36f41SAndroid Build Coastguard Worker# Isolated apps must not be permitted to perform actions on Binder and VndBinder service_manager 59*e4a36f41SAndroid Build Coastguard Worker# except the find actions for services allowlisted below. 60*e4a36f41SAndroid Build Coastguard Workerneverallow { isolated_app_all -isolated_compute_app } *:service_manager ~find; 61*e4a36f41SAndroid Build Coastguard Worker 62*e4a36f41SAndroid Build Coastguard Worker# b/17487348 63*e4a36f41SAndroid Build Coastguard Worker# Isolated apps can only access three services, 64*e4a36f41SAndroid Build Coastguard Worker# activity_service, display_service, webviewupdate_service. 65*e4a36f41SAndroid Build Coastguard Workerneverallow { isolated_app_all -isolated_compute_app } { 66*e4a36f41SAndroid Build Coastguard Worker service_manager_type 67*e4a36f41SAndroid Build Coastguard Worker -activity_service 68*e4a36f41SAndroid Build Coastguard Worker -display_service 69*e4a36f41SAndroid Build Coastguard Worker -webviewupdate_service 70*e4a36f41SAndroid Build Coastguard Worker}:service_manager find; 71*e4a36f41SAndroid Build Coastguard Worker 72*e4a36f41SAndroid Build Coastguard Worker# Isolated apps shouldn't be able to access the driver directly. 73*e4a36f41SAndroid Build Coastguard Workerneverallow { isolated_app_all -isolated_compute_app } gpu_device:chr_file { rw_file_perms execute }; 74*e4a36f41SAndroid Build Coastguard Worker 75*e4a36f41SAndroid Build Coastguard Worker# Do not allow isolated_apps access to /cache 76*e4a36f41SAndroid Build Coastguard Workerneverallow isolated_app_all cache_file:dir ~{ r_dir_perms }; 77*e4a36f41SAndroid Build Coastguard Workerneverallow isolated_app_all cache_file:file ~{ read getattr }; 78*e4a36f41SAndroid Build Coastguard Worker 79*e4a36f41SAndroid Build Coastguard Worker# Do not allow isolated_app_all to access external storage, except for files passed 80*e4a36f41SAndroid Build Coastguard Worker# via file descriptors (b/32896414). 81*e4a36f41SAndroid Build Coastguard Workerneverallow isolated_app_all { storage_file mnt_user_file sdcard_type fuse }:dir ~getattr; 82*e4a36f41SAndroid Build Coastguard Workerneverallow isolated_app_all { storage_file mnt_user_file }:file_class_set *; 83*e4a36f41SAndroid Build Coastguard Workerneverallow isolated_app_all { sdcard_type fuse }:{ devfile_class_set lnk_file sock_file fifo_file } *; 84*e4a36f41SAndroid Build Coastguard Workerneverallow isolated_app_all { sdcard_type fuse }:file ~{ read write append getattr lock map }; 85*e4a36f41SAndroid Build Coastguard Worker 86*e4a36f41SAndroid Build Coastguard Worker# Do not allow USB access 87*e4a36f41SAndroid Build Coastguard Workerneverallow isolated_app_all { usb_device usbaccessory_device }:chr_file *; 88*e4a36f41SAndroid Build Coastguard Worker 89*e4a36f41SAndroid Build Coastguard Worker# Restrict the webview_zygote control socket. 90*e4a36f41SAndroid Build Coastguard Workerneverallow isolated_app_all webview_zygote:sock_file write; 91*e4a36f41SAndroid Build Coastguard Worker 92*e4a36f41SAndroid Build Coastguard Worker# Limit the /sys files which isolated_app_all can access. This is important 93*e4a36f41SAndroid Build Coastguard Worker# for controlling isolated_app_all attack surface. 94*e4a36f41SAndroid Build Coastguard Worker# TODO (b/266555480): The permission should be guarded by compliance test. 95*e4a36f41SAndroid Build Coastguard Worker# Remove the negation for member domains when refactorization is done. 96*e4a36f41SAndroid Build Coastguard Workerneverallow { isolated_app_all -isolated_compute_app } { 97*e4a36f41SAndroid Build Coastguard Worker sysfs_type 98*e4a36f41SAndroid Build Coastguard Worker -sysfs_devices_system_cpu 99*e4a36f41SAndroid Build Coastguard Worker -sysfs_transparent_hugepage 100*e4a36f41SAndroid Build Coastguard Worker -sysfs_usb # TODO: check with audio team if needed for isolated_apps (b/28417852) 101*e4a36f41SAndroid Build Coastguard Worker -sysfs_fs_fuse_features 102*e4a36f41SAndroid Build Coastguard Worker -sysfs_fs_incfs_features 103*e4a36f41SAndroid Build Coastguard Worker -sysfs_pgsize_migration 104*e4a36f41SAndroid Build Coastguard Worker}:file no_rw_file_perms; 105*e4a36f41SAndroid Build Coastguard Worker 106*e4a36f41SAndroid Build Coastguard Worker# No creation of sockets families other than AF_UNIX sockets. 107*e4a36f41SAndroid Build Coastguard Worker# List taken from system/sepolicy/public/global_macros - socket_class_set 108*e4a36f41SAndroid Build Coastguard Worker# excluding unix_stream_socket and unix_dgram_socket. 109*e4a36f41SAndroid Build Coastguard Worker# Many of these are socket families which have never and will never 110*e4a36f41SAndroid Build Coastguard Worker# be compiled into the Android kernel. 111*e4a36f41SAndroid Build Coastguard Workerneverallow isolated_app_all { self ephemeral_app priv_app sdk_sandbox_all untrusted_app_all }:{ 112*e4a36f41SAndroid Build Coastguard Worker socket tcp_socket udp_socket rawip_socket netlink_socket packet_socket 113*e4a36f41SAndroid Build Coastguard Worker key_socket appletalk_socket netlink_route_socket 114*e4a36f41SAndroid Build Coastguard Worker netlink_tcpdiag_socket netlink_nflog_socket netlink_xfrm_socket 115*e4a36f41SAndroid Build Coastguard Worker netlink_selinux_socket netlink_audit_socket netlink_dnrt_socket 116*e4a36f41SAndroid Build Coastguard Worker netlink_kobject_uevent_socket tun_socket netlink_iscsi_socket 117*e4a36f41SAndroid Build Coastguard Worker netlink_fib_lookup_socket netlink_connector_socket netlink_netfilter_socket 118*e4a36f41SAndroid Build Coastguard Worker netlink_generic_socket netlink_scsitransport_socket netlink_rdma_socket 119*e4a36f41SAndroid Build Coastguard Worker netlink_crypto_socket sctp_socket icmp_socket ax25_socket ipx_socket 120*e4a36f41SAndroid Build Coastguard Worker netrom_socket atmpvc_socket x25_socket rose_socket decnet_socket atmsvc_socket 121*e4a36f41SAndroid Build Coastguard Worker rds_socket irda_socket pppox_socket llc_socket can_socket tipc_socket 122*e4a36f41SAndroid Build Coastguard Worker bluetooth_socket iucv_socket rxrpc_socket isdn_socket phonet_socket 123*e4a36f41SAndroid Build Coastguard Worker ieee802154_socket caif_socket alg_socket nfc_socket vsock_socket kcm_socket 124*e4a36f41SAndroid Build Coastguard Worker qipcrtr_socket smc_socket xdp_socket 125*e4a36f41SAndroid Build Coastguard Worker} create; 126