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