blob: 9df1a083b1191ba1875e0fb87137e2532456dd6b [file] [log] [blame]
Nick Kralevich748fdef2013-07-12 16:33:29 -07001###
2### Domain for all zygote spawned apps
3###
4### This file is the base policy for all zygote spawned apps.
5### Other policy files, such as isolated_app.te, untrusted_app.te, etc
6### extend from this policy. Only policies which should apply to ALL
7### zygote spawned apps should be added here.
8###
Stephen Smalley2dd4e512012-01-04 12:33:27 -05009
Stephen Smalleyad7df7b2013-12-20 08:24:12 -050010# Dalvik Compiler JIT Mapping.
11allow appdomain self:process execmem;
Stephen Smalleye7ec2f52013-12-23 16:18:55 -050012allow appdomain ashmem_device:chr_file execute;
Stephen Smalleyad7df7b2013-12-20 08:24:12 -050013
Nick Kralevich6634a102013-07-12 18:45:56 -070014# Receive and use open file descriptors inherited from zygote.
15allow appdomain zygote:fd use;
16
Stephen Smalley48759ca2013-10-29 14:42:39 -040017# gdbserver for ndk-gdb reads the zygote.
Nick Kralevich4fce0ef2014-05-22 15:00:25 -070018# valgrind needs mmap exec for zygote
19allow appdomain zygote_exec:file rx_file_perms;
Stephen Smalley48759ca2013-10-29 14:42:39 -040020
21# gdbserver for ndk-gdb ptrace attaches to app process.
22allow appdomain self:process ptrace;
23
Nick Kralevich6634a102013-07-12 18:45:56 -070024# Read system properties managed by zygote.
25allow appdomain zygote_tmpfs:file read;
26
27# Notify zygote of death;
28allow appdomain zygote:process sigchld;
29
Stephen Smalley48759ca2013-10-29 14:42:39 -040030# Notify shell and adbd of death when spawned via runas for ndk-gdb.
31allow appdomain shell:process sigchld;
32allow appdomain adbd:process sigchld;
33
34# child shell or gdbserver pty access for runas.
35allow appdomain devpts:chr_file { getattr read write ioctl };
36
Stephen Smalley3dad7b62014-03-05 09:50:08 -050037# Use pipes and sockets provided by system_server via binder or local socket.
Alex Klyubin1fdee112013-09-13 15:59:04 -070038allow appdomain system_server:fifo_file rw_file_perms;
Stephen Smalley3dad7b62014-03-05 09:50:08 -050039allow appdomain system_server:unix_stream_socket { read write setopt getattr getopt shutdown };
40allow appdomain system_server:tcp_socket { read write getattr getopt shutdown };
Nick Kralevich6634a102013-07-12 18:45:56 -070041
Nick Kralevich82fc3b52013-12-06 13:31:16 -080042# Communication with other apps via fifos
43allow appdomain appdomain:fifo_file rw_file_perms;
44
Nick Kralevich6634a102013-07-12 18:45:56 -070045# Communicate with surfaceflinger.
Stephen Smalleyb0db7122014-03-06 16:03:48 -050046allow appdomain surfaceflinger:unix_stream_socket { read write setopt getattr getopt shutdown };
Nick Kralevich6634a102013-07-12 18:45:56 -070047
48# App sandbox file accesses.
49allow appdomain app_data_file:dir create_dir_perms;
Stephen Smalley65317122013-12-11 09:08:09 -050050allow appdomain app_data_file:notdevfile_class_set create_file_perms;
Nick Kralevich6634a102013-07-12 18:45:56 -070051
Nick Kralevich6634a102013-07-12 18:45:56 -070052# lib subdirectory of /data/data dir is system-owned.
53allow appdomain system_data_file:dir r_dir_perms;
Nick Kralevich78706f92014-06-02 14:49:10 -070054allow appdomain system_data_file:file { execute execute_no_trans open execmod };
Nick Kralevich6634a102013-07-12 18:45:56 -070055
Jeff Sharkey6736bac2014-04-24 13:31:29 -070056# Access to OEM provided data and apps
57allow appdomain oemfs:dir r_dir_perms;
58allow appdomain oemfs:file rx_file_perms;
59
Nick Kralevich6634a102013-07-12 18:45:56 -070060# Execute the shell or other system executables.
61allow appdomain shell_exec:file rx_file_perms;
62allow appdomain system_file:file rx_file_perms;
63
64# Read/write wallpaper file (opened by system).
Robert Craigfc4c6b72014-01-23 10:05:28 -050065allow appdomain wallpaper_file:file { getattr read write };
Nick Kralevich6634a102013-07-12 18:45:56 -070066
67# Write to /data/anr/traces.txt.
68allow appdomain anr_data_file:dir search;
69allow appdomain anr_data_file:file { open append };
70
Nick Kralevich09e6abd2013-12-13 22:19:45 -080071# Allow apps to send dump information to dumpstate
72allow appdomain dumpstate:fd use;
Stephen Smalleyb0db7122014-03-06 16:03:48 -050073allow appdomain dumpstate:unix_stream_socket { read write getopt getattr shutdown };
Nick Kralevich2e7a3012014-01-10 23:05:25 -080074allow appdomain shell_data_file:file { write getattr };
Nick Kralevich09e6abd2013-12-13 22:19:45 -080075
Nick Kralevich6634a102013-07-12 18:45:56 -070076# Write to /proc/net/xt_qtaguid/ctrl file.
77allow appdomain qtaguid_proc:file rw_file_perms;
78# Everybody can read the xt_qtaguid resource tracking misc dev.
79# So allow all apps to read from /dev/xt_qtaguid.
80allow appdomain qtaguid_device:chr_file r_file_perms;
81
Stephen Smalley3ba90122013-12-12 09:09:53 -050082# Grant GPU access to all processes started by Zygote.
83# They need that to render the standard UI.
84allow appdomain gpu_device:chr_file { rw_file_perms execute };
85
Nick Kralevich6634a102013-07-12 18:45:56 -070086# Use the Binder.
87binder_use(appdomain)
88# Perform binder IPC to binder services.
89binder_call(appdomain, binderservicedomain)
90# Perform binder IPC to other apps.
91binder_call(appdomain, appdomain)
92
Nick Kralevich6634a102013-07-12 18:45:56 -070093# Already connected, unnamed sockets being passed over some other IPC
94# hence no sock_file or connectto permission. This appears to be how
95# Chrome works, may need to be updated as more apps using isolated services
96# are examined.
Stephen Smalleyb0db7122014-03-06 16:03:48 -050097allow appdomain appdomain:unix_stream_socket { getopt getattr read write shutdown };
Nick Kralevich6634a102013-07-12 18:45:56 -070098
99# Backup ability for every app. BMS opens and passes the fd
100# to any app that has backup ability. Hence, no open permissions here.
Geremy Condra81560732013-08-30 13:02:30 -0700101allow appdomain backup_data_file:file { read write getattr };
102allow appdomain cache_backup_file:file { read write getattr };
Stephen Smalley9ba844f2014-04-04 09:09:25 -0400103allow appdomain cache_backup_file:dir getattr;
Nick Kralevich6634a102013-07-12 18:45:56 -0700104# Backup ability using 'adb backup'
105allow appdomain system_data_file:lnk_file getattr;
106
Stephen Smalley2737cef2014-03-04 13:44:01 -0500107# Allow read/stat of /data/media files passed by Binder or local socket IPC.
108allow appdomain media_rw_data_file:file { read getattr };
109
Nick Kralevich1545b602014-05-05 11:04:12 -0700110# Read and write /data/data/com.android.providers.telephony files passed over Binder.
111allow appdomain radio_data_file:file { read write getattr };
Stephen Smalley3fbc5362014-03-27 09:45:26 -0400112
Stephen Smalley91a4f8d2014-05-07 13:10:02 -0400113# Read and write system app data files passed over Binder.
114# Motivating case was /data/data/com.android.settings/cache/*.jpg for
115# cropping or taking user photos.
116allow untrusted_app system_app_data_file:file { read write getattr };
117
Stephen Smalleyb0db7122014-03-06 16:03:48 -0500118# Access SDcard.
119allow appdomain sdcard_type:dir create_dir_perms;
120allow appdomain sdcard_type:file create_file_perms;
121
Nick Kralevich0b8c20e2013-10-09 12:27:27 -0700122# Allow apps to use the USB Accessory interface.
123# http://developer.android.com/guide/topics/connectivity/usb/accessory.html
124#
125# USB devices are first opened by the system server (USBDeviceManagerService)
126# and the file descriptor is passed to the right Activity via binder.
127allow appdomain usb_device:chr_file { read write getattr ioctl };
128allow appdomain usbaccessory_device:chr_file { read write getattr };
129
Stephen Smalley527316a2013-12-23 14:48:02 -0500130# For art.
131allow appdomain dalvikcache_data_file:file execute;
132
Stephen Smalley19c50902014-04-09 14:24:33 -0400133# /data/dalvik-cache/profiles
134allow appdomain dalvikcache_profiles_data_file:file write;
135
Torne (Richard Coles)9786af22014-05-23 11:01:58 +0100136# Allow any app to read shared RELRO files.
137allow appdomain shared_relro_file:dir search;
138allow appdomain shared_relro_file:file r_file_perms;
139
Christopher Tate6f6c4252014-05-30 15:21:22 -0700140# Allow apps to read/execute installed binaries
141allow appdomain apk_data_file:file { rx_file_perms execmod };
142
Nick Kralevich6634a102013-07-12 18:45:56 -0700143###
Stephen Smalley59469372013-12-16 08:55:24 -0500144### CTS-specific rules
145###
146
147# For cts/tools/device-setup/TestDeviceSetup/src/android/tests/getinfo/RootProcessScanner.java.
148# Reads /proc/pid/status and statm entries to check that
149# no unexpected root processes are running.
150# Also for cts/tests/tests/security/src/android/security/cts/VoldExploitTest.java
151# Reads /proc/pid/cmdline of vold.
152allow appdomain domain:dir { open read search getattr };
153allow appdomain domain:{ file lnk_file } { open read getattr };
154
155# For cts/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java.
156# testRunAsHasCorrectCapabilities
157allow appdomain runas_exec:file getattr;
158# Others are either allowed elsewhere or not desired.
159
160# For cts/tests/tests/security/src/android/security/cts/SELinuxTest.java
161# Check SELinux policy and contexts.
162selinux_check_access(appdomain)
163selinux_check_context(appdomain)
164# Validate that each process is running in the correct security context.
165allow appdomain domain:process getattr;
166
Mark Salyzyn8ed750e2013-11-12 15:34:52 -0800167# logd access
168read_logd(appdomain)
169# application inherit logd write socket (urge is to deprecate this long term)
170allow appdomain zygote:unix_dgram_socket write;
171
Stephen Smalley59469372013-12-16 08:55:24 -0500172###
Nick Kralevich6634a102013-07-12 18:45:56 -0700173### Neverallow rules
174###
175### These are things that Android apps should NEVER be able to do
176###
177
178# Superuser capabilities.
Stephen Smalley2a273ad2013-09-27 10:55:59 -0400179# bluetooth requires net_admin.
180neverallow { appdomain -unconfineddomain -bluetooth } self:capability *;
Nick Kralevich6634a102013-07-12 18:45:56 -0700181neverallow { appdomain -unconfineddomain } self:capability2 *;
182
183# Block device access.
184neverallow { appdomain -unconfineddomain } dev_type:blk_file { read write };
185
Stephen Smalley2a273ad2013-09-27 10:55:59 -0400186# Access to any of the following character devices.
187neverallow { appdomain -unconfineddomain } {
188 audio_device
189 camera_device
190 dm_device
191 radio_device
192 gps_device
193 rpmsg_device
194}:chr_file { read write };
195
196# Note: Try expanding list of app domains in the future.
Nick Kralevich84ed8902014-06-03 17:01:10 -0700197neverallow { untrusted_app isolated_app shell -unconfineddomain } graphics_device:chr_file { read write };
Stephen Smalley2a273ad2013-09-27 10:55:59 -0400198
199neverallow { appdomain -nfc -unconfineddomain } nfc_device:chr_file
200 { read write };
201neverallow { appdomain -bluetooth -unconfineddomain } hci_attach_dev:chr_file
202 { read write };
203neverallow { appdomain -unconfineddomain } tee_device:chr_file { read write };
204
Nick Kralevich6634a102013-07-12 18:45:56 -0700205# Privileged netlink socket interfaces.
206neverallow { appdomain -unconfineddomain }
207 self:{
208 netlink_socket
209 netlink_firewall_socket
210 netlink_tcpdiag_socket
211 netlink_nflog_socket
212 netlink_xfrm_socket
Nick Kralevich6634a102013-07-12 18:45:56 -0700213 netlink_audit_socket
214 netlink_ip6fw_socket
215 netlink_dnrt_socket
216 netlink_kobject_uevent_socket
217 } *;
218
Stephen Smalley2a273ad2013-09-27 10:55:59 -0400219# Sockets under /dev/socket that are not specifically typed.
220neverallow { appdomain -unconfineddomain } socket_device:sock_file write;
221
222# Unix domain sockets.
223neverallow { appdomain -unconfineddomain } adbd_socket:sock_file write;
Stephen Smalley2a273ad2013-09-27 10:55:59 -0400224neverallow { appdomain -unconfineddomain } installd_socket:sock_file write;
225neverallow { appdomain -bluetooth -radio -shell -system_app -unconfineddomain }
226 property_socket:sock_file write;
227neverallow { appdomain -radio -unconfineddomain } rild_socket:sock_file write;
228neverallow { appdomain -unconfineddomain } vold_socket:sock_file write;
229neverallow { appdomain -unconfineddomain } zygote_socket:sock_file write;
230
Nick Kralevich6634a102013-07-12 18:45:56 -0700231# ptrace access to non-app domains.
232neverallow { appdomain -unconfineddomain } { domain -appdomain }:process ptrace;
233
Stephen Smalley2a273ad2013-09-27 10:55:59 -0400234# Write access to /proc/pid entries for any non-app domain.
Nick Kralevich73c5ea72013-10-25 16:53:37 -0700235neverallow { appdomain -unconfineddomain } { domain -appdomain }:file write;
Stephen Smalley2a273ad2013-09-27 10:55:59 -0400236
237# signal access to non-app domains.
238# sigchld allowed for parent death notification.
239# signull allowed for kill(pid, 0) existence test.
240# All others prohibited.
241neverallow { appdomain -unconfineddomain } { domain -appdomain }:process
242 { sigkill sigstop signal };
243
Nick Kralevich6634a102013-07-12 18:45:56 -0700244# Transition to a non-app domain.
Stephen Smalley396015c2014-01-07 12:47:10 -0500245# Exception for the shell domain, can transition to runas, etc.
Stephen Smalley57085442013-09-30 08:47:54 -0400246neverallow { appdomain -shell -unconfineddomain } ~appdomain:process
Stephen Smalley2a273ad2013-09-27 10:55:59 -0400247 { transition dyntransition };
248
Stephen Smalley2a273ad2013-09-27 10:55:59 -0400249# Write to rootfs.
250neverallow { appdomain -unconfineddomain } rootfs:dir_file_class_set
251 { create write setattr relabelfrom relabelto append unlink link rename };
Nick Kralevich6634a102013-07-12 18:45:56 -0700252
253# Write to /system.
Stephen Smalley2a273ad2013-09-27 10:55:59 -0400254neverallow { appdomain -unconfineddomain } system_file:dir_file_class_set
255 { create write setattr relabelfrom relabelto append unlink link rename };
256
257# Write to entrypoint executables.
258neverallow { appdomain -unconfineddomain } exec_type:file
259 { create write setattr relabelfrom relabelto append unlink link rename };
Nick Kralevich6634a102013-07-12 18:45:56 -0700260
261# Write to system-owned parts of /data.
262# This is the default type for anything under /data not otherwise
263# specified in file_contexts. Define a different type for portions
264# that should be writable by apps.
265# Exception for system_app for Settings.
Stephen Smalley2a273ad2013-09-27 10:55:59 -0400266neverallow { appdomain -unconfineddomain -system_app }
267 system_data_file:dir_file_class_set
268 { create write setattr relabelfrom relabelto append unlink link rename };
269
270# Write to various other parts of /data.
Stephen Smalley2a273ad2013-09-27 10:55:59 -0400271neverallow { appdomain -unconfineddomain } drm_data_file:dir_file_class_set
272 { create write setattr relabelfrom relabelto append unlink link rename };
273neverallow { appdomain -unconfineddomain } gps_data_file:dir_file_class_set
274 { create write setattr relabelfrom relabelto append unlink link rename };
275neverallow { appdomain -platform_app -unconfineddomain }
276 apk_data_file:dir_file_class_set
277 { create write setattr relabelfrom relabelto append unlink link rename };
278neverallow { appdomain -platform_app -unconfineddomain }
279 apk_tmp_file:dir_file_class_set
280 { create write setattr relabelfrom relabelto append unlink link rename };
281neverallow { appdomain -platform_app -unconfineddomain }
282 apk_private_data_file:dir_file_class_set
283 { create write setattr relabelfrom relabelto append unlink link rename };
284neverallow { appdomain -platform_app -unconfineddomain }
285 apk_private_tmp_file:dir_file_class_set
286 { create write setattr relabelfrom relabelto append unlink link rename };
287neverallow { appdomain -shell -unconfineddomain }
288 shell_data_file:dir_file_class_set
Nick Kralevich2e7a3012014-01-10 23:05:25 -0800289 { create setattr relabelfrom relabelto append unlink link rename };
Stephen Smalley2a273ad2013-09-27 10:55:59 -0400290neverallow { appdomain -bluetooth -unconfineddomain }
291 bluetooth_data_file:dir_file_class_set
292 { create write setattr relabelfrom relabelto append unlink link rename };
293neverallow { appdomain -unconfineddomain }
294 keystore_data_file:dir_file_class_set
295 { create write setattr relabelfrom relabelto append unlink link rename };
296neverallow { appdomain -unconfineddomain }
297 systemkeys_data_file:dir_file_class_set
298 { create write setattr relabelfrom relabelto append unlink link rename };
299neverallow { appdomain -unconfineddomain }
300 wifi_data_file:dir_file_class_set
301 { create write setattr relabelfrom relabelto append unlink link rename };
302neverallow { appdomain -unconfineddomain }
303 dhcp_data_file:dir_file_class_set
304 { create write setattr relabelfrom relabelto append unlink link rename };
305
306# Access to factory files.
307neverallow { appdomain -unconfineddomain }
308 efs_file:dir_file_class_set { read write };
309
310# Write to various pseudo file systems.
Stephen Smalleydf8af762014-01-13 09:05:01 -0500311neverallow { appdomain -bluetooth -nfc -unconfineddomain }
Stephen Smalley2a273ad2013-09-27 10:55:59 -0400312 sysfs:dir_file_class_set write;
Stephen Smalley2a273ad2013-09-27 10:55:59 -0400313neverallow { appdomain -unconfineddomain }
314 proc:dir_file_class_set write;
315
316# Access to syslog(2) or /proc/kmsg.
Nick Kralevich685e2f92014-05-28 13:48:52 -0700317neverallow { appdomain -system_app }
Nick Kralevichf821b5a2014-05-27 16:49:59 -0700318 kernel:system { syslog_mod syslog_console };
Nick Kralevich685e2f92014-05-28 13:48:52 -0700319neverallow { appdomain -system_app -shelldomain }
Nick Kralevichf821b5a2014-05-27 16:49:59 -0700320 kernel:system syslog_read;
Stephen Smalley2a273ad2013-09-27 10:55:59 -0400321
322# Ability to perform any filesystem operation other than statfs(2).
323# i.e. no mount(2), unmount(2), etc.
324neverallow { appdomain -unconfineddomain } fs_type:filesystem ~getattr;
325
326# Ability to set system properties.
327neverallow { appdomain -system_app -radio -shell -bluetooth -unconfineddomain }
328 property_type:property_service set;