blob: e1525919ceac384d2abb13fd41a699f0eef19916 [file] [log] [blame]
William Hester5f486c72019-01-15 13:39:30 -08001# Allow apps to read the Test Harness Mode property. This property is used in
2# the implementation of ActivityManager.isDeviceInTestHarnessMode()
3get_prop(appdomain, test_harness_prop)
4
Inseob Kimdbcc4592020-05-21 20:12:55 +09005get_prop(appdomain, boot_status_prop)
6get_prop(appdomain, dalvik_config_prop)
Inseob Kimdddf6f52020-07-06 22:24:11 +09007get_prop(appdomain, media_config_prop)
Inseob Kim5eacf722020-07-01 01:27:49 +09008get_prop(appdomain, packagemanager_config_prop)
Inseob Kim4ae7ec12020-08-03 14:29:47 +09009get_prop(appdomain, radio_control_prop)
Inseob Kimdbcc4592020-05-21 20:12:55 +090010get_prop(appdomain, surfaceflinger_color_prop)
11get_prop(appdomain, systemsound_config_prop)
Inseob Kim641cffe2020-06-05 10:40:16 +090012get_prop(appdomain, telephony_config_prop)
Inseob Kimdbcc4592020-05-21 20:12:55 +090013get_prop(appdomain, userspace_reboot_config_prop)
14get_prop(appdomain, vold_config_prop)
Hongguang Chen67c36882020-07-27 15:15:53 -070015get_prop(appdomain, adbd_config_prop)
Thierry Strudel195149f2021-12-22 19:13:25 -080016get_prop(appdomain, dck_prop)
Evan Rosky5cfdf2b2022-03-02 22:13:58 +000017get_prop(appdomain, persist_wm_debug_prop)
Inseob Kimdbcc4592020-05-21 20:12:55 +090018
Calin Juravle0b2ca6c2021-05-18 15:33:08 -070019# Allow ART to be configurable via device_config properties
20# (ART "runs" inside the app process)
21get_prop(appdomain, device_config_runtime_native_prop)
22get_prop(appdomain, device_config_runtime_native_boot_prop)
23
Florian Mayer5e522812019-10-08 16:15:14 +010024userdebug_or_eng(`perfetto_producer({ appdomain })')
25
Jeff Vander Stoep607bc672019-12-16 10:59:03 +010026# Prevent apps from causing presubmit failures.
27# Apps can cause selinux denials by accessing CE storage
28# and/or external storage. In either case, the selinux denial is
29# not the cause of the failure, but just a symptom that
30# storage isn't ready. Many apps handle the failure appropriately.
31#
32# Apps cannot access external storage before it becomes available.
33dontaudit appdomain storage_stub_file:dir getattr;
34# Attempts to write to system_data_file is generally a sign
35# that apps are attempting to access encrypted storage before
36# the ACTION_USER_UNLOCKED intent is delivered. Apps are not
37# allowed to write to CE storage before it's available.
38# Attempting to do so will be blocked by both selinux and unix
39# permissions.
40dontaudit appdomain system_data_file:dir write;
Jeff Vander Stoep67896ee2020-04-02 13:36:17 +020041# Apps should not be reading vendor-defined properties.
42dontaudit appdomain vendor_default_prop:file read;
Jeff Vander Stoep607bc672019-12-16 10:59:03 +010043
Zimb61bcc82021-04-08 12:20:26 +010044# Access to /mnt/media_rw/<vol> (limited by DAC to apps with external_storage gid)
45allow appdomain mnt_media_rw_file:dir search;
46
Nathan Haroldee268642017-12-14 18:20:30 -080047neverallow appdomain system_server:udp_socket {
Nathan Harold252b0152018-03-27 06:34:54 -070048 accept append bind create ioctl listen lock name_bind
49 relabelfrom relabelto setattr shutdown };
Nick Kralevich1e5021c2018-11-28 17:50:24 -080050
51# Transition to a non-app domain.
52# Exception for the shell and su domains, can transition to runas, etc.
Nick Kralevich0eb0a162018-12-12 09:06:05 -080053# Exception for crash_dump to allow for app crash reporting.
54# Exception for renderscript binaries (/system/bin/bcc, /system/bin/ld.mc)
55# to allow renderscript to create privileged executable files.
56neverallow { appdomain -shell userdebug_or_eng(`-su') }
57 { domain -appdomain -crash_dump -rs }:process { transition };
58neverallow { appdomain -shell userdebug_or_eng(`-su') }
59 { domain -appdomain }:process { dyntransition };
Daniel Rosenbergafede842020-05-11 22:50:40 -070060
61# Don't allow regular apps access to storage configuration properties.
62neverallow { appdomain -mediaprovider_app } storage_config_prop:file no_rw_file_perms;
Peiyong Lin37dea072020-06-03 12:20:41 -070063
Inseob Kimc80b0242020-07-16 22:25:47 +090064# Allow to read sendbug.preferred.domain
65get_prop(appdomain, sendbug_config_prop)
66
Peiyong Lin37dea072020-06-03 12:20:41 -070067# Allow to read graphics related properties.
68get_prop(appdomain, graphics_config_prop)
Inseob Kimc97a97c2020-07-20 20:26:07 +090069
70# Allow to read persist.config.calibration_fac
71get_prop(appdomain, camera_calibration_prop)
Inseob Kim0cef0fe2020-11-17 13:54:52 +090072
73# Allow to read db.log.detailed, db.log.slow_query_threshold*
74get_prop(appdomain, sqlite_log_prop)
Orion Hodson8f75f762020-10-16 15:29:55 +010075
Seigo Nonaka9c3707f2021-01-21 13:08:31 -080076# Allow font file read by apps.
77allow appdomain font_data_file:file r_file_perms;
78allow appdomain font_data_file:dir r_dir_perms;
79
Martijn Coenen4825e862021-03-29 13:51:35 +020080# Enter /data/misc/apexdata/
81allow appdomain apex_module_data_file:dir search;
Orion Hodson13ee6532021-04-27 15:51:33 +010082# Read /data/misc/apexdata/com.android.art, execute signed AOT artifacts.
Martijn Coenen4825e862021-03-29 13:51:35 +020083allow appdomain apex_art_data_file:dir r_dir_perms;
Orion Hodson13ee6532021-04-27 15:51:33 +010084allow appdomain apex_art_data_file:file rx_file_perms;
Orion Hodson8f75f762020-10-16 15:29:55 +010085
Josh Gaoce1c4a52021-02-03 18:35:06 -080086# Allow access to tombstones if an fd to one is given to you.
87# This is restricted by unix permissions, so an app must go through system_server to get one.
88allow appdomain tombstone_data_file:file { getattr read };
89neverallow appdomain tombstone_data_file:file ~{ getattr read };
90
Nikita Ioffe269e7cf2022-01-13 22:56:14 +000091# WebView and other application-specific JIT compilers
92allow appdomain self:process execmem;
93
94allow appdomain { ashmem_device ashmem_libcutils_device }:chr_file execute;
95
96# Receive and use open file descriptors inherited from zygote.
97allow appdomain zygote:fd use;
98
99# Receive and use open file descriptors inherited from app zygote.
100allow appdomain app_zygote:fd use;
101
102# gdbserver for ndk-gdb reads the zygote.
103# valgrind needs mmap exec for zygote
104allow appdomain zygote_exec:file rx_file_perms;
105
106# Notify zygote of death;
107allow appdomain zygote:process sigchld;
108
109# Read /data/dalvik-cache.
110allow appdomain dalvikcache_data_file:dir { search getattr };
111allow appdomain dalvikcache_data_file:file r_file_perms;
112
113# Read the /sdcard and /mnt/sdcard symlinks
114allow { appdomain -isolated_app } rootfs:lnk_file r_file_perms;
115allow { appdomain -isolated_app } tmpfs:lnk_file r_file_perms;
116
117# Search /storage/emulated tmpfs mount.
118allow appdomain tmpfs:dir r_dir_perms;
119
120# Notify zygote of the wrapped process PID when using --invoke-with.
121allow appdomain zygote:fifo_file write;
122
123userdebug_or_eng(`
124 # Allow apps to create and write method traces in /data/misc/trace.
125 allow appdomain method_trace_data_file:dir w_dir_perms;
126 allow appdomain method_trace_data_file:file { create w_file_perms };
127')
128
129# Notify shell and adbd of death when spawned via runas for ndk-gdb.
130allow appdomain shell:process sigchld;
131allow appdomain adbd:process sigchld;
132
133# child shell or gdbserver pty access for runas.
134allow appdomain devpts:chr_file { getattr read write ioctl };
135
136# Use pipes and sockets provided by system_server via binder or local socket.
137allow appdomain system_server:fd use;
138allow appdomain system_server:fifo_file rw_file_perms;
139allow appdomain system_server:unix_stream_socket { read write setopt getattr getopt shutdown };
140allow appdomain system_server:tcp_socket { read write getattr getopt shutdown };
141
142# For AppFuse.
143allow appdomain vold:fd use;
144
145# Communication with other apps via fifos
146allow appdomain appdomain:fifo_file rw_file_perms;
147
148# Communicate with surfaceflinger.
149allow appdomain surfaceflinger:unix_stream_socket { read write setopt getattr getopt shutdown };
150
151# App sandbox file accesses.
152allow { appdomain -isolated_app -mlstrustedsubject } { app_data_file privapp_data_file }:dir create_dir_perms;
153allow { appdomain -isolated_app -mlstrustedsubject } { app_data_file privapp_data_file }:file create_file_perms;
154
155# Access via already open fds is ok even for mlstrustedsubject.
156allow { appdomain -isolated_app } { app_data_file privapp_data_file system_app_data_file }:file { getattr map read write };
157
158# Traverse into expanded storage
159allow appdomain mnt_expand_file:dir r_dir_perms;
160
161# Keychain and user-trusted credentials
162r_dir_file(appdomain, keychain_data_file)
163allow appdomain misc_user_data_file:dir r_dir_perms;
164allow appdomain misc_user_data_file:file r_file_perms;
165
166# TextClassifier
167r_dir_file({ appdomain -isolated_app }, textclassifier_data_file)
168
169# Access to OEM provided data and apps
170allow appdomain oemfs:dir r_dir_perms;
171allow appdomain oemfs:file rx_file_perms;
172
173# Execute the shell or other system executables.
174allow { appdomain -ephemeral_app } shell_exec:file rx_file_perms;
175allow { appdomain -ephemeral_app } toolbox_exec:file rx_file_perms;
176allow appdomain system_file:file x_file_perms;
177not_full_treble(`allow { appdomain -ephemeral_app } vendor_file:file x_file_perms;')
178
179# Renderscript needs the ability to read directories on /system
180allow appdomain system_file:dir r_dir_perms;
181allow appdomain system_file:lnk_file { getattr open read };
182# Renderscript specific permissions to open /system/vendor/lib64.
183not_full_treble(`
184 allow appdomain vendor_file_type:dir r_dir_perms;
185 allow appdomain vendor_file_type:lnk_file { getattr open read };
186')
187
188full_treble_only(`
189 # For looking up Renderscript vendor drivers
190 allow { appdomain -isolated_app } vendor_file:dir { open read };
191')
192
193# Allow apps access to /vendor/app except for privileged
194# apps which cannot be in /vendor.
195r_dir_file({ appdomain -ephemeral_app }, vendor_app_file)
196allow { appdomain -ephemeral_app } vendor_app_file:file execute;
197
198# Allow apps access to /vendor/overlay
199r_dir_file(appdomain, vendor_overlay_file)
200
201# Allow apps access to /vendor/framework
202# for vendor provided libraries.
203r_dir_file(appdomain, vendor_framework_file)
204
205# Allow apps read / execute access to vendor public libraries.
206allow appdomain {vendor_public_framework_file vendor_public_lib_file}:dir r_dir_perms;
207allow appdomain {vendor_public_framework_file vendor_public_lib_file}:file { execute read open getattr map };
208
209# Read/write wallpaper file (opened by system).
210allow appdomain wallpaper_file:file { getattr read write map };
211
212# Read/write cached ringtones (opened by system).
213allow appdomain ringtone_file:file { getattr read write map };
214
215# Read ShortcutManager icon files (opened by system).
216allow appdomain shortcut_manager_icons:file { getattr read map };
217
218# Read icon file (opened by system).
219allow appdomain icon_file:file { getattr read map };
220
221# Old stack dumping scheme : append to a global trace file (/data/anr/traces.txt).
222#
223# TODO: All of these permissions except for anr_data_file:file append can be
224# withdrawn once we've switched to the new stack dumping mechanism, see b/32064548
225# and the rules below.
226allow appdomain anr_data_file:dir search;
227allow appdomain anr_data_file:file { open append };
228
229# New stack dumping scheme : request an output FD from tombstoned via a unix
230# domain socket.
231#
232# Allow apps to connect and write to the tombstoned java trace socket in
233# order to dump their traces. Also allow them to append traces to pipes
234# created by dumptrace. (Also see the rules below where they are given
235# additional permissions to dumpstate pipes for other aspects of bug report
236# creation).
237unix_socket_connect(appdomain, tombstoned_java_trace, tombstoned)
238allow appdomain tombstoned:fd use;
239allow appdomain dumpstate:fifo_file append;
240allow appdomain incidentd:fifo_file append;
241
242# Allow apps to send dump information to dumpstate
243allow appdomain dumpstate:fd use;
244allow appdomain dumpstate:unix_stream_socket { read write getopt getattr shutdown };
245allow appdomain dumpstate:fifo_file { write getattr };
246allow appdomain shell_data_file:file { write getattr };
247
248# Allow apps to send dump information to incidentd
249allow appdomain incidentd:fd use;
250allow appdomain incidentd:fifo_file { write getattr };
251
252# Allow apps to send information to statsd socket.
253unix_socket_send(appdomain, statsdw, statsd)
254
255# Write profiles /data/misc/profiles
256allow appdomain user_profile_root_file:dir search;
257allow appdomain user_profile_data_file:dir { search write add_name };
258allow appdomain user_profile_data_file:file create_file_perms;
259
260# Send heap dumps to system_server via an already open file descriptor
261# % adb shell am set-watch-heap com.android.systemui 1048576
262# % adb shell dumpsys procstats --start-testing
263# debuggable builds only.
264userdebug_or_eng(`
265 allow appdomain heapdump_data_file:file append;
266')
267
268# /proc/net access.
269# TODO(b/9496886) Audit access for removal.
270# proc_net access for the negated domains below is granted (or not) in their
271# individual .te files.
272r_dir_file({
273 appdomain
274 -ephemeral_app
275 -isolated_app
276 -platform_app
277 -priv_app
278 -shell
279 -system_app
280 -untrusted_app_all
281}, proc_net_type)
282# audit access for all these non-core app domains.
283userdebug_or_eng(`
284 auditallow {
285 appdomain
286 -ephemeral_app
287 -isolated_app
288 -platform_app
289 -priv_app
290 -shell
291 -su
292 -system_app
293 -untrusted_app_all
294 } proc_net_type:{ dir file lnk_file } { getattr open read };
295')
296
297# Grant GPU access to all processes started by Zygote.
298# They need that to render the standard UI.
299allow { appdomain -isolated_app } gpu_device:chr_file rw_file_perms;
300
301# Use the Binder.
302binder_use(appdomain)
303# Perform binder IPC to binder services.
304binder_call(appdomain, binderservicedomain)
305# Perform binder IPC to other apps.
306binder_call(appdomain, appdomain)
307# Perform binder IPC to ephemeral apps.
308binder_call(appdomain, ephemeral_app)
309# Perform binder IPC to gpuservice.
310binder_call({ appdomain -isolated_app }, gpuservice)
311
312# Talk with graphics composer fences
313allow appdomain hal_graphics_composer:fd use;
314
315# Already connected, unnamed sockets being passed over some other IPC
316# hence no sock_file or connectto permission. This appears to be how
317# Chrome works, may need to be updated as more apps using isolated services
318# are examined.
319allow appdomain appdomain:unix_stream_socket { getopt getattr read write shutdown };
320
321# Backup ability for every app. BMS opens and passes the fd
322# to any app that has backup ability. Hence, no open permissions here.
323allow appdomain backup_data_file:file { read write getattr map };
324allow appdomain cache_backup_file:file { read write getattr map };
325allow appdomain cache_backup_file:dir getattr;
326# Backup ability using 'adb backup'
327allow appdomain system_data_file:lnk_file r_file_perms;
328allow appdomain system_data_file:file { getattr read map };
329
330# Allow read/stat of /data/media files passed by Binder or local socket IPC.
331allow { appdomain -isolated_app } media_rw_data_file:file { read getattr };
332
333# Read and write /data/data/com.android.providers.telephony files passed over Binder.
334allow { appdomain -isolated_app } radio_data_file:file { read write getattr };
335
336# Allow access to external storage; we have several visible mount points under /storage
337# and symlinks to primary storage at places like /storage/sdcard0 and /mnt/user/0/primary
338allow { appdomain -isolated_app -ephemeral_app } storage_file:dir r_dir_perms;
339allow { appdomain -isolated_app -ephemeral_app } storage_file:lnk_file r_file_perms;
340allow { appdomain -isolated_app -ephemeral_app } mnt_user_file:dir r_dir_perms;
341allow { appdomain -isolated_app -ephemeral_app } mnt_user_file:lnk_file r_file_perms;
342
343# Read/write visible storage
344allow { appdomain -isolated_app -ephemeral_app } { sdcard_type fuse }:dir create_dir_perms;
345allow { appdomain -isolated_app -ephemeral_app } { sdcard_type fuse }:file create_file_perms;
346# This should be removed if sdcardfs is modified to alter the secontext for its
347# accesses to the underlying FS.
348allow { appdomain -isolated_app -ephemeral_app } media_rw_data_file:dir create_dir_perms;
349allow { appdomain -isolated_app -ephemeral_app } media_rw_data_file:file create_file_perms;
350
351# Allow apps to use the USB Accessory interface.
352# http://developer.android.com/guide/topics/connectivity/usb/accessory.html
353#
354# USB devices are first opened by the system server (USBDeviceManagerService)
355# and the file descriptor is passed to the right Activity via binder.
356allow { appdomain -isolated_app -ephemeral_app } usb_device:chr_file { read write getattr ioctl };
357allow { appdomain -isolated_app -ephemeral_app } usbaccessory_device:chr_file { read write getattr };
358
359# For art.
360allow appdomain dalvikcache_data_file:file execute;
361allow appdomain dalvikcache_data_file:lnk_file r_file_perms;
362
363# Allow any app to read shared RELRO files.
364allow appdomain shared_relro_file:dir search;
365allow appdomain shared_relro_file:file r_file_perms;
366
367# Allow apps to read/execute installed binaries
368allow appdomain apk_data_file:dir r_dir_perms;
369allow appdomain apk_data_file:file rx_file_perms;
370
371# /data/resource-cache
372allow appdomain resourcecache_data_file:file r_file_perms;
373allow appdomain resourcecache_data_file:dir r_dir_perms;
374
375# logd access
376read_logd(appdomain)
377control_logd({ appdomain -ephemeral_app })
378# application inherit logd write socket (urge is to deprecate this long term)
379allow appdomain zygote:unix_dgram_socket write;
380
381allow { appdomain -isolated_app -ephemeral_app } keystore:keystore_key { get_state get insert delete exist list sign verify };
382allow { appdomain -isolated_app -ephemeral_app } keystore:keystore2_key { delete use get_info rebind update };
383
384allow { appdomain -isolated_app -ephemeral_app } keystore_maintenance_service:service_manager find;
385allow { appdomain -isolated_app -ephemeral_app } keystore:keystore2 get_state;
386
387use_keystore({ appdomain -isolated_app -ephemeral_app })
388
389use_credstore({ appdomain -isolated_app -ephemeral_app })
390
391allow appdomain console_device:chr_file { read write };
392
393# only allow unprivileged socket ioctl commands
394allowxperm { appdomain -bluetooth } self:{ rawip_socket tcp_socket udp_socket }
395 ioctl { unpriv_sock_ioctls unpriv_tty_ioctls };
396
397allow { appdomain -isolated_app } ion_device:chr_file r_file_perms;
398allow { appdomain -isolated_app } dmabuf_system_heap_device:chr_file r_file_perms;
399allow { appdomain -isolated_app } dmabuf_system_secure_heap_device:chr_file r_file_perms;
400
401# Allow AAudio apps to use shared memory file descriptors from the HAL
402allow { appdomain -isolated_app } hal_audio:fd use;
403
404# Allow app to access shared memory created by camera HAL1
405allow { appdomain -isolated_app } hal_camera:fd use;
406
407# Allow apps to access shared memory file descriptor from the tuner HAL
408allow {appdomain -isolated_app} hal_tv_tuner_server:fd use;
409
410# RenderScript always-passthrough HAL
411allow { appdomain -isolated_app } hal_renderscript_hwservice:hwservice_manager find;
412allow appdomain same_process_hal_file:file { execute read open getattr map };
413
414# TODO: switch to meminfo service
415allow appdomain proc_meminfo:file r_file_perms;
416
417# For app fuse.
418allow appdomain app_fuse_file:file { getattr read append write map };
419
420pdx_client({ appdomain -isolated_app -ephemeral_app }, display_client)
421pdx_client({ appdomain -isolated_app -ephemeral_app }, display_manager)
422pdx_client({ appdomain -isolated_app -ephemeral_app }, display_vsync)
423pdx_client({ appdomain -isolated_app -ephemeral_app }, performance_client)
424# Apps do not directly open the IPC socket for bufferhubd.
425pdx_use({ appdomain -isolated_app -ephemeral_app }, bufferhub_client)
426
427###
428### CTS-specific rules
429###
430
431# For cts/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java.
432# testRunAsHasCorrectCapabilities
433allow appdomain runas_exec:file getattr;
434# Others are either allowed elsewhere or not desired.
435
436# Apps receive an open tun fd from the framework for
437# device traffic. Do not allow untrusted app to directly open tun_device
438allow { appdomain -isolated_app -ephemeral_app } tun_device:chr_file { read write getattr append ioctl };
439allowxperm { appdomain -isolated_app -ephemeral_app } tun_device:chr_file ioctl TUNGETIFF;
440
441# Connect to adbd and use a socket transferred from it.
442# This is used for e.g. adb backup/restore.
443allow appdomain adbd:unix_stream_socket connectto;
444allow appdomain adbd:fd use;
445allow appdomain adbd:unix_stream_socket { getattr getopt ioctl read write shutdown };
446
447allow appdomain cache_file:dir getattr;
448
449# Allow apps to run with asanwrapper.
450with_asan(`allow appdomain asanwrapper_exec:file rx_file_perms;')
451
452# Read access to FDs from the DropboxManagerService.
453allow appdomain dropbox_data_file:file { getattr read };
454
455# Read tmpfs types from these processes.
456allow appdomain audioserver_tmpfs:file { getattr map read write };
457allow appdomain system_server_tmpfs:file { getattr map read write };
458allow appdomain zygote_tmpfs:file { map read };
459
Orion Hodson8f75f762020-10-16 15:29:55 +0100460# Sensitive app domains are not allowed to execute from /data
461# to prevent persistence attacks and ensure all code is executed
462# from read-only locations.
463neverallow {
464 bluetooth
465 isolated_app
466 nfc
467 radio
468 shared_relro
469 system_app
470} {
471 data_file_type
472 -apex_art_data_file
473 -dalvikcache_data_file
474 -system_data_file # shared libs in apks
475 -apk_data_file
476}:file no_x_file_perms;
Tianjieb729aa62021-10-05 22:13:20 -0700477
478# For now, don't allow apps other than gmscore to access /data/misc_ce/<userid>/checkin
479neverallow { appdomain -gmscore_app } checkin_data_file:dir *;
480neverallow { appdomain -gmscore_app } checkin_data_file:file *;