1*e4a36f41SAndroid Build Coastguard Worker# webview_zygote is an auxiliary zygote process that is used to spawn 2*e4a36f41SAndroid Build Coastguard Worker# isolated_app processes for rendering untrusted web content. 3*e4a36f41SAndroid Build Coastguard Worker 4*e4a36f41SAndroid Build Coastguard Workertypeattribute webview_zygote coredomain; 5*e4a36f41SAndroid Build Coastguard Worker 6*e4a36f41SAndroid Build Coastguard Worker# The webview_zygote needs to be able to transition domains. 7*e4a36f41SAndroid Build Coastguard Workertypeattribute webview_zygote mlstrustedsubject; 8*e4a36f41SAndroid Build Coastguard Worker 9*e4a36f41SAndroid Build Coastguard Worker# Allow access to temporary files, which is normally permitted through 10*e4a36f41SAndroid Build Coastguard Worker# a domain macro. 11*e4a36f41SAndroid Build Coastguard Workertmpfs_domain(webview_zygote); 12*e4a36f41SAndroid Build Coastguard Worker 13*e4a36f41SAndroid Build Coastguard Workeruserfaultfd_use(webview_zygote) 14*e4a36f41SAndroid Build Coastguard Worker 15*e4a36f41SAndroid Build Coastguard Worker# Allow reading/executing installed binaries to enable preloading the 16*e4a36f41SAndroid Build Coastguard Worker# installed WebView implementation. 17*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote apk_data_file:dir r_dir_perms; 18*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote apk_data_file:file { r_file_perms execute }; 19*e4a36f41SAndroid Build Coastguard Worker 20*e4a36f41SAndroid Build Coastguard Worker# Access to the WebView relro file. 21*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote shared_relro_file:dir search; 22*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote shared_relro_file:file r_file_perms; 23*e4a36f41SAndroid Build Coastguard Worker 24*e4a36f41SAndroid Build Coastguard Worker# Set the UID/GID of the process. 25*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote self:global_capability_class_set { setgid setuid }; 26*e4a36f41SAndroid Build Coastguard Worker# Drop capabilities from bounding set. 27*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote self:global_capability_class_set setpcap; 28*e4a36f41SAndroid Build Coastguard Worker# Switch SELinux context to app domains. 29*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote self:process setcurrent; 30*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote isolated_app:process dyntransition; 31*e4a36f41SAndroid Build Coastguard Worker 32*e4a36f41SAndroid Build Coastguard Worker# For art. 33*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote { apex_art_data_file dalvikcache_data_file }:dir r_dir_perms; 34*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote dalvikcache_data_file:lnk_file r_file_perms; 35*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote { apex_art_data_file dalvikcache_data_file }:file { r_file_perms execute }; 36*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote apex_module_data_file:dir search; 37*e4a36f41SAndroid Build Coastguard Worker 38*e4a36f41SAndroid Build Coastguard Worker# To load overlay from /apex (vendor APEXes) 39*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote vendor_apex_metadata_file:dir search; 40*e4a36f41SAndroid Build Coastguard Worker 41*e4a36f41SAndroid Build Coastguard Worker# Allow webview_zygote to create JIT memory. 42*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote self:process execmem; 43*e4a36f41SAndroid Build Coastguard Worker 44*e4a36f41SAndroid Build Coastguard Worker# Allow webview_zygote to stat the files that it opens. It must 45*e4a36f41SAndroid Build Coastguard Worker# be able to inspect them so that it can reopen them on fork 46*e4a36f41SAndroid Build Coastguard Worker# if necessary: b/30963384. 47*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote debugfs_trace_marker:file getattr; 48*e4a36f41SAndroid Build Coastguard Worker 49*e4a36f41SAndroid Build Coastguard Worker# Allow webview_zygote to manage the pgroup of its children. 50*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote system_server:process getpgid; 51*e4a36f41SAndroid Build Coastguard Worker 52*e4a36f41SAndroid Build Coastguard Worker# Interaction between the webview_zygote and its children. 53*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote isolated_app:process setpgid; 54*e4a36f41SAndroid Build Coastguard Worker 55*e4a36f41SAndroid Build Coastguard Worker# TODO (b/63631799) fix this access 56*e4a36f41SAndroid Build Coastguard Worker# Suppress denials to storage. Webview zygote should not be accessing. 57*e4a36f41SAndroid Build Coastguard Workerdontaudit webview_zygote mnt_expand_file:dir getattr; 58*e4a36f41SAndroid Build Coastguard Worker 59*e4a36f41SAndroid Build Coastguard Worker# TODO (b/72957399) remove this when webview_zygote is reparented to 60*e4a36f41SAndroid Build Coastguard Worker# app_process zygote 61*e4a36f41SAndroid Build Coastguard Workerdontaudit webview_zygote dex2oat_exec:file execute; 62*e4a36f41SAndroid Build Coastguard Worker 63*e4a36f41SAndroid Build Coastguard Worker# Get seapp_contexts 64*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote seapp_contexts_file:file r_file_perms; 65*e4a36f41SAndroid Build Coastguard Worker# Check validity of SELinux context before use. 66*e4a36f41SAndroid Build Coastguard Workerselinux_check_context(webview_zygote) 67*e4a36f41SAndroid Build Coastguard Worker# Check SELinux permissions. 68*e4a36f41SAndroid Build Coastguard Workerselinux_check_access(webview_zygote) 69*e4a36f41SAndroid Build Coastguard Worker 70*e4a36f41SAndroid Build Coastguard Worker# Directory listing in /system. 71*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote system_file:dir r_dir_perms; 72*e4a36f41SAndroid Build Coastguard Worker 73*e4a36f41SAndroid Build Coastguard Worker# Read and inspect temporary files (like system properties) managed by zygote. 74*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote zygote_tmpfs:file { read getattr }; 75*e4a36f41SAndroid Build Coastguard Worker# Child of zygote. 76*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote zygote:fd use; 77*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote zygote:process sigchld; 78*e4a36f41SAndroid Build Coastguard Worker 79*e4a36f41SAndroid Build Coastguard Worker# Allow apps access to /vendor/overlay 80*e4a36f41SAndroid Build Coastguard Workerr_dir_file(webview_zygote, vendor_overlay_file) 81*e4a36f41SAndroid Build Coastguard Worker 82*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote same_process_hal_file:file { execute read open getattr map }; 83*e4a36f41SAndroid Build Coastguard Worker 84*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote system_data_file:lnk_file r_file_perms; 85*e4a36f41SAndroid Build Coastguard Worker 86*e4a36f41SAndroid Build Coastguard Worker# Send unsolicited message to system_server 87*e4a36f41SAndroid Build Coastguard Workerunix_socket_send(webview_zygote, system_unsolzygote, system_server) 88*e4a36f41SAndroid Build Coastguard Worker 89*e4a36f41SAndroid Build Coastguard Worker# Allow the webview_zygote to access the runtime feature flag properties. 90*e4a36f41SAndroid Build Coastguard Workerget_prop(webview_zygote, device_config_runtime_native_prop) 91*e4a36f41SAndroid Build Coastguard Workerget_prop(webview_zygote, device_config_runtime_native_boot_prop) 92*e4a36f41SAndroid Build Coastguard Worker 93*e4a36f41SAndroid Build Coastguard Worker# Allow webview_zygote to access odsign verification status 94*e4a36f41SAndroid Build Coastguard Workerget_prop(zygote, odsign_prop) 95*e4a36f41SAndroid Build Coastguard Worker 96*e4a36f41SAndroid Build Coastguard Worker# /data/resource-cache 97*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote resourcecache_data_file:file r_file_perms; 98*e4a36f41SAndroid Build Coastguard Workerallow webview_zygote resourcecache_data_file:dir r_dir_perms; 99*e4a36f41SAndroid Build Coastguard Worker 100*e4a36f41SAndroid Build Coastguard Worker##### 101*e4a36f41SAndroid Build Coastguard Worker##### Neverallow 102*e4a36f41SAndroid Build Coastguard Worker##### 103*e4a36f41SAndroid Build Coastguard Worker 104*e4a36f41SAndroid Build Coastguard Worker# Only permit transition to isolated_app. 105*e4a36f41SAndroid Build Coastguard Workerneverallow webview_zygote { domain -isolated_app }:process dyntransition; 106*e4a36f41SAndroid Build Coastguard Worker 107*e4a36f41SAndroid Build Coastguard Worker# Only setcon() transitions, no exec() based transitions, except for crash_dump. 108*e4a36f41SAndroid Build Coastguard Workerneverallow webview_zygote { domain -crash_dump }:process transition; 109*e4a36f41SAndroid Build Coastguard Worker 110*e4a36f41SAndroid Build Coastguard Worker# Must not exec() a program without changing domains. 111*e4a36f41SAndroid Build Coastguard Worker# Having said that, exec() above is not allowed. 112*e4a36f41SAndroid Build Coastguard Workerneverallow webview_zygote *:file execute_no_trans; 113*e4a36f41SAndroid Build Coastguard Worker 114*e4a36f41SAndroid Build Coastguard Worker# The only way to enter this domain is for the zygote to fork a new 115*e4a36f41SAndroid Build Coastguard Worker# webview_zygote child. 116*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -zygote } webview_zygote:process dyntransition; 117*e4a36f41SAndroid Build Coastguard Worker 118*e4a36f41SAndroid Build Coastguard Worker# Disallow write access to properties. 119*e4a36f41SAndroid Build Coastguard Workerneverallow webview_zygote property_socket:sock_file write; 120*e4a36f41SAndroid Build Coastguard Workerneverallow webview_zygote property_type:property_service set; 121*e4a36f41SAndroid Build Coastguard Worker 122*e4a36f41SAndroid Build Coastguard Worker# Should not have any access to app data files. 123*e4a36f41SAndroid Build Coastguard Workerneverallow webview_zygote app_data_file_type:file { rwx_file_perms }; 124*e4a36f41SAndroid Build Coastguard Worker 125*e4a36f41SAndroid Build Coastguard Workerneverallow webview_zygote { 126*e4a36f41SAndroid Build Coastguard Worker service_manager_type 127*e4a36f41SAndroid Build Coastguard Worker -activity_service 128*e4a36f41SAndroid Build Coastguard Worker -webviewupdate_service 129*e4a36f41SAndroid Build Coastguard Worker}:service_manager find; 130*e4a36f41SAndroid Build Coastguard Worker 131*e4a36f41SAndroid Build Coastguard Worker# Isolated apps shouldn't be able to access the driver directly. 132*e4a36f41SAndroid Build Coastguard Workerneverallow webview_zygote gpu_device:chr_file { rwx_file_perms }; 133*e4a36f41SAndroid Build Coastguard Worker 134*e4a36f41SAndroid Build Coastguard Worker# Do not allow webview_zygote access to /cache. 135*e4a36f41SAndroid Build Coastguard Workerneverallow webview_zygote cache_file:dir ~{ r_dir_perms }; 136*e4a36f41SAndroid Build Coastguard Workerneverallow webview_zygote cache_file:file ~{ read getattr }; 137*e4a36f41SAndroid Build Coastguard Worker 138*e4a36f41SAndroid Build Coastguard Worker# Do not allow most socket access. This is socket_class_set, excluding unix_dgram_socket, 139*e4a36f41SAndroid Build Coastguard Worker# unix_stream_socket, and netlink_selinux_socket. 140*e4a36f41SAndroid Build Coastguard Workerneverallow webview_zygote domain:{ 141*e4a36f41SAndroid Build Coastguard Worker socket tcp_socket udp_socket rawip_socket netlink_socket packet_socket key_socket 142*e4a36f41SAndroid Build Coastguard Worker appletalk_socket netlink_route_socket netlink_tcpdiag_socket 143*e4a36f41SAndroid Build Coastguard Worker netlink_nflog_socket netlink_xfrm_socket netlink_audit_socket 144*e4a36f41SAndroid Build Coastguard Worker netlink_dnrt_socket netlink_kobject_uevent_socket tun_socket netlink_iscsi_socket 145*e4a36f41SAndroid Build Coastguard Worker netlink_fib_lookup_socket netlink_connector_socket netlink_netfilter_socket 146*e4a36f41SAndroid Build Coastguard Worker netlink_generic_socket netlink_scsitransport_socket netlink_rdma_socket netlink_crypto_socket 147*e4a36f41SAndroid Build Coastguard Worker sctp_socket icmp_socket ax25_socket ipx_socket netrom_socket atmpvc_socket 148*e4a36f41SAndroid Build Coastguard Worker x25_socket rose_socket decnet_socket atmsvc_socket rds_socket irda_socket 149*e4a36f41SAndroid Build Coastguard Worker pppox_socket llc_socket can_socket tipc_socket bluetooth_socket iucv_socket 150*e4a36f41SAndroid Build Coastguard Worker rxrpc_socket isdn_socket phonet_socket ieee802154_socket caif_socket 151*e4a36f41SAndroid Build Coastguard Worker alg_socket nfc_socket vsock_socket kcm_socket qipcrtr_socket smc_socket 152*e4a36f41SAndroid Build Coastguard Worker xdp_socket 153*e4a36f41SAndroid Build Coastguard Worker} *; 154*e4a36f41SAndroid Build Coastguard Worker 155*e4a36f41SAndroid Build Coastguard Worker# Do not allow access to Bluetooth-related system properties. 156*e4a36f41SAndroid Build Coastguard Worker# neverallow rules for Bluetooth-related data files are listed above. 157*e4a36f41SAndroid Build Coastguard Workerneverallow webview_zygote { 158*e4a36f41SAndroid Build Coastguard Worker bluetooth_a2dp_offload_prop 159*e4a36f41SAndroid Build Coastguard Worker bluetooth_audio_hal_prop 160*e4a36f41SAndroid Build Coastguard Worker bluetooth_prop 161*e4a36f41SAndroid Build Coastguard Worker exported_bluetooth_prop 162*e4a36f41SAndroid Build Coastguard Worker}:file create_file_perms; 163