blob: 47de41462e9dc1c3ef783e0438c471b348c20afc [file] [log] [blame]
Charles Chenccf80142023-01-20 03:34:19 +00001###
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.
12allow 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.
16allow isolated_app_all { ephemeral_app priv_app untrusted_app_all }:{ tcp_socket udp_socket } { rw_socket_perms_no_ioctl };
17
18allow isolated_app_all activity_service:service_manager find;
19allow isolated_app_all display_service:service_manager find;
20allow 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
27allow 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.
34allow 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.
40allow isolated_app_all webview_zygote:fd use;
41# Notify webview_zygote of child death.
42allow isolated_app_all webview_zygote:process sigchld;
43# Inherit logd write socket.
44allow isolated_app_all webview_zygote:unix_dgram_socket write;
45# Read system properties managed by webview_zygote.
46allow isolated_app_all webview_zygote_tmpfs:file read;
47
48# Inherit FDs from the app_zygote.
49allow isolated_app_all app_zygote:fd use;
50# Notify app_zygote of child death.
51allow isolated_app_all app_zygote:process sigchld;
52# Inherit logd write socket.
53allow isolated_app_all app_zygote:unix_dgram_socket write;
54
55# TODO (b/63631799) fix this access
56# suppress denials to /data/local/tmp
57dontaudit 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.
61perfetto_producer(isolated_app_all)
62
63# Allow profiling if the main app has been marked as profileable or
64# debuggable.
65can_profile_heap(isolated_app_all)
66can_profile_perf(isolated_app_all)
67
68#####
69##### Neverallow
70#####
71
72# Isolated apps should not directly open app data files themselves.
73neverallow 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?
78neverallow isolated_app_all anr_data_file:file ~{ open append };
79neverallow isolated_app_all anr_data_file:dir ~search;
80
81# Isolated apps must not be permitted to use HwBinder
82neverallow isolated_app_all hwbinder_device:chr_file *;
83neverallow isolated_app_all *:hwservice_manager *;
84
85# Isolated apps must not be permitted to use VndBinder
86neverallow 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.
90neverallow 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.
95neverallow 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.
103neverallow isolated_app_all gpu_device:chr_file { rw_file_perms execute };
104
105# Do not allow isolated_app access to /cache
106neverallow isolated_app_all cache_file:dir ~{ r_dir_perms };
107neverallow 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).
111neverallow isolated_app_all { storage_file mnt_user_file sdcard_type fuse }:dir ~getattr;
112neverallow isolated_app_all { storage_file mnt_user_file }:file_class_set *;
113neverallow isolated_app_all { sdcard_type fuse }:{ devfile_class_set lnk_file sock_file fifo_file } *;
114neverallow isolated_app_all { sdcard_type fuse }:file ~{ read write append getattr lock map };
115
116# Do not allow USB access
117neverallow isolated_app_all { usb_device usbaccessory_device }:chr_file *;
118
119# Restrict the webview_zygote control socket.
120neverallow 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.
124neverallow 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.
137neverallow 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;