blob: dc1690c4607283644e0f92fd5e27d9d9efd9fe2c [file] [log] [blame]
Alex Klyubin92295ef2017-01-05 15:44:32 -08001###
2### A domain for further sandboxing privileged apps.
3###
4
dcashman3e8dbf02016-12-08 11:23:34 -08005app_domain(priv_app)
dcashman2e00e632016-10-12 14:58:09 -07006
Alex Klyubin92295ef2017-01-05 15:44:32 -08007# Access the network.
8net_domain(priv_app)
9# Access bluetooth.
10bluetooth_domain(priv_app)
11
dcashman2e00e632016-10-12 14:58:09 -070012# Allow the allocation and use of ptys
13# Used by: https://play.privileged.com/store/apps/details?id=jackpal.androidterm
14create_pty(priv_app)
Alex Klyubin92295ef2017-01-05 15:44:32 -080015
16# webview crash handling depends on self ptrace (b/27697529, b/20150694, b/19277529#comment7)
17allow priv_app self:process ptrace;
18
19# Some apps ship with shared libraries that they write out
20# to their sandbox directory and then dlopen().
Daniel Micay41e3ee462017-01-08 17:19:02 -050021allow priv_app app_data_file:file execute;
Alex Klyubin92295ef2017-01-05 15:44:32 -080022
23allow priv_app audioserver_service:service_manager find;
24allow priv_app cameraserver_service:service_manager find;
25allow priv_app drmserver_service:service_manager find;
26allow priv_app mediacodec_service:service_manager find;
27allow priv_app mediadrmserver_service:service_manager find;
28allow priv_app mediaextractor_service:service_manager find;
29allow priv_app mediaserver_service:service_manager find;
30allow priv_app nfc_service:service_manager find;
31allow priv_app radio_service:service_manager find;
32allow priv_app surfaceflinger_service:service_manager find;
33allow priv_app app_api_service:service_manager find;
34allow priv_app system_api_service:service_manager find;
35allow priv_app persistent_data_block_service:service_manager find;
36allow priv_app recovery_service:service_manager find;
37
38# Write to /cache.
39allow priv_app { cache_file cache_recovery_file }:dir create_dir_perms;
40allow priv_app { cache_file cache_recovery_file }:file create_file_perms;
41
42# Write to /data/ota_package for OTA packages.
43allow priv_app ota_package_file:dir rw_dir_perms;
44allow priv_app ota_package_file:file create_file_perms;
45
46# Access to /data/media.
47allow priv_app media_rw_data_file:dir create_dir_perms;
48allow priv_app media_rw_data_file:file create_file_perms;
49
50# Used by Finsky / Android "Verify Apps" functionality when
51# running "adb install foo.apk".
52allow priv_app shell_data_file:file r_file_perms;
53allow priv_app shell_data_file:dir r_dir_perms;
54
55# Allow verifier to access staged apks.
56allow priv_app { apk_tmp_file apk_private_tmp_file }:dir r_dir_perms;
57allow priv_app { apk_tmp_file apk_private_tmp_file }:file r_file_perms;
58
59# b/18504118: Allow reads from /data/anr/traces.txt
60allow priv_app anr_data_file:file r_file_perms;
61
62# Allow GMS core to access perfprofd output, which is stored
63# in /data/misc/perfprofd/. GMS core will need to list all
64# data stored in that directory to process them one by one.
65userdebug_or_eng(`
66 allow priv_app perfprofd_data_file:file r_file_perms;
67 allow priv_app perfprofd_data_file:dir r_dir_perms;
68')
69
70# Allow GMS core to scan executables on the system partition
71allow priv_app exec_type:file { getattr read open };
72
73# For AppFuse.
74allow priv_app vold:fd use;
75allow priv_app fuse_device:chr_file { read write };
76
77# /sys and /proc access
78r_dir_file(priv_app, sysfs_type)
79r_dir_file(priv_app, proc)
80r_dir_file(priv_app, rootfs)
81
82# access the mac address
83allowxperm priv_app self:udp_socket ioctl SIOCGIFHWADDR;
84
85# Allow GMS core to communicate with update_engine for A/B update.
86binder_call(priv_app, update_engine)
87allow priv_app update_engine_service:service_manager find;
88
89# Allow Phone to read/write cached ringtones (opened by system).
90allow priv_app ringtone_file:file { getattr read write };
91
92# Access to /data/preloads
93allow priv_app preloads_data_file:file r_file_perms;
94allow priv_app preloads_data_file:dir r_dir_perms;
95
96# TODO: revert this as part of fixing 33574909
97# android.process.media uses /dev/mtp_usb
98allow priv_app mtp_device:chr_file rw_file_perms;
99
100# TODO: revert this as part of fixing 33574909
101# MtpServer uses /dev/usb-ffs/mtp
102allow priv_app functionfs:dir search;
103allow priv_app functionfs:file rw_file_perms;
104
105# TODO: revert this as part of fixing 33574909
106# Traverse into /mnt/media_rw for bypassing FUSE daemon
107# TODO: narrow this to just MediaProvider
108allow priv_app mnt_media_rw_file:dir search;
109
110###
111### neverallow rules
112###
113
114# Receive or send uevent messages.
115neverallow priv_app domain:netlink_kobject_uevent_socket *;
116
117# Receive or send generic netlink messages
118neverallow priv_app domain:netlink_socket *;
119
120# Too much leaky information in debugfs. It's a security
121# best practice to ensure these files aren't readable.
122neverallow priv_app debugfs:file read;
123
124# Do not allow privileged apps to register services.
125# Only trusted components of Android should be registering
126# services.
127neverallow priv_app service_manager_type:service_manager add;
128
129# Do not allow privileged apps to connect to the property service
130# or set properties. b/10243159
131neverallow priv_app property_socket:sock_file write;
132neverallow priv_app init:unix_stream_socket connectto;
133neverallow priv_app property_type:property_service set;
134
135# Do not allow priv_app to be assigned mlstrustedsubject.
136# This would undermine the per-user isolation model being
137# enforced via levelFrom=user in seapp_contexts and the mls
138# constraints. As there is no direct way to specify a neverallow
139# on attribute assignment, this relies on the fact that fork
140# permission only makes sense within a domain (hence should
141# never be granted to any other domain within mlstrustedsubject)
142# and priv_app is allowed fork permission to itself.
143neverallow priv_app mlstrustedsubject:process fork;
144
145# Do not allow priv_app to hard link to any files.
146# In particular, if priv_app links to other app data
147# files, installd will not be able to guarantee the deletion
148# of the linked to file. Hard links also contribute to security
149# bugs, so we want to ensure priv_app never has this
150# capability.
151neverallow priv_app file_type:file link;