app.te 6.67 KB
Newer Older
Stephen Smalley's avatar
Stephen Smalley committed
1 2 3 4 5 6
#
# Domains for apps that do not run with one of the predefined
# platform UIDs (system, radio, nfc, ...).
#

#
7
# Apps signed with the platform key.
Stephen Smalley's avatar
Stephen Smalley committed
8
#
9
type platform_app, domain;
10
permissive platform_app;
11
app_domain(platform_app)
12
platform_app_domain(platform_app)
Stephen Smalley's avatar
Stephen Smalley committed
13
# Access the network.
14
net_domain(platform_app)
Stephen Smalley's avatar
Stephen Smalley committed
15
# Access bluetooth.
16
bluetooth_domain(platform_app)
Stephen Smalley's avatar
Stephen Smalley committed
17
# Write to /cache.
18 19
allow platform_app cache_file:dir rw_dir_perms;
allow platform_app cache_file:file create_file_perms;
Stephen Smalley's avatar
Stephen Smalley committed
20
# Read from /data/local.
21 22 23
allow platform_app shell_data_file:dir search;
allow platform_app shell_data_file:file { open getattr read };
allow platform_app shell_data_file:lnk_file read;
24 25 26 27
# Populate /data/app/vmdl*.tmp, /data/app-private/vmdl*.tmp files
# created by system server.
allow platform_app { apk_tmp_file apk_private_tmp_file }:file rw_file_perms;
allow platform_app apk_private_data_file:dir search;
28 29 30
# ASEC
allow platform_app asec_apk_file:dir create_dir_perms;
allow platform_app asec_apk_file:file create_file_perms;
Geremy Condra's avatar
Geremy Condra committed
31
allow platform_app download_file:file rw_file_perms;
32 33 34

# Apps signed with the media key.
type media_app, domain;
35
permissive media_app;
36
app_domain(media_app)
37
platform_app_domain(media_app)
38 39 40 41 42 43 44
# Access the network.
net_domain(media_app)
# Access /dev/mtp_usb.
allow media_app mtp_device:chr_file rw_file_perms;
# Write to /cache.
allow media_app cache_file:dir rw_dir_perms;
allow media_app cache_file:file create_file_perms;
45 46 47 48 49 50
# Stat /cache/lost+found
allow media_app unlabeled:file getattr;
allow media_app unlabeled:dir getattr;
# Stat /cache/backup
allow media_app cache_backup_file:file getattr;
allow media_app cache_backup_file:dir getattr;
Geremy Condra's avatar
Geremy Condra committed
51 52 53 54 55
# Read files in the rootdir
allow media_app rootfs:file r_file_perms;
# Allow platform apps to mark platform app data files as download files
allow media_app platform_app_data_file:dir relabelfrom;
allow media_app download_file:dir relabelto;
56

57 58
# Apps signed with the shared key.
type shared_app, domain;
59
permissive shared_app;
60
app_domain(shared_app)
61
platform_app_domain(shared_app)
62 63 64 65
# Access the network.
net_domain(shared_app)
# Access bluetooth.
bluetooth_domain(shared_app)
66
# ASEC
67
r_dir_file(shared_app, asec_apk_file)
68 69 70

# Apps signed with the release key (testkey in AOSP).
type release_app, domain;
71
permissive release_app;
72
app_domain(release_app)
73
platform_app_domain(release_app)
74 75 76 77
# Access the network.
net_domain(release_app)
# Access bluetooth.
bluetooth_domain(release_app)
Stephen Smalley's avatar
Stephen Smalley committed
78

79
# Services with isolatedProcess=true in their manifest.
80 81 82
# In order for isolated_apps to interact with apps that have levelFromUid=true
# set it must be an mlstrustedsubject.
type isolated_app, domain, mlstrustedsubject;
83
permissive isolated_app;
84 85
app_domain(isolated_app)

86 87 88 89 90 91 92
#
# Rules for platform app domains.
#

# App sandbox file accesses.
allow platformappdomain platform_app_data_file:dir create_dir_perms;
allow platformappdomain platform_app_data_file:notdevfile_class_set create_file_perms;
93
# App sdcard file accesses
94 95
allow platformappdomain sdcard_type:dir create_dir_perms;
allow platformappdomain sdcard_type:file create_file_perms;
96

Geremy Condra's avatar
Geremy Condra committed
97

Stephen Smalley's avatar
Stephen Smalley committed
98 99 100 101
#
# Untrusted apps.
#
type untrusted_app, domain;
102
permissive untrusted_app;
Stephen Smalley's avatar
Stephen Smalley committed
103
app_domain(untrusted_app)
104 105
net_domain(untrusted_app)
bluetooth_domain(untrusted_app)
Robert Craig's avatar
Robert Craig committed
106
allow untrusted_app tun_device:chr_file rw_file_perms;
107

