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