blob: dcf757271a54892183cda0ad610c42f0997c06f1 [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
20# Some apps ship with shared libraries that they write out
21# to their sandbox directory and then dlopen().
Daniel Micay41e3ee462017-01-08 17:19:02 -050022allow priv_app app_data_file:file execute;
Alex Klyubin92295ef2017-01-05 15:44:32 -080023
yro31b11d82018-01-09 11:27:36 -080024allow priv_app app_api_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080025allow priv_app audioserver_service:service_manager find;
26allow priv_app cameraserver_service:service_manager find;
27allow priv_app drmserver_service:service_manager find;
28allow priv_app mediacodec_service:service_manager find;
29allow priv_app mediadrmserver_service:service_manager find;
30allow priv_app mediaextractor_service:service_manager find;
yro31b11d82018-01-09 11:27:36 -080031allow priv_app mediametrics_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080032allow priv_app mediaserver_service:service_manager find;
Ricky Waic6352972017-11-13 17:52:05 +000033allow priv_app network_watchlist_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080034allow priv_app nfc_service:service_manager find;
Andrew Scull37174242017-02-17 13:51:32 +000035allow priv_app oem_lock_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080036allow priv_app persistent_data_block_service:service_manager find;
yro31b11d82018-01-09 11:27:36 -080037allow priv_app radio_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080038allow priv_app recovery_service:service_manager find;
yro31b11d82018-01-09 11:27:36 -080039allow priv_app stats_service:service_manager find;
40allow priv_app system_api_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080041
42# Write to /cache.
43allow priv_app { cache_file cache_recovery_file }:dir create_dir_perms;
44allow priv_app { cache_file cache_recovery_file }:file create_file_perms;
Nick Kralevich21cb0452017-01-23 22:19:06 -080045# /cache is a symlink to /data/cache on some devices. Allow reading the link.
46allow priv_app cache_file:lnk_file r_file_perms;
Alex Klyubin92295ef2017-01-05 15:44:32 -080047
48# Write to /data/ota_package for OTA packages.
49allow priv_app ota_package_file:dir rw_dir_perms;
50allow priv_app ota_package_file:file create_file_perms;
51
52# Access to /data/media.
53allow priv_app media_rw_data_file:dir create_dir_perms;
54allow priv_app media_rw_data_file:file create_file_perms;
55
56# Used by Finsky / Android "Verify Apps" functionality when
57# running "adb install foo.apk".
58allow priv_app shell_data_file:file r_file_perms;
59allow priv_app shell_data_file:dir r_dir_perms;
60
61# Allow verifier to access staged apks.
62allow priv_app { apk_tmp_file apk_private_tmp_file }:dir r_dir_perms;
63allow priv_app { apk_tmp_file apk_private_tmp_file }:file r_file_perms;
64
65# b/18504118: Allow reads from /data/anr/traces.txt
66allow priv_app anr_data_file:file r_file_perms;
67
68# Allow GMS core to access perfprofd output, which is stored
69# in /data/misc/perfprofd/. GMS core will need to list all
70# data stored in that directory to process them one by one.
71userdebug_or_eng(`
72 allow priv_app perfprofd_data_file:file r_file_perms;
73 allow priv_app perfprofd_data_file:dir r_dir_perms;
74')
75
Alex Klyubin92295ef2017-01-05 15:44:32 -080076# For AppFuse.
77allow priv_app vold:fd use;
78allow priv_app fuse_device:chr_file { read write };
79
Tri Vof92cfb92017-12-08 15:37:01 -080080# /proc access
81allow priv_app {
82 proc_vmstat
83}:file r_file_perms;
84
85allow priv_app sysfs_type:dir search;
86# Read access to /sys/class/net/wlan*/address
87r_dir_file(priv_app, sysfs_net)
88# Read access to /sys/block/zram*/mm_stat
89r_dir_file(priv_app, sysfs_zram)
90
Alex Klyubin92295ef2017-01-05 15:44:32 -080091r_dir_file(priv_app, rootfs)
92
Sandeep Patil04654422017-04-19 11:35:15 -070093# Allow GMS core to open kernel config for OTA matching through libvintf
94allow priv_app config_gz:file { open read getattr };
95
Alex Klyubin92295ef2017-01-05 15:44:32 -080096# access the mac address
97allowxperm priv_app self:udp_socket ioctl SIOCGIFHWADDR;
98
99# Allow GMS core to communicate with update_engine for A/B update.
100binder_call(priv_app, update_engine)
101allow priv_app update_engine_service:service_manager find;
102
Jin Qian00a17892017-04-12 17:38:11 -0700103# Allow GMS core to communicate with dumpsys storaged.
104binder_call(priv_app, storaged)
105allow priv_app storaged_service:service_manager find;
106
Tao Baod7d9cfc2017-10-16 21:57:12 -0700107# Allow GMS core to access system_update_service (e.g. to publish pending
108# system update info).
109allow priv_app system_update_service:service_manager find;
110
yro31b11d82018-01-09 11:27:36 -0800111# Allow GMS core to communicate with statsd.
112binder_call(priv_app, statsd)
113
Alex Klyubin92295ef2017-01-05 15:44:32 -0800114# Allow Phone to read/write cached ringtones (opened by system).
115allow priv_app ringtone_file:file { getattr read write };
116
117# Access to /data/preloads
118allow priv_app preloads_data_file:file r_file_perms;
119allow priv_app preloads_data_file:dir r_dir_perms;
Fyodor Kupolovb238fe62017-03-14 11:42:03 -0700120allow priv_app preloads_media_file:file r_file_perms;
121allow priv_app preloads_media_file:dir r_dir_perms;
Alex Klyubin92295ef2017-01-05 15:44:32 -0800122
Shawn Willdena0c7f012017-04-11 09:41:25 -0600123# Allow privileged apps (e.g. GMS core) to generate unique hardware IDs
124allow priv_app keystore:keystore_key gen_unique_id;
125
Dan Cashman91d398d2017-09-26 12:58:29 -0700126# Allow GMS core to access /sys/fs/selinux/policyvers for compatibility check
127allow priv_app selinuxfs:file r_file_perms;
128
Mark Salyzynd33a9a12016-11-07 15:11:39 -0800129read_runtime_log_tags(priv_app)
130
Primiano Tuccic80f9e02017-12-21 03:51:15 +0100131# Write app-specific trace data to the Perfetto traced damon. This requires
132# connecting to its producer socket and obtaining a (per-process) tmpfs fd.
133allow priv_app traced:fd use;
134allow priv_app traced_tmpfs:file { read write getattr map };
135unix_socket_connect(priv_app, traced_producer, traced)
136
Jeff Vander Stoep6d8a8762018-01-18 08:55:02 -0800137# suppress denials for non-API accesses.
Dan Cashman91d398d2017-09-26 12:58:29 -0700138dontaudit priv_app exec_type:file getattr;
Jeff Vander Stoep62338482017-10-20 13:35:42 -0700139dontaudit priv_app device:dir read;
Tri Vof92cfb92017-12-08 15:37:01 -0800140dontaudit priv_app proc:file read;
Jeff Vander Stoep62338482017-10-20 13:35:42 -0700141dontaudit priv_app proc_interrupts:file read;
142dontaudit priv_app proc_modules:file read;
Jeff Vander Stoep6d8a8762018-01-18 08:55:02 -0800143dontaudit priv_app proc_version:file read;
144dontaudit priv_app wifi_prop:file read;
145dontaudit priv_app net_dns_prop:file read;
Dan Cashman91d398d2017-09-26 12:58:29 -0700146
Nathan Haroldee268642017-12-14 18:20:30 -0800147# allow privileged apps to use UDP sockets provided by the system server but not
148# modify them other than to connect
149allow priv_app system_server:udp_socket { connect getattr read recvfrom sendto write };
150
Alex Klyubin92295ef2017-01-05 15:44:32 -0800151###
152### neverallow rules
153###
154
155# Receive or send uevent messages.
156neverallow priv_app domain:netlink_kobject_uevent_socket *;
157
158# Receive or send generic netlink messages
159neverallow priv_app domain:netlink_socket *;
160
161# Too much leaky information in debugfs. It's a security
162# best practice to ensure these files aren't readable.
163neverallow priv_app debugfs:file read;
164
165# Do not allow privileged apps to register services.
166# Only trusted components of Android should be registering
167# services.
168neverallow priv_app service_manager_type:service_manager add;
169
170# Do not allow privileged apps to connect to the property service
171# or set properties. b/10243159
172neverallow priv_app property_socket:sock_file write;
173neverallow priv_app init:unix_stream_socket connectto;
174neverallow priv_app property_type:property_service set;
175
176# Do not allow priv_app to be assigned mlstrustedsubject.
177# This would undermine the per-user isolation model being
178# enforced via levelFrom=user in seapp_contexts and the mls
179# constraints. As there is no direct way to specify a neverallow
180# on attribute assignment, this relies on the fact that fork
181# permission only makes sense within a domain (hence should
182# never be granted to any other domain within mlstrustedsubject)
183# and priv_app is allowed fork permission to itself.
184neverallow priv_app mlstrustedsubject:process fork;
185
186# Do not allow priv_app to hard link to any files.
187# In particular, if priv_app links to other app data
188# files, installd will not be able to guarantee the deletion
189# of the linked to file. Hard links also contribute to security
190# bugs, so we want to ensure priv_app never has this
191# capability.
192neverallow priv_app file_type:file link;