RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 1 | # /proc/net access. |
| 2 | # TODO(b/9496886) Audit access for removal. |
| 3 | # proc_net access for the negated domains below is granted (or not) in their |
| 4 | # individual .te files. |
| 5 | r_dir_file({ |
| 6 | appdomain |
| 7 | -ephemeral_app |
Charles Chen | ccf8014 | 2023-01-20 03:34:19 +0000 | [diff] [blame] | 8 | -isolated_app_all |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 9 | -platform_app |
| 10 | -priv_app |
| 11 | -shell |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 12 | -sdk_sandbox_all |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 13 | -system_app |
| 14 | -untrusted_app_all |
| 15 | }, proc_net_type) |
| 16 | # audit access for all these non-core app domains. |
| 17 | userdebug_or_eng(` |
| 18 | auditallow { |
| 19 | appdomain |
| 20 | -ephemeral_app |
Charles Chen | ccf8014 | 2023-01-20 03:34:19 +0000 | [diff] [blame] | 21 | -isolated_app_all |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 22 | -platform_app |
| 23 | -priv_app |
| 24 | -shell |
| 25 | -su |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 26 | -sdk_sandbox_all |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 27 | -system_app |
| 28 | -untrusted_app_all |
| 29 | } proc_net_type:{ dir file lnk_file } { getattr open read }; |
| 30 | ') |
| 31 | |
William Hester | 5f486c7 | 2019-01-15 13:39:30 -0800 | [diff] [blame] | 32 | # Allow apps to read the Test Harness Mode property. This property is used in |
| 33 | # the implementation of ActivityManager.isDeviceInTestHarnessMode() |
| 34 | get_prop(appdomain, test_harness_prop) |
| 35 | |
Inseob Kim | dbcc459 | 2020-05-21 20:12:55 +0900 | [diff] [blame] | 36 | get_prop(appdomain, boot_status_prop) |
Jiakai Zhang | 22fb5c7 | 2023-03-30 15:50:05 +0100 | [diff] [blame] | 37 | get_prop(appdomain, dalvik_config_prop_type) |
Inseob Kim | dddf6f5 | 2020-07-06 22:24:11 +0900 | [diff] [blame] | 38 | get_prop(appdomain, media_config_prop) |
Inseob Kim | 5eacf72 | 2020-07-01 01:27:49 +0900 | [diff] [blame] | 39 | get_prop(appdomain, packagemanager_config_prop) |
Inseob Kim | 4ae7ec1 | 2020-08-03 14:29:47 +0900 | [diff] [blame] | 40 | get_prop(appdomain, radio_control_prop) |
Inseob Kim | dbcc459 | 2020-05-21 20:12:55 +0900 | [diff] [blame] | 41 | get_prop(appdomain, surfaceflinger_color_prop) |
| 42 | get_prop(appdomain, systemsound_config_prop) |
Inseob Kim | 641cffe | 2020-06-05 10:40:16 +0900 | [diff] [blame] | 43 | get_prop(appdomain, telephony_config_prop) |
Inseob Kim | dbcc459 | 2020-05-21 20:12:55 +0900 | [diff] [blame] | 44 | get_prop(appdomain, userspace_reboot_config_prop) |
| 45 | get_prop(appdomain, vold_config_prop) |
Hongguang Chen | 67c3688 | 2020-07-27 15:15:53 -0700 | [diff] [blame] | 46 | get_prop(appdomain, adbd_config_prop) |
Thierry Strudel | f4e3b06 | 2021-12-22 19:13:25 -0800 | [diff] [blame] | 47 | get_prop(appdomain, dck_prop) |
Evan Rosky | 5cfdf2b | 2022-03-02 22:13:58 +0000 | [diff] [blame] | 48 | get_prop(appdomain, persist_wm_debug_prop) |
Alexander Roederer | 829d974 | 2023-03-23 02:19:22 +0000 | [diff] [blame] | 49 | get_prop(appdomain, persist_sysui_builder_extras_prop) |
Alexander Roederer | 584a862 | 2023-05-31 21:25:50 +0000 | [diff] [blame] | 50 | get_prop(appdomain, persist_sysui_ranking_update_prop) |
Inseob Kim | dbcc459 | 2020-05-21 20:12:55 +0900 | [diff] [blame] | 51 | |
Ioannis Ilkos | 8d168e2 | 2023-02-10 17:52:19 +0000 | [diff] [blame] | 52 | # Allow the heap dump ART plugin to the count of sessions waiting for OOME |
| 53 | get_prop(appdomain, traced_oome_heap_session_count_prop) |
| 54 | |
Sandro | 080c579 | 2022-11-03 14:44:35 +0000 | [diff] [blame] | 55 | # Allow to read ro.vendor.camera.extensions.enabled |
| 56 | get_prop(appdomain, camera2_extensions_prop) |
| 57 | |
| 58 | # Allow to ro.camerax.extensions.enabled |
| 59 | get_prop(appdomain, camerax_extensions_prop) |
| 60 | |
Jeff Vander Stoep | 607bc67 | 2019-12-16 10:59:03 +0100 | [diff] [blame] | 61 | # Prevent apps from causing presubmit failures. |
| 62 | # Apps can cause selinux denials by accessing CE storage |
| 63 | # and/or external storage. In either case, the selinux denial is |
| 64 | # not the cause of the failure, but just a symptom that |
| 65 | # storage isn't ready. Many apps handle the failure appropriately. |
| 66 | # |
| 67 | # Apps cannot access external storage before it becomes available. |
| 68 | dontaudit appdomain storage_stub_file:dir getattr; |
| 69 | # Attempts to write to system_data_file is generally a sign |
| 70 | # that apps are attempting to access encrypted storage before |
| 71 | # the ACTION_USER_UNLOCKED intent is delivered. Apps are not |
| 72 | # allowed to write to CE storage before it's available. |
| 73 | # Attempting to do so will be blocked by both selinux and unix |
| 74 | # permissions. |
| 75 | dontaudit appdomain system_data_file:dir write; |
Jeff Vander Stoep | 67896ee | 2020-04-02 13:36:17 +0200 | [diff] [blame] | 76 | # Apps should not be reading vendor-defined properties. |
| 77 | dontaudit appdomain vendor_default_prop:file read; |
Jeff Vander Stoep | 607bc67 | 2019-12-16 10:59:03 +0100 | [diff] [blame] | 78 | |
Zim | b61bcc8 | 2021-04-08 12:20:26 +0100 | [diff] [blame] | 79 | # Access to /mnt/media_rw/<vol> (limited by DAC to apps with external_storage gid) |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 80 | allow { appdomain -sdk_sandbox_all } mnt_media_rw_file:dir search; |
Zim | b61bcc8 | 2021-04-08 12:20:26 +0100 | [diff] [blame] | 81 | |
Jeff Vander Stoep | 7295721 | 2022-07-01 10:08:34 +0200 | [diff] [blame] | 82 | # allow apps to use UDP sockets provided by the system server but not |
| 83 | # modify them other than to connect |
| 84 | allow appdomain system_server:udp_socket { |
| 85 | connect getattr read recvfrom sendto write getopt setopt }; |
| 86 | |
Nathan Harold | ee26864 | 2017-12-14 18:20:30 -0800 | [diff] [blame] | 87 | neverallow appdomain system_server:udp_socket { |
Nathan Harold | 252b015 | 2018-03-27 06:34:54 -0700 | [diff] [blame] | 88 | accept append bind create ioctl listen lock name_bind |
| 89 | relabelfrom relabelto setattr shutdown }; |
Nick Kralevich | 1e5021c | 2018-11-28 17:50:24 -0800 | [diff] [blame] | 90 | |
| 91 | # Transition to a non-app domain. |
| 92 | # Exception for the shell and su domains, can transition to runas, etc. |
Nick Kralevich | 0eb0a16 | 2018-12-12 09:06:05 -0800 | [diff] [blame] | 93 | # Exception for crash_dump to allow for app crash reporting. |
| 94 | # Exception for renderscript binaries (/system/bin/bcc, /system/bin/ld.mc) |
| 95 | # to allow renderscript to create privileged executable files. |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 96 | # Exception for virtualizationmanager to allow running VMs as child processes. |
Nick Kralevich | 0eb0a16 | 2018-12-12 09:06:05 -0800 | [diff] [blame] | 97 | neverallow { appdomain -shell userdebug_or_eng(`-su') } |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 98 | { domain -appdomain -crash_dump -rs -virtualizationmanager }:process { transition }; |
Nick Kralevich | 0eb0a16 | 2018-12-12 09:06:05 -0800 | [diff] [blame] | 99 | neverallow { appdomain -shell userdebug_or_eng(`-su') } |
| 100 | { domain -appdomain }:process { dyntransition }; |
Daniel Rosenberg | afede84 | 2020-05-11 22:50:40 -0700 | [diff] [blame] | 101 | |
| 102 | # Don't allow regular apps access to storage configuration properties. |
| 103 | neverallow { appdomain -mediaprovider_app } storage_config_prop:file no_rw_file_perms; |
Peiyong Lin | 37dea07 | 2020-06-03 12:20:41 -0700 | [diff] [blame] | 104 | |
Seigo Nonaka | d570a5c | 2023-07-21 14:29:24 +0900 | [diff] [blame] | 105 | # Don't allow apps reading /system/etc/font_fallback.xml |
| 106 | dontaudit appdomain system_font_fallback_file:file no_rw_file_perms; |
| 107 | neverallow appdomain system_font_fallback_file:file no_rw_file_perms; |
| 108 | |
Inseob Kim | c80b024 | 2020-07-16 22:25:47 +0900 | [diff] [blame] | 109 | # Allow to read sendbug.preferred.domain |
| 110 | get_prop(appdomain, sendbug_config_prop) |
| 111 | |
Peiyong Lin | 37dea07 | 2020-06-03 12:20:41 -0700 | [diff] [blame] | 112 | # Allow to read graphics related properties. |
| 113 | get_prop(appdomain, graphics_config_prop) |
Inseob Kim | c97a97c | 2020-07-20 20:26:07 +0900 | [diff] [blame] | 114 | |
| 115 | # Allow to read persist.config.calibration_fac |
| 116 | get_prop(appdomain, camera_calibration_prop) |
Inseob Kim | 0cef0fe | 2020-11-17 13:54:52 +0900 | [diff] [blame] | 117 | |
| 118 | # Allow to read db.log.detailed, db.log.slow_query_threshold* |
| 119 | get_prop(appdomain, sqlite_log_prop) |
Orion Hodson | 8f75f76 | 2020-10-16 15:29:55 +0100 | [diff] [blame] | 120 | |
Felipe Leme | b85242c | 2022-04-21 17:49:05 -0700 | [diff] [blame] | 121 | # Allow to read system_user_mode_emulation_prop, which is used by UserManager.java |
| 122 | userdebug_or_eng(`get_prop(appdomain, system_user_mode_emulation_prop)') |
| 123 | |
Seigo Nonaka | 9c3707f | 2021-01-21 13:08:31 -0800 | [diff] [blame] | 124 | # Allow font file read by apps. |
| 125 | allow appdomain font_data_file:file r_file_perms; |
| 126 | allow appdomain font_data_file:dir r_dir_perms; |
| 127 | |
Martijn Coenen | 4825e86 | 2021-03-29 13:51:35 +0200 | [diff] [blame] | 128 | # Enter /data/misc/apexdata/ |
| 129 | allow appdomain apex_module_data_file:dir search; |
Orion Hodson | 13ee653 | 2021-04-27 15:51:33 +0100 | [diff] [blame] | 130 | # Read /data/misc/apexdata/com.android.art, execute signed AOT artifacts. |
Martijn Coenen | 4825e86 | 2021-03-29 13:51:35 +0200 | [diff] [blame] | 131 | allow appdomain apex_art_data_file:dir r_dir_perms; |
Orion Hodson | 13ee653 | 2021-04-27 15:51:33 +0100 | [diff] [blame] | 132 | allow appdomain apex_art_data_file:file rx_file_perms; |
Orion Hodson | 8f75f76 | 2020-10-16 15:29:55 +0100 | [diff] [blame] | 133 | |
Josh Gao | ce1c4a5 | 2021-02-03 18:35:06 -0800 | [diff] [blame] | 134 | # Allow access to tombstones if an fd to one is given to you. |
| 135 | # This is restricted by unix permissions, so an app must go through system_server to get one. |
| 136 | allow appdomain tombstone_data_file:file { getattr read }; |
| 137 | neverallow appdomain tombstone_data_file:file ~{ getattr read }; |
| 138 | |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 139 | # Execute the shell or other system executables. |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 140 | allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } shell_exec:file rx_file_perms; |
| 141 | allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } toolbox_exec:file rx_file_perms; |
| 142 | not_full_treble(`allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } vendor_file:file x_file_perms;') |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 143 | |
| 144 | # Allow apps access to /vendor/app except for privileged |
| 145 | # apps which cannot be in /vendor. |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 146 | r_dir_file({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all }, vendor_app_file) |
| 147 | allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } vendor_app_file:file execute; |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 148 | |
Nikita Ioffe | e2da633 | 2022-02-21 17:55:59 +0000 | [diff] [blame] | 149 | # Perform binder IPC to sdk sandbox. |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 150 | binder_call(appdomain, sdk_sandbox_all) |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 151 | |
Jan Sebechlebsky | 6e1795c | 2023-12-06 09:31:17 +0100 | [diff] [blame] | 152 | # Allow apps to communicate via binder with virtual camera service. |
| 153 | binder_call(appdomain, virtual_camera) |
| 154 | |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 155 | # Allow access to external storage; we have several visible mount points under /storage |
| 156 | # and symlinks to primary storage at places like /storage/sdcard0 and /mnt/user/0/primary |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 157 | allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } storage_file:dir r_dir_perms; |
| 158 | allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } storage_file:lnk_file r_file_perms; |
| 159 | allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } mnt_user_file:dir r_dir_perms; |
| 160 | allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } mnt_user_file:lnk_file r_file_perms; |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 161 | |
| 162 | # Read/write visible storage |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 163 | allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } { sdcard_type fuse }:dir create_dir_perms; |
| 164 | allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } { sdcard_type fuse }:file create_file_perms; |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 165 | # This should be removed if sdcardfs is modified to alter the secontext for its |
| 166 | # accesses to the underlying FS. |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 167 | allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } media_rw_data_file:dir create_dir_perms; |
| 168 | allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } media_rw_data_file:file create_file_perms; |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 169 | |
| 170 | # Allow apps to use the USB Accessory interface. |
| 171 | # http://developer.android.com/guide/topics/connectivity/usb/accessory.html |
| 172 | # |
| 173 | # USB devices are first opened by the system server (USBDeviceManagerService) |
| 174 | # and the file descriptor is passed to the right Activity via binder. |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 175 | allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } usb_device:chr_file { read write getattr ioctl }; |
| 176 | allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } usbaccessory_device:chr_file { read write getattr }; |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 177 | |
| 178 | #logd access |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 179 | control_logd({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all }) |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 180 | |
| 181 | # application inherit logd write socket (urge is to deprecate this long term) |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 182 | allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } keystore:keystore2_key { delete use get_info rebind update }; |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 183 | |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 184 | allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } keystore_maintenance_service:service_manager find; |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 185 | |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 186 | use_keystore({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all }) |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 187 | |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 188 | use_credstore({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all }) |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 189 | |
| 190 | # For app fuse. |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 191 | pdx_client({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all }, display_client) |
| 192 | pdx_client({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all }, display_manager) |
| 193 | pdx_client({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all }, display_vsync) |
| 194 | pdx_client({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all }, performance_client) |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 195 | # Apps do not directly open the IPC socket for bufferhubd. |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 196 | pdx_use({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all }, bufferhub_client) |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 197 | |
| 198 | # Apps receive an open tun fd from the framework for |
| 199 | # device traffic. Do not allow untrusted app to directly open tun_device |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 200 | allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } tun_device:chr_file { read write getattr append ioctl }; |
| 201 | allowxperm { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } tun_device:chr_file ioctl TUNGETIFF; |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 202 | |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 203 | |
| 204 | # WebView and other application-specific JIT compilers |
| 205 | allow appdomain self:process execmem; |
| 206 | |
| 207 | allow appdomain { ashmem_device ashmem_libcutils_device }:chr_file execute; |
| 208 | |
| 209 | # Receive and use open file descriptors inherited from zygote. |
| 210 | allow appdomain zygote:fd use; |
| 211 | |
| 212 | # Receive and use open file descriptors inherited from app zygote. |
| 213 | allow appdomain app_zygote:fd use; |
| 214 | |
| 215 | # gdbserver for ndk-gdb reads the zygote. |
| 216 | # valgrind needs mmap exec for zygote |
| 217 | allow appdomain zygote_exec:file rx_file_perms; |
| 218 | |
| 219 | # Notify zygote of death; |
| 220 | allow appdomain zygote:process sigchld; |
| 221 | |
| 222 | # Read /data/dalvik-cache. |
| 223 | allow appdomain dalvikcache_data_file:dir { search getattr }; |
| 224 | allow appdomain dalvikcache_data_file:file r_file_perms; |
| 225 | |
| 226 | # Read the /sdcard and /mnt/sdcard symlinks |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 227 | allow { appdomain -isolated_app_all -sdk_sandbox_all } rootfs:lnk_file r_file_perms; |
| 228 | allow { appdomain -isolated_app_all -sdk_sandbox_all } tmpfs:lnk_file r_file_perms; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 229 | |
| 230 | # Search /storage/emulated tmpfs mount. |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 231 | allow { appdomain -sdk_sandbox_all } tmpfs:dir r_dir_perms; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 232 | |
| 233 | # Notify zygote of the wrapped process PID when using --invoke-with. |
| 234 | allow appdomain zygote:fifo_file write; |
| 235 | |
| 236 | userdebug_or_eng(` |
| 237 | # Allow apps to create and write method traces in /data/misc/trace. |
| 238 | allow appdomain method_trace_data_file:dir w_dir_perms; |
| 239 | allow appdomain method_trace_data_file:file { create w_file_perms }; |
| 240 | ') |
| 241 | |
| 242 | # Notify shell and adbd of death when spawned via runas for ndk-gdb. |
| 243 | allow appdomain shell:process sigchld; |
| 244 | allow appdomain adbd:process sigchld; |
| 245 | |
| 246 | # child shell or gdbserver pty access for runas. |
| 247 | allow appdomain devpts:chr_file { getattr read write ioctl }; |
| 248 | |
| 249 | # Use pipes and sockets provided by system_server via binder or local socket. |
| 250 | allow appdomain system_server:fd use; |
| 251 | allow appdomain system_server:fifo_file rw_file_perms; |
| 252 | allow appdomain system_server:unix_stream_socket { read write setopt getattr getopt shutdown }; |
| 253 | allow appdomain system_server:tcp_socket { read write getattr getopt shutdown }; |
| 254 | |
| 255 | # For AppFuse. |
| 256 | allow appdomain vold:fd use; |
| 257 | |
| 258 | # Communication with other apps via fifos |
| 259 | allow appdomain appdomain:fifo_file rw_file_perms; |
| 260 | |
| 261 | # Communicate with surfaceflinger. |
| 262 | allow appdomain surfaceflinger:unix_stream_socket { read write setopt getattr getopt shutdown }; |
| 263 | |
| 264 | # App sandbox file accesses. |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 265 | allow { appdomain -isolated_app_all -mlstrustedsubject -sdk_sandbox_all } { app_data_file privapp_data_file }:dir create_dir_perms; |
| 266 | allow { appdomain -isolated_app_all -mlstrustedsubject -sdk_sandbox_all } { app_data_file privapp_data_file }:file create_file_perms; |
Victor Hsieh | fefc956 | 2023-08-07 13:51:41 -0700 | [diff] [blame] | 267 | allowxperm { appdomain -isolated_app_all -mlstrustedsubject -sdk_sandbox_all } { app_data_file privapp_data_file }:file ioctl FS_IOC_MEASURE_VERITY; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 268 | |
| 269 | # Access via already open fds is ok even for mlstrustedsubject. |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 270 | allow { appdomain -isolated_app_all -sdk_sandbox_all } { app_data_file privapp_data_file system_app_data_file }:file { getattr map read write }; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 271 | |
Gavin Corkery | d4d3c01 | 2023-05-10 16:13:53 +0000 | [diff] [blame] | 272 | # Access open fds from SDK sandbox |
| 273 | allow appdomain sdk_sandbox_data_file:file { getattr read }; |
| 274 | |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 275 | # Traverse into expanded storage |
| 276 | allow appdomain mnt_expand_file:dir r_dir_perms; |
| 277 | |
| 278 | # Keychain and user-trusted credentials |
| 279 | r_dir_file(appdomain, keychain_data_file) |
| 280 | allow appdomain misc_user_data_file:dir r_dir_perms; |
| 281 | allow appdomain misc_user_data_file:file r_file_perms; |
| 282 | |
| 283 | # TextClassifier |
Charles Chen | ccf8014 | 2023-01-20 03:34:19 +0000 | [diff] [blame] | 284 | r_dir_file({ appdomain -isolated_app_all }, textclassifier_data_file) |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 285 | |
| 286 | # Access to OEM provided data and apps |
| 287 | allow appdomain oemfs:dir r_dir_perms; |
| 288 | allow appdomain oemfs:file rx_file_perms; |
| 289 | |
| 290 | allow appdomain system_file:file x_file_perms; |
| 291 | |
| 292 | # Renderscript needs the ability to read directories on /system |
| 293 | allow appdomain system_file:dir r_dir_perms; |
| 294 | allow appdomain system_file:lnk_file { getattr open read }; |
| 295 | # Renderscript specific permissions to open /system/vendor/lib64. |
| 296 | not_full_treble(` |
| 297 | allow appdomain vendor_file_type:dir r_dir_perms; |
| 298 | allow appdomain vendor_file_type:lnk_file { getattr open read }; |
| 299 | ') |
| 300 | |
| 301 | full_treble_only(` |
| 302 | # For looking up Renderscript vendor drivers |
Charles Chen | ccf8014 | 2023-01-20 03:34:19 +0000 | [diff] [blame] | 303 | allow { appdomain -isolated_app_all } vendor_file:dir { open read }; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 304 | ') |
| 305 | |
| 306 | # Allow apps access to /vendor/overlay |
| 307 | r_dir_file(appdomain, vendor_overlay_file) |
| 308 | |
| 309 | # Allow apps access to /vendor/framework |
| 310 | # for vendor provided libraries. |
| 311 | r_dir_file(appdomain, vendor_framework_file) |
| 312 | |
| 313 | # Allow apps read / execute access to vendor public libraries. |
| 314 | allow appdomain {vendor_public_framework_file vendor_public_lib_file}:dir r_dir_perms; |
| 315 | allow appdomain {vendor_public_framework_file vendor_public_lib_file}:file { execute read open getattr map }; |
| 316 | |
| 317 | # Read/write wallpaper file (opened by system). |
Thiébaud Weksteen | 7ba4801 | 2023-03-20 12:56:43 +1100 | [diff] [blame] | 318 | allow { appdomain -isolated_app_all } wallpaper_file:file { getattr read write map }; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 319 | |
| 320 | # Read/write cached ringtones (opened by system). |
Thiébaud Weksteen | 7ba4801 | 2023-03-20 12:56:43 +1100 | [diff] [blame] | 321 | allow { appdomain -isolated_app_all } ringtone_file:file { getattr read write map }; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 322 | |
| 323 | # Read ShortcutManager icon files (opened by system). |
Thiébaud Weksteen | 7ba4801 | 2023-03-20 12:56:43 +1100 | [diff] [blame] | 324 | allow { appdomain -isolated_app_all } shortcut_manager_icons:file { getattr read map }; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 325 | |
| 326 | # Read icon file (opened by system). |
Thiébaud Weksteen | 7ba4801 | 2023-03-20 12:56:43 +1100 | [diff] [blame] | 327 | allow { appdomain -isolated_app_all } icon_file:file { getattr read map }; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 328 | |
| 329 | # Old stack dumping scheme : append to a global trace file (/data/anr/traces.txt). |
| 330 | # |
| 331 | # TODO: All of these permissions except for anr_data_file:file append can be |
| 332 | # withdrawn once we've switched to the new stack dumping mechanism, see b/32064548 |
| 333 | # and the rules below. |
| 334 | allow appdomain anr_data_file:dir search; |
| 335 | allow appdomain anr_data_file:file { open append }; |
| 336 | |
| 337 | # New stack dumping scheme : request an output FD from tombstoned via a unix |
| 338 | # domain socket. |
| 339 | # |
| 340 | # Allow apps to connect and write to the tombstoned java trace socket in |
| 341 | # order to dump their traces. Also allow them to append traces to pipes |
| 342 | # created by dumptrace. (Also see the rules below where they are given |
| 343 | # additional permissions to dumpstate pipes for other aspects of bug report |
| 344 | # creation). |
| 345 | unix_socket_connect(appdomain, tombstoned_java_trace, tombstoned) |
| 346 | allow appdomain tombstoned:fd use; |
| 347 | allow appdomain dumpstate:fifo_file append; |
| 348 | allow appdomain incidentd:fifo_file append; |
| 349 | |
| 350 | # Allow apps to send dump information to dumpstate |
| 351 | allow appdomain dumpstate:fd use; |
| 352 | allow appdomain dumpstate:unix_stream_socket { read write getopt getattr shutdown }; |
| 353 | allow appdomain dumpstate:fifo_file { write getattr }; |
| 354 | allow appdomain shell_data_file:file { write getattr }; |
| 355 | |
| 356 | # Allow apps to send dump information to incidentd |
| 357 | allow appdomain incidentd:fd use; |
| 358 | allow appdomain incidentd:fifo_file { write getattr }; |
| 359 | |
| 360 | # Allow apps to send information to statsd socket. |
| 361 | unix_socket_send(appdomain, statsdw, statsd) |
| 362 | |
| 363 | # Write profiles /data/misc/profiles |
| 364 | allow appdomain user_profile_root_file:dir search; |
Jiakai Zhang | 3c614b2 | 2022-09-28 16:29:28 +0000 | [diff] [blame] | 365 | allow appdomain user_profile_data_file:dir w_dir_perms; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 366 | allow appdomain user_profile_data_file:file create_file_perms; |
| 367 | |
Ryan Savitski | 941ba72 | 2023-02-02 14:24:45 +0000 | [diff] [blame] | 368 | # Allow writing performance tracing data into the perfetto traced daemon. |
| 369 | # Needed for java heap graph ART plugin (perfetto_hprof). |
| 370 | # The perfetto profiling daemon will check for the specific application's |
| 371 | # opt-in/opt-out. |
| 372 | perfetto_producer(appdomain) |
| 373 | |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 374 | # Send heap dumps to system_server via an already open file descriptor |
| 375 | # % adb shell am set-watch-heap com.android.systemui 1048576 |
| 376 | # % adb shell dumpsys procstats --start-testing |
| 377 | # debuggable builds only. |
| 378 | userdebug_or_eng(` |
| 379 | allow appdomain heapdump_data_file:file append; |
| 380 | ') |
| 381 | |
| 382 | # Grant GPU access to all processes started by Zygote. |
| 383 | # They need that to render the standard UI. |
Charles Chen | ccf8014 | 2023-01-20 03:34:19 +0000 | [diff] [blame] | 384 | allow { appdomain -isolated_app_all } gpu_device:chr_file rw_file_perms; |
| 385 | allow { appdomain -isolated_app_all } gpu_device:dir r_dir_perms; |
| 386 | allow { appdomain -isolated_app_all } sysfs_gpu:file r_file_perms; |
Jason Macnak | 365024e | 2022-02-24 18:32:16 +0000 | [diff] [blame] | 387 | |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 388 | |
| 389 | # Use the Binder. |
| 390 | binder_use(appdomain) |
| 391 | # Perform binder IPC to binder services. |
| 392 | binder_call(appdomain, binderservicedomain) |
| 393 | # Perform binder IPC to other apps. |
| 394 | binder_call(appdomain, appdomain) |
| 395 | # Perform binder IPC to ephemeral apps. |
| 396 | binder_call(appdomain, ephemeral_app) |
| 397 | # Perform binder IPC to gpuservice. |
Charles Chen | ccf8014 | 2023-01-20 03:34:19 +0000 | [diff] [blame] | 398 | binder_call({ appdomain -isolated_app_all }, gpuservice) |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 399 | |
| 400 | # Talk with graphics composer fences |
| 401 | allow appdomain hal_graphics_composer:fd use; |
| 402 | |
| 403 | # Already connected, unnamed sockets being passed over some other IPC |
| 404 | # hence no sock_file or connectto permission. This appears to be how |
| 405 | # Chrome works, may need to be updated as more apps using isolated services |
| 406 | # are examined. |
| 407 | allow appdomain appdomain:unix_stream_socket { getopt getattr read write shutdown }; |
| 408 | |
| 409 | # Backup ability for every app. BMS opens and passes the fd |
| 410 | # to any app that has backup ability. Hence, no open permissions here. |
| 411 | allow appdomain backup_data_file:file { read write getattr map }; |
| 412 | allow appdomain cache_backup_file:file { read write getattr map }; |
| 413 | allow appdomain cache_backup_file:dir getattr; |
| 414 | # Backup ability using 'adb backup' |
| 415 | allow appdomain system_data_file:lnk_file r_file_perms; |
| 416 | allow appdomain system_data_file:file { getattr read map }; |
| 417 | |
| 418 | # Allow read/stat of /data/media files passed by Binder or local socket IPC. |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 419 | allow { appdomain -isolated_app_all -sdk_sandbox_all } media_rw_data_file:file { read getattr }; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 420 | |
| 421 | # Read and write /data/data/com.android.providers.telephony files passed over Binder. |
Charles Chen | ccf8014 | 2023-01-20 03:34:19 +0000 | [diff] [blame] | 422 | allow { appdomain -isolated_app_all } radio_data_file:file { read write getattr }; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 423 | |
| 424 | # For art. |
| 425 | allow appdomain dalvikcache_data_file:file execute; |
| 426 | allow appdomain dalvikcache_data_file:lnk_file r_file_perms; |
| 427 | |
| 428 | # Allow any app to read shared RELRO files. |
| 429 | allow appdomain shared_relro_file:dir search; |
| 430 | allow appdomain shared_relro_file:file r_file_perms; |
| 431 | |
| 432 | # Allow apps to read/execute installed binaries |
Jeff Vander Stoep | 3fbb177 | 2023-03-27 10:03:46 +0200 | [diff] [blame] | 433 | allow appdomain apk_data_file:dir { open getattr read search ioctl lock }; |
| 434 | allow appdomain apk_data_file:file { getattr open read ioctl lock map x_file_perms }; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 435 | |
| 436 | # /data/resource-cache |
| 437 | allow appdomain resourcecache_data_file:file r_file_perms; |
| 438 | allow appdomain resourcecache_data_file:dir r_dir_perms; |
| 439 | |
| 440 | # logd access |
| 441 | read_logd(appdomain) |
| 442 | |
| 443 | allow appdomain zygote:unix_dgram_socket write; |
| 444 | |
| 445 | allow appdomain console_device:chr_file { read write }; |
| 446 | |
| 447 | # only allow unprivileged socket ioctl commands |
| 448 | allowxperm { appdomain -bluetooth } self:{ rawip_socket tcp_socket udp_socket } |
| 449 | ioctl { unpriv_sock_ioctls unpriv_tty_ioctls }; |
| 450 | |
Charles Chen | ccf8014 | 2023-01-20 03:34:19 +0000 | [diff] [blame] | 451 | allow { appdomain -isolated_app_all } ion_device:chr_file r_file_perms; |
| 452 | allow { appdomain -isolated_app_all } dmabuf_system_heap_device:chr_file r_file_perms; |
| 453 | allow { appdomain -isolated_app_all } dmabuf_system_secure_heap_device:chr_file r_file_perms; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 454 | |
| 455 | # Allow AAudio apps to use shared memory file descriptors from the HAL |
Charles Chen | ccf8014 | 2023-01-20 03:34:19 +0000 | [diff] [blame] | 456 | allow { appdomain -isolated_app_all } hal_audio:fd use; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 457 | |
| 458 | # Allow app to access shared memory created by camera HAL1 |
Charles Chen | ccf8014 | 2023-01-20 03:34:19 +0000 | [diff] [blame] | 459 | allow { appdomain -isolated_app_all } hal_camera:fd use; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 460 | |
| 461 | # Allow apps to access shared memory file descriptor from the tuner HAL |
Charles Chen | ccf8014 | 2023-01-20 03:34:19 +0000 | [diff] [blame] | 462 | allow {appdomain -isolated_app_all} hal_tv_tuner_server:fd use; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 463 | |
| 464 | # RenderScript always-passthrough HAL |
Charles Chen | ccf8014 | 2023-01-20 03:34:19 +0000 | [diff] [blame] | 465 | allow { appdomain -isolated_app_all } hal_renderscript_hwservice:hwservice_manager find; |
Nikita Ioffe | eb833f0 | 2022-01-07 03:12:53 +0000 | [diff] [blame] | 466 | allow appdomain same_process_hal_file:file { execute read open getattr map }; |
| 467 | |
| 468 | # TODO: switch to meminfo service |
| 469 | allow appdomain proc_meminfo:file r_file_perms; |
| 470 | |
| 471 | # For app fuse. |
| 472 | allow appdomain app_fuse_file:file { getattr read append write map }; |
| 473 | |
| 474 | ### |
| 475 | ### CTS-specific rules |
| 476 | ### |
| 477 | |
| 478 | # For cts/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java. |
| 479 | # testRunAsHasCorrectCapabilities |
| 480 | allow appdomain runas_exec:file getattr; |
| 481 | # Others are either allowed elsewhere or not desired. |
| 482 | |
| 483 | # Connect to adbd and use a socket transferred from it. |
| 484 | # This is used for e.g. adb backup/restore. |
| 485 | allow appdomain adbd:unix_stream_socket connectto; |
| 486 | allow appdomain adbd:fd use; |
| 487 | allow appdomain adbd:unix_stream_socket { getattr getopt ioctl read write shutdown }; |
| 488 | |
| 489 | allow appdomain cache_file:dir getattr; |
| 490 | |
| 491 | # Allow apps to run with asanwrapper. |
| 492 | with_asan(`allow appdomain asanwrapper_exec:file rx_file_perms;') |
| 493 | |
| 494 | # Read access to FDs from the DropboxManagerService. |
| 495 | allow appdomain dropbox_data_file:file { getattr read }; |
| 496 | |
| 497 | # Read tmpfs types from these processes. |
| 498 | allow appdomain audioserver_tmpfs:file { getattr map read write }; |
| 499 | allow appdomain system_server_tmpfs:file { getattr map read write }; |
| 500 | allow appdomain zygote_tmpfs:file { map read }; |
| 501 | |
Orion Hodson | 8f75f76 | 2020-10-16 15:29:55 +0100 | [diff] [blame] | 502 | # Sensitive app domains are not allowed to execute from /data |
| 503 | # to prevent persistence attacks and ensure all code is executed |
| 504 | # from read-only locations. |
| 505 | neverallow { |
| 506 | bluetooth |
Charles Chen | ccf8014 | 2023-01-20 03:34:19 +0000 | [diff] [blame] | 507 | isolated_app_all |
Orion Hodson | 8f75f76 | 2020-10-16 15:29:55 +0100 | [diff] [blame] | 508 | nfc |
| 509 | radio |
| 510 | shared_relro |
Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame] | 511 | sdk_sandbox_all |
Orion Hodson | 8f75f76 | 2020-10-16 15:29:55 +0100 | [diff] [blame] | 512 | system_app |
| 513 | } { |
| 514 | data_file_type |
| 515 | -apex_art_data_file |
| 516 | -dalvikcache_data_file |
| 517 | -system_data_file # shared libs in apks |
| 518 | -apk_data_file |
Avichal Rakesh | e092924 | 2023-01-23 23:49:50 -0800 | [diff] [blame] | 519 | }:file no_x_file_perms; |
| 520 | |
| 521 | # Don't allow apps access to any of the following character devices. |
| 522 | neverallow appdomain { |
| 523 | audio_device |
| 524 | camera_device |
| 525 | dm_device |
| 526 | radio_device |
| 527 | rpmsg_device |
| 528 | }:chr_file { read write }; |
| 529 | |
| 530 | # Block video device access for all apps except the DeviceAsWebcam Service which |
| 531 | # needs access to /dev/video* for interfacing with the host |
| 532 | neverallow { |
| 533 | appdomain |
| 534 | -device_as_webcam |
| 535 | } video_device:chr_file { read write }; |
Jeff Vander Stoep | f9a774f | 2023-03-27 12:30:23 +0200 | [diff] [blame] | 536 | |
| 537 | # Prevent calling inotify on APKs. This can be used as a side channel |
| 538 | # to observer app launches, so it must be disallowed. b/231587164 |
| 539 | # Gate by targetSdkVersion to avoid breaking existing apps. |
| 540 | neverallow { |
| 541 | appdomain |
| 542 | -untrusted_app_25 |
| 543 | -untrusted_app_27 |
| 544 | -untrusted_app_29 |
| 545 | -untrusted_app_30 |
| 546 | -untrusted_app_32 |
| 547 | } apk_data_file:dir { watch watch_reads }; |
| 548 | neverallow { |
| 549 | appdomain |
| 550 | -untrusted_app_25 |
| 551 | -untrusted_app_27 |
| 552 | -untrusted_app_29 |
| 553 | -untrusted_app_30 |
| 554 | -untrusted_app_32 |
| 555 | } apk_data_file:file { watch watch_reads }; |