blob: ad39eb16baacd1498336c6d4c863beb4a4791eb9 [file] [log] [blame]
Alex Klyubin92295ef2017-01-05 15:44:32 -08001###
2### A domain for further sandboxing privileged apps.
3###
4
Alex Klyubinf5446eb2017-03-23 14:27:32 -07005typeattribute priv_app coredomain;
dcashman3e8dbf02016-12-08 11:23:34 -08006app_domain(priv_app)
dcashman2e00e632016-10-12 14:58:09 -07007
Alex Klyubin92295ef2017-01-05 15:44:32 -08008# Access the network.
9net_domain(priv_app)
10# Access bluetooth.
11bluetooth_domain(priv_app)
12
dcashman2e00e632016-10-12 14:58:09 -070013# Allow the allocation and use of ptys
14# Used by: https://play.privileged.com/store/apps/details?id=jackpal.androidterm
15create_pty(priv_app)
Alex Klyubin92295ef2017-01-05 15:44:32 -080016
17# webview crash handling depends on self ptrace (b/27697529, b/20150694, b/19277529#comment7)
18allow priv_app self:process ptrace;
19
Nick Kraleviche1ddd742018-10-27 15:20:38 -070020# Allow loading executable code from writable priv-app home
21# directories. This is a W^X violation, however, it needs
22# to be supported for now for the following reasons.
23# * /data/user_*/0/*/code_cache/* POSSIBLE uses (b/117841367)
24# 1) com.android.opengl.shaders_cache
25# 2) com.android.skia.shaders_cache
26# 3) com.android.renderscript.cache
27# * /data/user_de/0/com.google.android.gms/app_chimera
28# TODO: Tighten (b/112357170)
29allow priv_app privapp_data_file:file execute;
Alex Klyubin92295ef2017-01-05 15:44:32 -080030
Nick Kralevich87e91232019-01-24 13:05:03 -080031allow priv_app privapp_data_file:lnk_file create_file_perms;
32
yro31b11d82018-01-09 11:27:36 -080033allow priv_app app_api_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080034allow priv_app audioserver_service:service_manager find;
35allow priv_app cameraserver_service:service_manager find;
36allow priv_app drmserver_service:service_manager find;
37allow priv_app mediacodec_service:service_manager find;
38allow priv_app mediadrmserver_service:service_manager find;
39allow priv_app mediaextractor_service:service_manager find;
yro31b11d82018-01-09 11:27:36 -080040allow priv_app mediametrics_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080041allow priv_app mediaserver_service:service_manager find;
Ricky Waic6352972017-11-13 17:52:05 +000042allow priv_app network_watchlist_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080043allow priv_app nfc_service:service_manager find;
Andrew Scull37174242017-02-17 13:51:32 +000044allow priv_app oem_lock_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080045allow priv_app persistent_data_block_service:service_manager find;
yro31b11d82018-01-09 11:27:36 -080046allow priv_app radio_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080047allow priv_app recovery_service:service_manager find;
yro31b11d82018-01-09 11:27:36 -080048allow priv_app stats_service:service_manager find;
49allow priv_app system_api_service:service_manager find;
Yiwei Zhang544d6b32019-02-07 15:00:55 -080050allow priv_app gpu_service:service_manager find;
51
52# Allow privileged apps to interact with gpuservice
53binder_call(priv_app, gpuservice)
Alex Klyubin92295ef2017-01-05 15:44:32 -080054
55# Write to /cache.
56allow priv_app { cache_file cache_recovery_file }:dir create_dir_perms;
57allow priv_app { cache_file cache_recovery_file }:file create_file_perms;
Nick Kralevich21cb0452017-01-23 22:19:06 -080058# /cache is a symlink to /data/cache on some devices. Allow reading the link.
59allow priv_app cache_file:lnk_file r_file_perms;
Alex Klyubin92295ef2017-01-05 15:44:32 -080060
61# Write to /data/ota_package for OTA packages.
62allow priv_app ota_package_file:dir rw_dir_perms;
63allow priv_app ota_package_file:file create_file_perms;
64
65# Access to /data/media.
66allow priv_app media_rw_data_file:dir create_dir_perms;
67allow priv_app media_rw_data_file:file create_file_perms;
68
69# Used by Finsky / Android "Verify Apps" functionality when
70# running "adb install foo.apk".
71allow priv_app shell_data_file:file r_file_perms;
72allow priv_app shell_data_file:dir r_dir_perms;
73
Max Bires715e2ae2018-03-13 09:56:27 -070074# Allow traceur to pass file descriptors through a content provider to betterbug
75allow priv_app trace_data_file:file { getattr read };
76
Alex Klyubin92295ef2017-01-05 15:44:32 -080077# Allow verifier to access staged apks.
78allow priv_app { apk_tmp_file apk_private_tmp_file }:dir r_dir_perms;
79allow priv_app { apk_tmp_file apk_private_tmp_file }:file r_file_perms;
80
81# b/18504118: Allow reads from /data/anr/traces.txt
82allow priv_app anr_data_file:file r_file_perms;
83
84# Allow GMS core to access perfprofd output, which is stored
85# in /data/misc/perfprofd/. GMS core will need to list all
86# data stored in that directory to process them one by one.
87userdebug_or_eng(`
88 allow priv_app perfprofd_data_file:file r_file_perms;
89 allow priv_app perfprofd_data_file:dir r_dir_perms;
90')
91
Alex Klyubin92295ef2017-01-05 15:44:32 -080092# For AppFuse.
93allow priv_app vold:fd use;
94allow priv_app fuse_device:chr_file { read write };
95
Tri Vof92cfb92017-12-08 15:37:01 -080096# /proc access
97allow priv_app {
98 proc_vmstat
99}:file r_file_perms;
100
101allow priv_app sysfs_type:dir search;
102# Read access to /sys/class/net/wlan*/address
103r_dir_file(priv_app, sysfs_net)
104# Read access to /sys/block/zram*/mm_stat
105r_dir_file(priv_app, sysfs_zram)
106
Alex Klyubin92295ef2017-01-05 15:44:32 -0800107r_dir_file(priv_app, rootfs)
108
Sandeep Patil04654422017-04-19 11:35:15 -0700109# Allow GMS core to open kernel config for OTA matching through libvintf
110allow priv_app config_gz:file { open read getattr };
111
Alex Klyubin92295ef2017-01-05 15:44:32 -0800112# access the mac address
113allowxperm priv_app self:udp_socket ioctl SIOCGIFHWADDR;
114
115# Allow GMS core to communicate with update_engine for A/B update.
116binder_call(priv_app, update_engine)
117allow priv_app update_engine_service:service_manager find;
118
Jin Qian00a17892017-04-12 17:38:11 -0700119# Allow GMS core to communicate with dumpsys storaged.
120binder_call(priv_app, storaged)
121allow priv_app storaged_service:service_manager find;
122
Tao Baod7d9cfc2017-10-16 21:57:12 -0700123# Allow GMS core to access system_update_service (e.g. to publish pending
124# system update info).
125allow priv_app system_update_service:service_manager find;
126
yro31b11d82018-01-09 11:27:36 -0800127# Allow GMS core to communicate with statsd.
128binder_call(priv_app, statsd)
129
Alex Klyubin92295ef2017-01-05 15:44:32 -0800130# Allow Phone to read/write cached ringtones (opened by system).
131allow priv_app ringtone_file:file { getattr read write };
132
133# Access to /data/preloads
134allow priv_app preloads_data_file:file r_file_perms;
135allow priv_app preloads_data_file:dir r_dir_perms;
Fyodor Kupolovb238fe62017-03-14 11:42:03 -0700136allow priv_app preloads_media_file:file r_file_perms;
137allow priv_app preloads_media_file:dir r_dir_perms;
Alex Klyubin92295ef2017-01-05 15:44:32 -0800138
Shawn Willdena0c7f012017-04-11 09:41:25 -0600139# Allow privileged apps (e.g. GMS core) to generate unique hardware IDs
140allow priv_app keystore:keystore_key gen_unique_id;
141
Dan Cashman91d398d2017-09-26 12:58:29 -0700142# Allow GMS core to access /sys/fs/selinux/policyvers for compatibility check
143allow priv_app selinuxfs:file r_file_perms;
144
Mark Salyzynd33a9a12016-11-07 15:11:39 -0800145read_runtime_log_tags(priv_app)
146
Primiano Tuccic80f9e02017-12-21 03:51:15 +0100147# Write app-specific trace data to the Perfetto traced damon. This requires
148# connecting to its producer socket and obtaining a (per-process) tmpfs fd.
149allow priv_app traced:fd use;
150allow priv_app traced_tmpfs:file { read write getattr map };
151unix_socket_connect(priv_app, traced_producer, traced)
152
Ryan Savitskica0690e2019-01-16 16:29:43 +0000153# Allow heap profiling if the app opts in by being marked
154# profileable/debuggable.
155can_profile_heap(priv_app)
156
Jeff Vander Stoep6d8a8762018-01-18 08:55:02 -0800157# suppress denials for non-API accesses.
Dan Cashman91d398d2017-09-26 12:58:29 -0700158dontaudit priv_app exec_type:file getattr;
Jeff Vander Stoep62338482017-10-20 13:35:42 -0700159dontaudit priv_app device:dir read;
Joel Galenson9ec59f62018-04-20 15:27:21 -0700160dontaudit priv_app fs_bpf:dir search;
Jeff Vander Stoep9dc1d532018-04-04 14:36:13 -0700161dontaudit priv_app net_dns_prop:file read;
Tri Vof92cfb92017-12-08 15:37:01 -0800162dontaudit priv_app proc:file read;
Jeff Vander Stoep62338482017-10-20 13:35:42 -0700163dontaudit priv_app proc_interrupts:file read;
164dontaudit priv_app proc_modules:file read;
Jeff Vander Stoepe88d6492018-01-29 20:50:59 -0800165dontaudit priv_app proc_stat:file read;
Jeff Vander Stoep6d8a8762018-01-18 08:55:02 -0800166dontaudit priv_app proc_version:file read;
Jeff Vander Stoep9dc1d532018-04-04 14:36:13 -0700167dontaudit priv_app sysfs:dir read;
Jeff Vander Stoep4894d9f2018-06-29 11:04:24 -0700168dontaudit priv_app sysfs:file read;
Jeff Vander Stoep9dc1d532018-04-04 14:36:13 -0700169dontaudit priv_app sysfs_android_usb:file read;
Jeff Vander Stoep6d8a8762018-01-18 08:55:02 -0800170dontaudit priv_app wifi_prop:file read;
Jaekyun Seok224921d2018-04-09 12:07:32 +0900171dontaudit priv_app { wifi_prop exported_wifi_prop }:file read;
Dan Cashman91d398d2017-09-26 12:58:29 -0700172
Nathan Haroldee268642017-12-14 18:20:30 -0800173# allow privileged apps to use UDP sockets provided by the system server but not
174# modify them other than to connect
Nathan Harold252b0152018-03-27 06:34:54 -0700175allow priv_app system_server:udp_socket {
176 connect getattr read recvfrom sendto write getopt setopt };
Nathan Haroldee268642017-12-14 18:20:30 -0800177
Jeff Vander Stoep9c7396d2018-06-01 12:12:11 -0700178# Attempts to write to system_data_file is generally a sign
179# that apps are attempting to access encrypted storage before
180# the ACTION_USER_UNLOCKED intent is delivered. Suppress this
181# denial to prevent apps from spamming the logs.
182dontaudit priv_app system_data_file:dir write;
183
Alex Klyubin92295ef2017-01-05 15:44:32 -0800184###
185### neverallow rules
186###
187
188# Receive or send uevent messages.
189neverallow priv_app domain:netlink_kobject_uevent_socket *;
190
191# Receive or send generic netlink messages
192neverallow priv_app domain:netlink_socket *;
193
194# Too much leaky information in debugfs. It's a security
195# best practice to ensure these files aren't readable.
196neverallow priv_app debugfs:file read;
197
198# Do not allow privileged apps to register services.
199# Only trusted components of Android should be registering
200# services.
201neverallow priv_app service_manager_type:service_manager add;
202
203# Do not allow privileged apps to connect to the property service
204# or set properties. b/10243159
205neverallow priv_app property_socket:sock_file write;
206neverallow priv_app init:unix_stream_socket connectto;
207neverallow priv_app property_type:property_service set;
208
209# Do not allow priv_app to be assigned mlstrustedsubject.
210# This would undermine the per-user isolation model being
211# enforced via levelFrom=user in seapp_contexts and the mls
212# constraints. As there is no direct way to specify a neverallow
213# on attribute assignment, this relies on the fact that fork
214# permission only makes sense within a domain (hence should
215# never be granted to any other domain within mlstrustedsubject)
216# and priv_app is allowed fork permission to itself.
217neverallow priv_app mlstrustedsubject:process fork;
218
219# Do not allow priv_app to hard link to any files.
220# In particular, if priv_app links to other app data
221# files, installd will not be able to guarantee the deletion
222# of the linked to file. Hard links also contribute to security
223# bugs, so we want to ensure priv_app never has this
224# capability.
225neverallow priv_app file_type:file link;
Max Bires715e2ae2018-03-13 09:56:27 -0700226
227# priv apps should not be able to open trace data files, they should depend
228# upon traceur to pass a file descriptor which they can then read
229neverallow priv_app trace_data_file:dir *;
230neverallow priv_app trace_data_file:file { no_w_file_perms open };
Tri Vof55c9892018-10-10 22:48:15 +0000231
232# Do not allow priv_app access to cgroups.
233neverallow priv_app cgroup:file *;
Nick Kraleviche1ddd742018-10-27 15:20:38 -0700234
235# Do not allow loading executable code from non-privileged
236# application home directories. Code loading across a security boundary
237# is dangerous and allows a full compromise of a privileged process
238# by an unprivileged process. b/112357170
239neverallow priv_app app_data_file:file no_x_file_perms;
Nick Kralevich87e91232019-01-24 13:05:03 -0800240
241# Do not follow untrusted app provided symlinks
242neverallow priv_app app_data_file:lnk_file { open read getattr };