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