108 109 110 111 112 113 114 115 116 117 118
# Internal SDCard rw access.
bool app_internal_sdcard_rw true;
if (app_internal_sdcard_rw) {
allow untrusted_app sdcard_internal:dir create_dir_perms;
allow untrusted_app sdcard_internal:file create_file_perms;
}
# External SDCard rw access.
bool app_external_sdcard_rw true;
if (app_external_sdcard_rw) {
allow untrusted_app sdcard_external:dir create_dir_perms;
allow untrusted_app sdcard_external:file create_file_perms;
Stephen Smalley's avatar
Stephen Smalley committed
119 120 121 122 123 124
}

#
# Rules for all app domains.
#

125 126 127
# Allow apps to connect to the keystore
unix_socket_connect(appdomain, keystore, keystore)

Stephen Smalley's avatar
Stephen Smalley committed
128 129 130 131 132 133 134 135 136
# Receive and use open file descriptors inherited from zygote.
allow appdomain zygote:fd use;

# Read system properties managed by zygote.
allow appdomain zygote_tmpfs:file read;

# Notify zygote of death;
allow appdomain zygote:process sigchld;

137
# Communicate over a FIFO or socket created by the system_server.
Stephen Smalley's avatar
Stephen Smalley committed
138
allow appdomain system:fifo_file rw_file_perms;
139
allow appdomain system:unix_stream_socket { read write setopt };
140 141 142

# Communicate over a socket created by surfaceflinger.
allow appdomain surfaceflinger:unix_stream_socket { read write setopt };
Stephen Smalley's avatar
Stephen Smalley committed
143 144 145 146 147

# App sandbox file accesses.
allow appdomain app_data_file:dir create_dir_perms;
allow appdomain app_data_file:notdevfile_class_set create_file_perms;

148 149
# Read/write data files created by the platform apps if they
# were passed to the app via binder or local IPC.  Do not allow open.
150
allow appdomain platform_app_data_file:file { getattr read write };
151

Stephen Smalley's avatar
Stephen Smalley committed
152 153
# lib subdirectory of /data/data dir is system-owned.
allow appdomain system_data_file:dir r_dir_perms;
154
allow appdomain system_data_file:file { execute open };
Stephen Smalley's avatar
Stephen Smalley committed
155

156 157 158 159
# Execute the shell or other system executables.
allow appdomain shell_exec:file rx_file_perms;
allow appdomain system_file:file rx_file_perms;

160 161 162
# Read/write wallpaper file (opened by system).
allow appdomain wallpaper_file:file { read write };

163 164 165 166
# Write to /data/anr/traces.txt.
allow appdomain anr_data_file:dir search;
allow appdomain anr_data_file:file { open append };

167
# Write to /proc/net/xt_qtaguid/ctrl file.
168
allow appdomain qtaguid_proc:file rw_file_perms;
169 170 171
# Everybody can read the xt_qtaguid resource tracking misc dev.
# So allow all apps to read from /dev/xt_qtaguid.
allow appdomain qtaguid_device:chr_file r_file_perms;
172

Stephen Smalley's avatar
Stephen Smalley committed
173 174 175 176
# Use the Binder.
binder_use(appdomain)
# Perform binder IPC to binder services.
binder_call(appdomain, binderservicedomain)
177 178
# Perform binder IPC to other apps.
binder_call(appdomain, appdomain)
179 180 181 182 183 184 185 186 187 188

# Appdomain interaction with isolated apps
r_dir_file(appdomain, isolated_app)

# Already connected, unnamed sockets being passed over some other IPC
# hence no sock_file or connectto permission. This appears to be how
# Chrome works, may need to be updated as more apps using isolated services
# are examined.
allow appdomain isolated_app:unix_stream_socket { read write };
allow isolated_app appdomain:unix_stream_socket { read write };
rpcraig's avatar
rpcraig committed
189 190 191 192 193 194 195

# Backup ability for every app. BMS opens and passes the fd
# to any app that has backup ability. Hence, no open permissions here.
allow { appdomain isolated_app } backup_data_file:file { read write };
allow { appdomain isolated_app } cache_backup_file:file { read write };
# Backup ability using 'adb backup'
allow { appdomain isolated_app } system_data_file:lnk_file getattr;
Geremy Condra's avatar
Geremy Condra committed
196 197 198 199

# Allow all applications to read downloaded files
allow appdomain download_file:file r_file_perms;
file_type_auto_trans(appdomain, download_file, download_file)
repo sync's avatar
repo sync committed
200 201 202 203

# ASEC
allow untrusted_app asec_apk_file:dir { getattr };
allow untrusted_app asec_apk_file:file r_file_perms;