blob: 74930ee271c0f897668ca54f69b8fc815f4e96c9 [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
Nick Kraleviche1ddd742018-10-27 15:20:38 -070017# Allow loading executable code from writable priv-app home
18# directories. This is a W^X violation, however, it needs
19# to be supported for now for the following reasons.
20# * /data/user_*/0/*/code_cache/* POSSIBLE uses (b/117841367)
21# 1) com.android.opengl.shaders_cache
22# 2) com.android.skia.shaders_cache
23# 3) com.android.renderscript.cache
24# * /data/user_de/0/com.google.android.gms/app_chimera
25# TODO: Tighten (b/112357170)
26allow priv_app privapp_data_file:file execute;
Alex Klyubin92295ef2017-01-05 15:44:32 -080027
Nick Kralevich87e91232019-01-24 13:05:03 -080028allow priv_app privapp_data_file:lnk_file create_file_perms;
29
Alan Stokes5c378a52019-03-21 23:52:30 +000030# Priv apps can find services that expose both @SystemAPI and normal APIs.
yro31b11d82018-01-09 11:27:36 -080031allow priv_app app_api_service:service_manager find;
Alan Stokes5c378a52019-03-21 23:52:30 +000032allow priv_app system_api_service:service_manager find;
33
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;
Alex Klyubin92295ef2017-01-05 15:44:32 -080037allow priv_app mediadrmserver_service:service_manager find;
38allow priv_app mediaextractor_service:service_manager find;
yro31b11d82018-01-09 11:27:36 -080039allow priv_app mediametrics_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080040allow priv_app mediaserver_service:service_manager find;
Ricky Waic6352972017-11-13 17:52:05 +000041allow priv_app network_watchlist_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080042allow priv_app nfc_service:service_manager find;
Andrew Scull37174242017-02-17 13:51:32 +000043allow priv_app oem_lock_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080044allow priv_app persistent_data_block_service:service_manager find;
yro31b11d82018-01-09 11:27:36 -080045allow priv_app radio_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080046allow priv_app recovery_service:service_manager find;
yro31b11d82018-01-09 11:27:36 -080047allow priv_app stats_service:service_manager find;
Yiwei Zhang544d6b32019-02-07 15:00:55 -080048
49# Allow privileged apps to interact with gpuservice
50binder_call(priv_app, gpuservice)
Alan Stokes5c378a52019-03-21 23:52:30 +000051allow priv_app gpu_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080052
53# Write to /cache.
54allow priv_app { cache_file cache_recovery_file }:dir create_dir_perms;
55allow priv_app { cache_file cache_recovery_file }:file create_file_perms;
Nick Kralevich21cb0452017-01-23 22:19:06 -080056# /cache is a symlink to /data/cache on some devices. Allow reading the link.
57allow priv_app cache_file:lnk_file r_file_perms;
Alex Klyubin92295ef2017-01-05 15:44:32 -080058
Alex Klyubin92295ef2017-01-05 15:44:32 -080059# Access to /data/media.
60allow priv_app media_rw_data_file:dir create_dir_perms;
61allow priv_app media_rw_data_file:file create_file_perms;
62
63# Used by Finsky / Android "Verify Apps" functionality when
64# running "adb install foo.apk".
65allow priv_app shell_data_file:file r_file_perms;
66allow priv_app shell_data_file:dir r_dir_perms;
67
Max Bires715e2ae2018-03-13 09:56:27 -070068# Allow traceur to pass file descriptors through a content provider to betterbug
69allow priv_app trace_data_file:file { getattr read };
70
Alex Klyubin92295ef2017-01-05 15:44:32 -080071# Allow verifier to access staged apks.
72allow priv_app { apk_tmp_file apk_private_tmp_file }:dir r_dir_perms;
73allow priv_app { apk_tmp_file apk_private_tmp_file }:file r_file_perms;
74
Alex Klyubin92295ef2017-01-05 15:44:32 -080075# For AppFuse.
76allow priv_app vold:fd use;
77allow priv_app fuse_device:chr_file { read write };
78
Tri Vof92cfb92017-12-08 15:37:01 -080079# /proc access
80allow priv_app {
81 proc_vmstat
82}:file r_file_perms;
83
84allow priv_app sysfs_type:dir search;
85# Read access to /sys/class/net/wlan*/address
86r_dir_file(priv_app, sysfs_net)
87# Read access to /sys/block/zram*/mm_stat
88r_dir_file(priv_app, sysfs_zram)
89
Alex Klyubin92295ef2017-01-05 15:44:32 -080090r_dir_file(priv_app, rootfs)
91
92# access the mac address
93allowxperm priv_app self:udp_socket ioctl SIOCGIFHWADDR;
94
Ashwini Oruganti60c6d4e2019-12-13 13:30:53 -080095# Allow com.android.vending to communicate with statsd.
yro31b11d82018-01-09 11:27:36 -080096binder_call(priv_app, statsd)
97
Alex Klyubin92295ef2017-01-05 15:44:32 -080098# Allow Phone to read/write cached ringtones (opened by system).
99allow priv_app ringtone_file:file { getattr read write };
100
101# Access to /data/preloads
102allow priv_app preloads_data_file:file r_file_perms;
103allow priv_app preloads_data_file:dir r_dir_perms;
Fyodor Kupolovb238fe62017-03-14 11:42:03 -0700104allow priv_app preloads_media_file:file r_file_perms;
105allow priv_app preloads_media_file:dir r_dir_perms;
Alex Klyubin92295ef2017-01-05 15:44:32 -0800106
Mark Salyzynd33a9a12016-11-07 15:11:39 -0800107read_runtime_log_tags(priv_app)
108
Primiano Tuccic80f9e02017-12-21 03:51:15 +0100109# Write app-specific trace data to the Perfetto traced damon. This requires
110# connecting to its producer socket and obtaining a (per-process) tmpfs fd.
Florian Mayer5e522812019-10-08 16:15:14 +0100111perfetto_producer(priv_app)
Primiano Tuccic80f9e02017-12-21 03:51:15 +0100112
Joe Onorato9cc5c092019-03-16 15:45:45 -0700113# Allow priv_apps to request and collect incident reports.
114# (Also requires DUMP and PACKAGE_USAGE_STATS permissions)
115allow priv_app incident_service:service_manager find;
116binder_call(priv_app, incidentd)
117allow priv_app incidentd:fifo_file { read write };
118
Ryan Savitski67a82482020-01-22 19:16:13 +0000119# Allow profiling if the app opts in by being marked profileable/debuggable.
Ryan Savitskica0690e2019-01-16 16:29:43 +0000120can_profile_heap(priv_app)
Ryan Savitski67a82482020-01-22 19:16:13 +0000121can_profile_perf(priv_app)
Ryan Savitskica0690e2019-01-16 16:29:43 +0000122
Hung-ying Tyan565384d2019-04-26 16:14:52 +0800123# Allow priv_apps to check whether Dynamic System Update is enabled
124get_prop(priv_app, dynamic_system_prop)
125
Jeff Vander Stoep6d8a8762018-01-18 08:55:02 -0800126# suppress denials for non-API accesses.
Dan Cashman91d398d2017-09-26 12:58:29 -0700127dontaudit priv_app exec_type:file getattr;
Jeff Vander Stoep62338482017-10-20 13:35:42 -0700128dontaudit priv_app device:dir read;
Joel Galenson9ec59f62018-04-20 15:27:21 -0700129dontaudit priv_app fs_bpf:dir search;
Jeff Vander Stoep9dc1d532018-04-04 14:36:13 -0700130dontaudit priv_app net_dns_prop:file read;
Tri Vof92cfb92017-12-08 15:37:01 -0800131dontaudit priv_app proc:file read;
Jeff Vander Stoep62338482017-10-20 13:35:42 -0700132dontaudit priv_app proc_interrupts:file read;
133dontaudit priv_app proc_modules:file read;
Tri Voe319c032019-05-09 16:14:04 -0700134dontaudit priv_app proc_net:file read;
Jeff Vander Stoepe88d6492018-01-29 20:50:59 -0800135dontaudit priv_app proc_stat:file read;
Jeff Vander Stoep6d8a8762018-01-18 08:55:02 -0800136dontaudit priv_app proc_version:file read;
Jeff Vander Stoep9dc1d532018-04-04 14:36:13 -0700137dontaudit priv_app sysfs:dir read;
Jeff Vander Stoep4894d9f2018-06-29 11:04:24 -0700138dontaudit priv_app sysfs:file read;
Jeff Vander Stoep9dc1d532018-04-04 14:36:13 -0700139dontaudit priv_app sysfs_android_usb:file read;
Jeff Vander Stoep90bd1de2019-10-25 11:01:40 +0200140dontaudit priv_app sysfs_dm:file r_file_perms;
Jeff Vander Stoep6d8a8762018-01-18 08:55:02 -0800141dontaudit priv_app wifi_prop:file read;
Jaekyun Seok224921d2018-04-09 12:07:32 +0900142dontaudit priv_app { wifi_prop exported_wifi_prop }:file read;
Dan Cashman91d398d2017-09-26 12:58:29 -0700143
Nathan Haroldee268642017-12-14 18:20:30 -0800144# allow privileged apps to use UDP sockets provided by the system server but not
145# modify them other than to connect
Nathan Harold252b0152018-03-27 06:34:54 -0700146allow priv_app system_server:udp_socket {
147 connect getattr read recvfrom sendto write getopt setopt };
Nathan Haroldee268642017-12-14 18:20:30 -0800148
Alex Klyubin92295ef2017-01-05 15:44:32 -0800149###
150### neverallow rules
151###
152
153# Receive or send uevent messages.
154neverallow priv_app domain:netlink_kobject_uevent_socket *;
155
156# Receive or send generic netlink messages
157neverallow priv_app domain:netlink_socket *;
158
159# Too much leaky information in debugfs. It's a security
160# best practice to ensure these files aren't readable.
161neverallow priv_app debugfs:file read;
162
163# Do not allow privileged apps to register services.
164# Only trusted components of Android should be registering
165# services.
166neverallow priv_app service_manager_type:service_manager add;
167
168# Do not allow privileged apps to connect to the property service
169# or set properties. b/10243159
170neverallow priv_app property_socket:sock_file write;
171neverallow priv_app init:unix_stream_socket connectto;
172neverallow priv_app property_type:property_service set;
173
174# Do not allow priv_app to be assigned mlstrustedsubject.
175# This would undermine the per-user isolation model being
176# enforced via levelFrom=user in seapp_contexts and the mls
177# constraints. As there is no direct way to specify a neverallow
178# on attribute assignment, this relies on the fact that fork
179# permission only makes sense within a domain (hence should
180# never be granted to any other domain within mlstrustedsubject)
181# and priv_app is allowed fork permission to itself.
182neverallow priv_app mlstrustedsubject:process fork;
183
184# Do not allow priv_app to hard link to any files.
185# In particular, if priv_app links to other app data
186# files, installd will not be able to guarantee the deletion
187# of the linked to file. Hard links also contribute to security
188# bugs, so we want to ensure priv_app never has this
189# capability.
190neverallow priv_app file_type:file link;
Max Bires715e2ae2018-03-13 09:56:27 -0700191
192# priv apps should not be able to open trace data files, they should depend
193# upon traceur to pass a file descriptor which they can then read
194neverallow priv_app trace_data_file:dir *;
195neverallow priv_app trace_data_file:file { no_w_file_perms open };
Tri Vof55c9892018-10-10 22:48:15 +0000196
197# Do not allow priv_app access to cgroups.
198neverallow priv_app cgroup:file *;
Nick Kraleviche1ddd742018-10-27 15:20:38 -0700199
200# Do not allow loading executable code from non-privileged
201# application home directories. Code loading across a security boundary
202# is dangerous and allows a full compromise of a privileged process
203# by an unprivileged process. b/112357170
204neverallow priv_app app_data_file:file no_x_file_perms;
Nick Kralevich87e91232019-01-24 13:05:03 -0800205
206# Do not follow untrusted app provided symlinks
207neverallow priv_app app_data_file:lnk_file { open read getattr };