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 |
| 8 | -isolated_app |
| 9 | -platform_app |
| 10 | -priv_app |
| 11 | -shell |
| 12 | -supplemental_process |
| 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 |
| 21 | -isolated_app |
| 22 | -platform_app |
| 23 | -priv_app |
| 24 | -shell |
| 25 | -su |
| 26 | -supplemental_process |
| 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) |
| 37 | get_prop(appdomain, dalvik_config_prop) |
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) |
Inseob Kim | dbcc459 | 2020-05-21 20:12:55 +0900 | [diff] [blame] | 48 | |
Calin Juravle | 0b2ca6c | 2021-05-18 15:33:08 -0700 | [diff] [blame] | 49 | # Allow ART to be configurable via device_config properties |
| 50 | # (ART "runs" inside the app process) |
| 51 | get_prop(appdomain, device_config_runtime_native_prop) |
| 52 | get_prop(appdomain, device_config_runtime_native_boot_prop) |
| 53 | |
Florian Mayer | 5e52281 | 2019-10-08 16:15:14 +0100 | [diff] [blame] | 54 | userdebug_or_eng(`perfetto_producer({ appdomain })') |
| 55 | |
Jeff Vander Stoep | 607bc67 | 2019-12-16 10:59:03 +0100 | [diff] [blame] | 56 | # Prevent apps from causing presubmit failures. |
| 57 | # Apps can cause selinux denials by accessing CE storage |
| 58 | # and/or external storage. In either case, the selinux denial is |
| 59 | # not the cause of the failure, but just a symptom that |
| 60 | # storage isn't ready. Many apps handle the failure appropriately. |
| 61 | # |
| 62 | # Apps cannot access external storage before it becomes available. |
| 63 | dontaudit appdomain storage_stub_file:dir getattr; |
| 64 | # Attempts to write to system_data_file is generally a sign |
| 65 | # that apps are attempting to access encrypted storage before |
| 66 | # the ACTION_USER_UNLOCKED intent is delivered. Apps are not |
| 67 | # allowed to write to CE storage before it's available. |
| 68 | # Attempting to do so will be blocked by both selinux and unix |
| 69 | # permissions. |
| 70 | dontaudit appdomain system_data_file:dir write; |
Jeff Vander Stoep | 67896ee | 2020-04-02 13:36:17 +0200 | [diff] [blame] | 71 | # Apps should not be reading vendor-defined properties. |
| 72 | dontaudit appdomain vendor_default_prop:file read; |
Jeff Vander Stoep | 607bc67 | 2019-12-16 10:59:03 +0100 | [diff] [blame] | 73 | |
Zim | b61bcc8 | 2021-04-08 12:20:26 +0100 | [diff] [blame] | 74 | # Access to /mnt/media_rw/<vol> (limited by DAC to apps with external_storage gid) |
| 75 | allow appdomain mnt_media_rw_file:dir search; |
| 76 | |
Nathan Harold | ee26864 | 2017-12-14 18:20:30 -0800 | [diff] [blame] | 77 | neverallow appdomain system_server:udp_socket { |
Nathan Harold | 252b015 | 2018-03-27 06:34:54 -0700 | [diff] [blame] | 78 | accept append bind create ioctl listen lock name_bind |
| 79 | relabelfrom relabelto setattr shutdown }; |
Nick Kralevich | 1e5021c | 2018-11-28 17:50:24 -0800 | [diff] [blame] | 80 | |
| 81 | # Transition to a non-app domain. |
| 82 | # Exception for the shell and su domains, can transition to runas, etc. |
Nick Kralevich | 0eb0a16 | 2018-12-12 09:06:05 -0800 | [diff] [blame] | 83 | # Exception for crash_dump to allow for app crash reporting. |
| 84 | # Exception for renderscript binaries (/system/bin/bcc, /system/bin/ld.mc) |
| 85 | # to allow renderscript to create privileged executable files. |
| 86 | neverallow { appdomain -shell userdebug_or_eng(`-su') } |
| 87 | { domain -appdomain -crash_dump -rs }:process { transition }; |
| 88 | neverallow { appdomain -shell userdebug_or_eng(`-su') } |
| 89 | { domain -appdomain }:process { dyntransition }; |
Daniel Rosenberg | afede84 | 2020-05-11 22:50:40 -0700 | [diff] [blame] | 90 | |
| 91 | # Don't allow regular apps access to storage configuration properties. |
| 92 | neverallow { appdomain -mediaprovider_app } storage_config_prop:file no_rw_file_perms; |
Peiyong Lin | 37dea07 | 2020-06-03 12:20:41 -0700 | [diff] [blame] | 93 | |
Inseob Kim | c80b024 | 2020-07-16 22:25:47 +0900 | [diff] [blame] | 94 | # Allow to read sendbug.preferred.domain |
| 95 | get_prop(appdomain, sendbug_config_prop) |
| 96 | |
Peiyong Lin | 37dea07 | 2020-06-03 12:20:41 -0700 | [diff] [blame] | 97 | # Allow to read graphics related properties. |
| 98 | get_prop(appdomain, graphics_config_prop) |
Inseob Kim | c97a97c | 2020-07-20 20:26:07 +0900 | [diff] [blame] | 99 | |
| 100 | # Allow to read persist.config.calibration_fac |
| 101 | get_prop(appdomain, camera_calibration_prop) |
Inseob Kim | 0cef0fe | 2020-11-17 13:54:52 +0900 | [diff] [blame] | 102 | |
| 103 | # Allow to read db.log.detailed, db.log.slow_query_threshold* |
| 104 | get_prop(appdomain, sqlite_log_prop) |
Orion Hodson | 8f75f76 | 2020-10-16 15:29:55 +0100 | [diff] [blame] | 105 | |
Seigo Nonaka | 9c3707f | 2021-01-21 13:08:31 -0800 | [diff] [blame] | 106 | # Allow font file read by apps. |
| 107 | allow appdomain font_data_file:file r_file_perms; |
| 108 | allow appdomain font_data_file:dir r_dir_perms; |
| 109 | |
Martijn Coenen | 4825e86 | 2021-03-29 13:51:35 +0200 | [diff] [blame] | 110 | # Enter /data/misc/apexdata/ |
| 111 | allow appdomain apex_module_data_file:dir search; |
Orion Hodson | 13ee653 | 2021-04-27 15:51:33 +0100 | [diff] [blame] | 112 | # Read /data/misc/apexdata/com.android.art, execute signed AOT artifacts. |
Martijn Coenen | 4825e86 | 2021-03-29 13:51:35 +0200 | [diff] [blame] | 113 | allow appdomain apex_art_data_file:dir r_dir_perms; |
Orion Hodson | 13ee653 | 2021-04-27 15:51:33 +0100 | [diff] [blame] | 114 | allow appdomain apex_art_data_file:file rx_file_perms; |
Orion Hodson | 8f75f76 | 2020-10-16 15:29:55 +0100 | [diff] [blame] | 115 | |
Josh Gao | ce1c4a5 | 2021-02-03 18:35:06 -0800 | [diff] [blame] | 116 | # Allow access to tombstones if an fd to one is given to you. |
| 117 | # This is restricted by unix permissions, so an app must go through system_server to get one. |
| 118 | allow appdomain tombstone_data_file:file { getattr read }; |
| 119 | neverallow appdomain tombstone_data_file:file ~{ getattr read }; |
| 120 | |
RafayKamran | eaa18ce | 2021-10-27 14:12:44 +0000 | [diff] [blame] | 121 | # Execute the shell or other system executables. |
| 122 | allow { appdomain -ephemeral_app -supplemental_process } shell_exec:file rx_file_perms; |
| 123 | allow { appdomain -ephemeral_app -supplemental_process } toolbox_exec:file rx_file_perms; |
| 124 | not_full_treble(`allow { appdomain -ephemeral_app -supplemental_process } vendor_file:file x_file_perms;') |
| 125 | |
| 126 | # Allow apps access to /vendor/app except for privileged |
| 127 | # apps which cannot be in /vendor. |
| 128 | r_dir_file({ appdomain -ephemeral_app -supplemental_process }, vendor_app_file) |
| 129 | allow { appdomain -ephemeral_app -supplemental_process } vendor_app_file:file execute; |
| 130 | |
| 131 | # Perform binder IPC to supplemental process. |
| 132 | binder_call(appdomain, supplemental_process) |
| 133 | |
| 134 | # Allow access to external storage; we have several visible mount points under /storage |
| 135 | # and symlinks to primary storage at places like /storage/sdcard0 and /mnt/user/0/primary |
| 136 | allow { appdomain -isolated_app -ephemeral_app -supplemental_process } storage_file:dir r_dir_perms; |
| 137 | allow { appdomain -isolated_app -ephemeral_app -supplemental_process } storage_file:lnk_file r_file_perms; |
| 138 | allow { appdomain -isolated_app -ephemeral_app -supplemental_process } mnt_user_file:dir r_dir_perms; |
| 139 | allow { appdomain -isolated_app -ephemeral_app -supplemental_process } mnt_user_file:lnk_file r_file_perms; |
| 140 | |
| 141 | # Read/write visible storage |
| 142 | allow { appdomain -isolated_app -ephemeral_app -supplemental_process } { sdcard_type fuse }:dir create_dir_perms; |
| 143 | allow { appdomain -isolated_app -ephemeral_app -supplemental_process } { sdcard_type fuse }:file create_file_perms; |
| 144 | # This should be removed if sdcardfs is modified to alter the secontext for its |
| 145 | # accesses to the underlying FS. |
| 146 | allow { appdomain -isolated_app -ephemeral_app -supplemental_process } media_rw_data_file:dir create_dir_perms; |
| 147 | allow { appdomain -isolated_app -ephemeral_app -supplemental_process } media_rw_data_file:file create_file_perms; |
| 148 | |
| 149 | # Allow apps to use the USB Accessory interface. |
| 150 | # http://developer.android.com/guide/topics/connectivity/usb/accessory.html |
| 151 | # |
| 152 | # USB devices are first opened by the system server (USBDeviceManagerService) |
| 153 | # and the file descriptor is passed to the right Activity via binder. |
| 154 | allow { appdomain -isolated_app -ephemeral_app -supplemental_process } usb_device:chr_file { read write getattr ioctl }; |
| 155 | allow { appdomain -isolated_app -ephemeral_app -supplemental_process } usbaccessory_device:chr_file { read write getattr }; |
| 156 | |
| 157 | #logd access |
| 158 | control_logd({ appdomain -ephemeral_app -supplemental_process }) |
| 159 | |
| 160 | # application inherit logd write socket (urge is to deprecate this long term) |
| 161 | allow { appdomain -isolated_app -ephemeral_app -supplemental_process } keystore:keystore_key { get_state get insert delete exist list sign verify }; |
| 162 | allow { appdomain -isolated_app -ephemeral_app -supplemental_process } keystore:keystore2_key { delete use get_info rebind update }; |
| 163 | |
| 164 | allow { appdomain -isolated_app -ephemeral_app -supplemental_process } keystore_maintenance_service:service_manager find; |
| 165 | allow { appdomain -isolated_app -ephemeral_app -supplemental_process } keystore:keystore2 get_state; |
| 166 | |
| 167 | use_keystore({ appdomain -isolated_app -ephemeral_app -supplemental_process }) |
| 168 | |
| 169 | use_credstore({ appdomain -isolated_app -ephemeral_app -supplemental_process }) |
| 170 | |
| 171 | # For app fuse. |
| 172 | pdx_client({ appdomain -isolated_app -ephemeral_app -supplemental_process }, display_client) |
| 173 | pdx_client({ appdomain -isolated_app -ephemeral_app -supplemental_process }, display_manager) |
| 174 | pdx_client({ appdomain -isolated_app -ephemeral_app -supplemental_process }, display_vsync) |
| 175 | pdx_client({ appdomain -isolated_app -ephemeral_app -supplemental_process }, performance_client) |
| 176 | # Apps do not directly open the IPC socket for bufferhubd. |
| 177 | pdx_use({ appdomain -isolated_app -ephemeral_app -supplemental_process }, bufferhub_client) |
| 178 | |
| 179 | # Apps receive an open tun fd from the framework for |
| 180 | # device traffic. Do not allow untrusted app to directly open tun_device |
| 181 | allow { appdomain -isolated_app -ephemeral_app -supplemental_process } tun_device:chr_file { read write getattr append ioctl }; |
| 182 | allowxperm { appdomain -isolated_app -ephemeral_app -supplemental_process } tun_device:chr_file ioctl TUNGETIFF; |
| 183 | |
Orion Hodson | 8f75f76 | 2020-10-16 15:29:55 +0100 | [diff] [blame] | 184 | # Sensitive app domains are not allowed to execute from /data |
| 185 | # to prevent persistence attacks and ensure all code is executed |
| 186 | # from read-only locations. |
| 187 | neverallow { |
| 188 | bluetooth |
| 189 | isolated_app |
| 190 | nfc |
| 191 | radio |
| 192 | shared_relro |
| 193 | system_app |
| 194 | } { |
| 195 | data_file_type |
| 196 | -apex_art_data_file |
| 197 | -dalvikcache_data_file |
| 198 | -system_data_file # shared libs in apks |
| 199 | -apk_data_file |
| 200 | }:file no_x_file_perms; |
Tianjie | b729aa6 | 2021-10-05 22:13:20 -0700 | [diff] [blame] | 201 | |
| 202 | # For now, don't allow apps other than gmscore to access /data/misc_ce/<userid>/checkin |
| 203 | neverallow { appdomain -gmscore_app } checkin_data_file:dir *; |
| 204 | neverallow { appdomain -gmscore_app } checkin_data_file:file *; |