blob: a703ba8d436c12e395dfdf7e204d176d074b013a [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
24allow priv_app audioserver_service:service_manager find;
25allow priv_app cameraserver_service:service_manager find;
26allow priv_app drmserver_service:service_manager find;
27allow priv_app mediacodec_service:service_manager find;
Ray Essick39185402017-01-24 12:53:45 -080028allow priv_app mediametrics_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080029allow priv_app mediadrmserver_service:service_manager find;
Chong Zhang72916412016-10-31 17:02:32 -070030allow priv_app mediacasserver_service:service_manager find;
Alex Klyubin92295ef2017-01-05 15:44:32 -080031allow priv_app mediaextractor_service:service_manager find;
32allow priv_app mediaserver_service:service_manager find;
33allow priv_app nfc_service:service_manager find;
34allow priv_app radio_service:service_manager find;
35allow priv_app surfaceflinger_service:service_manager find;
36allow priv_app app_api_service:service_manager find;
37allow priv_app system_api_service:service_manager find;
38allow priv_app persistent_data_block_service:service_manager find;
39allow priv_app recovery_service:service_manager find;
40
41# Write to /cache.
42allow priv_app { cache_file cache_recovery_file }:dir create_dir_perms;
43allow priv_app { cache_file cache_recovery_file }:file create_file_perms;
Nick Kralevich21cb0452017-01-23 22:19:06 -080044# /cache is a symlink to /data/cache on some devices. Allow reading the link.
45allow priv_app cache_file:lnk_file r_file_perms;
Alex Klyubin92295ef2017-01-05 15:44:32 -080046
47# Write to /data/ota_package for OTA packages.
48allow priv_app ota_package_file:dir rw_dir_perms;
49allow priv_app ota_package_file:file create_file_perms;
50
51# Access to /data/media.
52allow priv_app media_rw_data_file:dir create_dir_perms;
53allow priv_app media_rw_data_file:file create_file_perms;
54
55# Used by Finsky / Android "Verify Apps" functionality when
56# running "adb install foo.apk".
57allow priv_app shell_data_file:file r_file_perms;
58allow priv_app shell_data_file:dir r_dir_perms;
59
60# Allow verifier to access staged apks.
61allow priv_app { apk_tmp_file apk_private_tmp_file }:dir r_dir_perms;
62allow priv_app { apk_tmp_file apk_private_tmp_file }:file r_file_perms;
63
64# b/18504118: Allow reads from /data/anr/traces.txt
65allow priv_app anr_data_file:file r_file_perms;
66
67# Allow GMS core to access perfprofd output, which is stored
68# in /data/misc/perfprofd/. GMS core will need to list all
69# data stored in that directory to process them one by one.
70userdebug_or_eng(`
71 allow priv_app perfprofd_data_file:file r_file_perms;
72 allow priv_app perfprofd_data_file:dir r_dir_perms;
73')
74
75# Allow GMS core to scan executables on the system partition
76allow priv_app exec_type:file { getattr read open };
77
78# For AppFuse.
79allow priv_app vold:fd use;
80allow priv_app fuse_device:chr_file { read write };
81
82# /sys and /proc access
83r_dir_file(priv_app, sysfs_type)
84r_dir_file(priv_app, proc)
85r_dir_file(priv_app, rootfs)
86
87# access the mac address
88allowxperm priv_app self:udp_socket ioctl SIOCGIFHWADDR;
89
90# Allow GMS core to communicate with update_engine for A/B update.
91binder_call(priv_app, update_engine)
92allow priv_app update_engine_service:service_manager find;
93
94# Allow Phone to read/write cached ringtones (opened by system).
95allow priv_app ringtone_file:file { getattr read write };
96
97# Access to /data/preloads
98allow priv_app preloads_data_file:file r_file_perms;
99allow priv_app preloads_data_file:dir r_dir_perms;
Fyodor Kupolovb238fe62017-03-14 11:42:03 -0700100allow priv_app preloads_media_file:file r_file_perms;
101allow priv_app preloads_media_file:dir r_dir_perms;
Alex Klyubin92295ef2017-01-05 15:44:32 -0800102
103# TODO: revert this as part of fixing 33574909
104# android.process.media uses /dev/mtp_usb
105allow priv_app mtp_device:chr_file rw_file_perms;
106
107# TODO: revert this as part of fixing 33574909
108# MtpServer uses /dev/usb-ffs/mtp
109allow priv_app functionfs:dir search;
110allow priv_app functionfs:file rw_file_perms;
111
112# TODO: revert this as part of fixing 33574909
113# Traverse into /mnt/media_rw for bypassing FUSE daemon
114# TODO: narrow this to just MediaProvider
115allow priv_app mnt_media_rw_file:dir search;
116
Shawn Willdena0c7f012017-04-11 09:41:25 -0600117# Allow privileged apps (e.g. GMS core) to generate unique hardware IDs
118allow priv_app keystore:keystore_key gen_unique_id;
119
Mark Salyzynd33a9a12016-11-07 15:11:39 -0800120read_runtime_log_tags(priv_app)
121
Alex Klyubin92295ef2017-01-05 15:44:32 -0800122###
123### neverallow rules
124###
125
126# Receive or send uevent messages.
127neverallow priv_app domain:netlink_kobject_uevent_socket *;
128
129# Receive or send generic netlink messages
130neverallow priv_app domain:netlink_socket *;
131
132# Too much leaky information in debugfs. It's a security
133# best practice to ensure these files aren't readable.
134neverallow priv_app debugfs:file read;
135
136# Do not allow privileged apps to register services.
137# Only trusted components of Android should be registering
138# services.
139neverallow priv_app service_manager_type:service_manager add;
140
141# Do not allow privileged apps to connect to the property service
142# or set properties. b/10243159
143neverallow priv_app property_socket:sock_file write;
144neverallow priv_app init:unix_stream_socket connectto;
145neverallow priv_app property_type:property_service set;
146
147# Do not allow priv_app to be assigned mlstrustedsubject.
148# This would undermine the per-user isolation model being
149# enforced via levelFrom=user in seapp_contexts and the mls
150# constraints. As there is no direct way to specify a neverallow
151# on attribute assignment, this relies on the fact that fork
152# permission only makes sense within a domain (hence should
153# never be granted to any other domain within mlstrustedsubject)
154# and priv_app is allowed fork permission to itself.
155neverallow priv_app mlstrustedsubject:process fork;
156
157# Do not allow priv_app to hard link to any files.
158# In particular, if priv_app links to other app data
159# files, installd will not be able to guarantee the deletion
160# of the linked to file. Hard links also contribute to security
161# bugs, so we want to ensure priv_app never has this
162# capability.
163neverallow priv_app file_type:file link;