Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 1 | ### |
| 2 | ### neverallow rules for untrusted app domains |
| 3 | ### |
| 4 | |
Nick Kralevich | db5962c | 2017-04-26 16:14:40 -0700 | [diff] [blame] | 5 | define(`all_untrusted_apps',`{ |
| 6 | ephemeral_app |
| 7 | isolated_app |
| 8 | mediaprovider |
| 9 | untrusted_app |
| 10 | untrusted_app_25 |
Jeff Vander Stoep | 3aa7ca5 | 2018-04-03 11:22:38 -0700 | [diff] [blame] | 11 | untrusted_app_27 |
Nick Kralevich | db5962c | 2017-04-26 16:14:40 -0700 | [diff] [blame] | 12 | untrusted_app_all |
Nick Kralevich | db5962c | 2017-04-26 16:14:40 -0700 | [diff] [blame] | 13 | }') |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 14 | # Receive or send uevent messages. |
Chad Brubaker | a782a81 | 2017-02-06 10:31:45 -0800 | [diff] [blame] | 15 | neverallow all_untrusted_apps domain:netlink_kobject_uevent_socket *; |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 16 | |
| 17 | # Receive or send generic netlink messages |
Chad Brubaker | a782a81 | 2017-02-06 10:31:45 -0800 | [diff] [blame] | 18 | neverallow all_untrusted_apps domain:netlink_socket *; |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 19 | |
| 20 | # Too much leaky information in debugfs. It's a security |
| 21 | # best practice to ensure these files aren't readable. |
Dan Austin | 55d9096 | 2018-11-29 10:37:18 -0800 | [diff] [blame] | 22 | neverallow all_untrusted_apps { debugfs_type -debugfs_kcov }:file read; |
Jeff Vander Stoep | 0ac2eec | 2019-02-04 10:07:15 -0800 | [diff] [blame] | 23 | neverallow {all_untrusted_apps userdebug_or_eng(`-domain')} debugfs_type:{ file lnk_file } read; |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 24 | |
| 25 | # Do not allow untrusted apps to register services. |
| 26 | # Only trusted components of Android should be registering |
| 27 | # services. |
Chad Brubaker | a782a81 | 2017-02-06 10:31:45 -0800 | [diff] [blame] | 28 | neverallow all_untrusted_apps service_manager_type:service_manager add; |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 29 | |
Alex Klyubin | 0065783 | 2017-04-25 09:27:54 -0700 | [diff] [blame] | 30 | # Do not allow untrusted apps to use VendorBinder |
| 31 | neverallow all_untrusted_apps vndbinder_device:chr_file *; |
| 32 | neverallow all_untrusted_apps vndservice_manager_type:service_manager *; |
| 33 | |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 34 | # Do not allow untrusted apps to connect to the property service |
| 35 | # or set properties. b/10243159 |
Jerry Zhang | 9f152d9 | 2017-04-10 16:57:48 -0700 | [diff] [blame] | 36 | neverallow { all_untrusted_apps -mediaprovider } property_socket:sock_file write; |
| 37 | neverallow { all_untrusted_apps -mediaprovider } init:unix_stream_socket connectto; |
| 38 | neverallow { all_untrusted_apps -mediaprovider } property_type:property_service set; |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 39 | |
Jeff Vander Stoep | 886aa54 | 2018-03-28 15:34:37 -0700 | [diff] [blame] | 40 | # net.dns properties are not a public API. Temporarily exempt pre-Oreo apps, |
| 41 | # but otherwise disallow untrusted apps from reading this property. |
| 42 | neverallow { all_untrusted_apps -untrusted_app_25 } net_dns_prop:file read; |
| 43 | |
Nick Kralevich | fb66c6f | 2019-01-11 09:37:46 -0800 | [diff] [blame] | 44 | # Shared libraries created by trusted components within an app home |
| 45 | # directory can be dlopen()ed. To maintain the W^X property, these files |
Nick Kralevich | 0eb0a16 | 2018-12-12 09:06:05 -0800 | [diff] [blame] | 46 | # must never be writable to the app. |
Nick Kralevich | fb66c6f | 2019-01-11 09:37:46 -0800 | [diff] [blame] | 47 | neverallow all_untrusted_apps app_exec_data_file:file |
Nick Kralevich | 0eb0a16 | 2018-12-12 09:06:05 -0800 | [diff] [blame] | 48 | { append create link relabelfrom relabelto rename setattr write }; |
| 49 | |
Nick Kralevich | 65a89c1 | 2018-12-21 10:03:50 -0800 | [diff] [blame] | 50 | # Block calling execve() on files in an apps home directory. |
Yabin Cui | 5dc2c8c | 2018-11-02 11:12:43 -0700 | [diff] [blame] | 51 | # This is a W^X violation (loading executable code from a writable |
| 52 | # home directory). For compatibility, allow for targetApi <= 28. |
| 53 | # b/112357170 |
| 54 | neverallow { |
| 55 | all_untrusted_apps |
| 56 | -untrusted_app_25 |
| 57 | -untrusted_app_27 |
Yabin Cui | ffa2b61 | 2018-11-02 14:34:06 -0700 | [diff] [blame] | 58 | -runas_app |
Yabin Cui | 5dc2c8c | 2018-11-02 11:12:43 -0700 | [diff] [blame] | 59 | } { app_data_file privapp_data_file }:file execute_no_trans; |
| 60 | |
David Brazdil | 535c5d2 | 2018-11-19 23:02:49 +0000 | [diff] [blame] | 61 | # Do not allow untrusted apps to invoke dex2oat. This was historically required |
| 62 | # by ART for compiling secondary dex files but has been removed in Q. |
| 63 | # Exempt legacy apps (targetApi<=28) for compatibility. |
| 64 | neverallow { |
| 65 | all_untrusted_apps |
| 66 | -untrusted_app_25 |
| 67 | -untrusted_app_27 |
| 68 | } dex2oat_exec:file no_x_file_perms; |
| 69 | |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 70 | # Do not allow untrusted apps to be assigned mlstrustedsubject. |
| 71 | # This would undermine the per-user isolation model being |
| 72 | # enforced via levelFrom=user in seapp_contexts and the mls |
| 73 | # constraints. As there is no direct way to specify a neverallow |
| 74 | # on attribute assignment, this relies on the fact that fork |
| 75 | # permission only makes sense within a domain (hence should |
| 76 | # never be granted to any other domain within mlstrustedsubject) |
| 77 | # and an untrusted app is allowed fork permission to itself. |
Chad Brubaker | a782a81 | 2017-02-06 10:31:45 -0800 | [diff] [blame] | 78 | neverallow all_untrusted_apps mlstrustedsubject:process fork; |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 79 | |
| 80 | # Do not allow untrusted apps to hard link to any files. |
| 81 | # In particular, if an untrusted app links to other app data |
| 82 | # files, installd will not be able to guarantee the deletion |
| 83 | # of the linked to file. Hard links also contribute to security |
| 84 | # bugs, so we want to ensure untrusted apps never have this |
| 85 | # capability. |
Chad Brubaker | a782a81 | 2017-02-06 10:31:45 -0800 | [diff] [blame] | 86 | neverallow all_untrusted_apps file_type:file link; |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 87 | |
| 88 | # Do not allow untrusted apps to access network MAC address file |
Chad Brubaker | a782a81 | 2017-02-06 10:31:45 -0800 | [diff] [blame] | 89 | neverallow all_untrusted_apps sysfs_mac_address:file no_rw_file_perms; |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 90 | |
Jeff Vander Stoep | 06cef4f | 2017-10-04 13:12:25 -0700 | [diff] [blame] | 91 | # Do not allow any write access to files in /sys |
Jeff Vander Stoep | 886aa54 | 2018-03-28 15:34:37 -0700 | [diff] [blame] | 92 | neverallow all_untrusted_apps sysfs_type:file { no_w_file_perms no_x_file_perms }; |
| 93 | |
| 94 | # Apps may never access the default sysfs label. |
| 95 | neverallow all_untrusted_apps sysfs:file no_rw_file_perms; |
Jeff Vander Stoep | 06cef4f | 2017-10-04 13:12:25 -0700 | [diff] [blame] | 96 | |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 97 | # Restrict socket ioctls. Either 1. disallow privileged ioctls, 2. disallow the |
| 98 | # ioctl permission, or 3. disallow the socket class. |
Jeff Vander Stoep | 0597ade | 2018-06-21 16:57:58 -0700 | [diff] [blame] | 99 | neverallowxperm all_untrusted_apps domain:{ icmp_socket rawip_socket tcp_socket udp_socket } ioctl priv_sock_ioctls; |
Chad Brubaker | a782a81 | 2017-02-06 10:31:45 -0800 | [diff] [blame] | 100 | neverallow all_untrusted_apps *:{ netlink_route_socket netlink_selinux_socket } ioctl; |
| 101 | neverallow all_untrusted_apps *:{ |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 102 | socket netlink_socket packet_socket key_socket appletalk_socket |
Stephen Smalley | 4921085 | 2017-02-06 14:14:58 -0500 | [diff] [blame] | 103 | netlink_tcpdiag_socket netlink_nflog_socket |
| 104 | netlink_xfrm_socket netlink_audit_socket |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 105 | netlink_dnrt_socket netlink_kobject_uevent_socket tun_socket |
| 106 | netlink_iscsi_socket netlink_fib_lookup_socket netlink_connector_socket |
| 107 | netlink_netfilter_socket netlink_generic_socket netlink_scsitransport_socket |
Jeff Vander Stoep | 0597ade | 2018-06-21 16:57:58 -0700 | [diff] [blame] | 108 | netlink_rdma_socket netlink_crypto_socket sctp_socket |
| 109 | ax25_socket ipx_socket netrom_socket atmpvc_socket x25_socket rose_socket decnet_socket |
| 110 | atmsvc_socket rds_socket irda_socket pppox_socket llc_socket can_socket tipc_socket |
| 111 | bluetooth_socket iucv_socket rxrpc_socket isdn_socket phonet_socket ieee802154_socket caif_socket |
Nick Kralevich | a194d37 | 2018-11-16 02:48:03 -0800 | [diff] [blame] | 112 | alg_socket nfc_socket vsock_socket kcm_socket qipcrtr_socket smc_socket xdp_socket |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 113 | } *; |
| 114 | |
| 115 | # Do not allow untrusted apps access to /cache |
Jerry Zhang | 9f152d9 | 2017-04-10 16:57:48 -0700 | [diff] [blame] | 116 | neverallow { all_untrusted_apps -mediaprovider } { cache_file cache_recovery_file }:dir ~{ r_dir_perms }; |
| 117 | neverallow { all_untrusted_apps -mediaprovider } { cache_file cache_recovery_file }:file ~{ read getattr }; |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 118 | |
| 119 | # Do not allow untrusted apps to create/unlink files outside of its sandbox, |
| 120 | # internal storage or sdcard. |
| 121 | # World accessible data locations allow application to fill the device |
| 122 | # with unaccounted for data. This data will not get removed during |
| 123 | # application un-installation. |
Jerry Zhang | 9f152d9 | 2017-04-10 16:57:48 -0700 | [diff] [blame] | 124 | neverallow { all_untrusted_apps -mediaprovider } { |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 125 | fs_type |
Jeff Sharkey | 000cafc | 2018-03-30 12:22:54 -0600 | [diff] [blame] | 126 | -sdcard_type |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 127 | file_type |
| 128 | -app_data_file # The apps sandbox itself |
Nick Kralevich | 23c9d91 | 2018-08-02 15:54:23 -0700 | [diff] [blame] | 129 | -privapp_data_file |
Nick Kralevich | fb66c6f | 2019-01-11 09:37:46 -0800 | [diff] [blame] | 130 | -app_exec_data_file # stored within the app sandbox directory |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 131 | -media_rw_data_file # Internal storage. Known that apps can |
| 132 | # leave artfacts here after uninstall. |
| 133 | -user_profile_data_file # Access to profile files |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 134 | userdebug_or_eng(` |
| 135 | -method_trace_data_file # only on ro.debuggable=1 |
| 136 | -coredump_file # userdebug/eng only |
| 137 | ') |
| 138 | }:dir_file_class_set { create unlink }; |
| 139 | |
Nick Kralevich | 45766d4 | 2017-04-26 11:40:48 -0700 | [diff] [blame] | 140 | # No untrusted component should be touching /dev/fuse |
| 141 | neverallow all_untrusted_apps fuse_device:chr_file *; |
| 142 | |
Nick Kralevich | 3b2df19 | 2018-11-15 06:14:07 -0800 | [diff] [blame] | 143 | # Do not allow untrusted apps to directly open the tun_device |
| 144 | neverallow all_untrusted_apps tun_device:chr_file open; |
| 145 | # The tun_device ioctls below are not allowed, to prove equivalence |
| 146 | # to the kernel patch at |
Nick Kralevich | 619c1ef | 2018-10-30 20:12:41 -0700 | [diff] [blame] | 147 | # https://android.googlesource.com/kernel/common/+/11cee2be0c2062ba88f04eb51196506f870a3b5d%5E%21 |
| 148 | neverallowxperm all_untrusted_apps tun_device:chr_file ioctl { |
| 149 | SIOCGIFHWADDR |
| 150 | SIOCSIFHWADDR |
| 151 | TUNATTACHFILTER |
| 152 | TUNDETACHFILTER |
| 153 | TUNGETFEATURES |
| 154 | TUNGETFILTER |
| 155 | TUNGETSNDBUF |
| 156 | TUNGETVNETHDRSZ |
| 157 | TUNSETDEBUG |
| 158 | TUNSETGROUP |
| 159 | TUNSETIFF |
| 160 | TUNSETLINK |
| 161 | TUNSETNOCSUM |
| 162 | TUNSETOFFLOAD |
| 163 | TUNSETOWNER |
| 164 | TUNSETPERSIST |
| 165 | TUNSETQUEUE |
| 166 | TUNSETSNDBUF |
| 167 | TUNSETTXFILTER |
| 168 | TUNSETVNETHDRSZ |
| 169 | }; |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 170 | |
| 171 | # Only allow appending to /data/anr/traces.txt (b/27853304, b/18340553) |
Chad Brubaker | a782a81 | 2017-02-06 10:31:45 -0800 | [diff] [blame] | 172 | neverallow all_untrusted_apps anr_data_file:file ~{ open append }; |
| 173 | neverallow all_untrusted_apps anr_data_file:dir ~search; |
Chad Brubaker | 46e5a06 | 2017-01-27 15:53:38 -0800 | [diff] [blame] | 174 | |
| 175 | # Avoid reads from generically labeled /proc files |
| 176 | # Create a more specific label if needed |
Dan Cashman | 91d398d | 2017-09-26 12:58:29 -0700 | [diff] [blame] | 177 | neverallow all_untrusted_apps { |
| 178 | proc |
Tri Vo | 464f59a | 2017-10-06 10:20:53 -0700 | [diff] [blame] | 179 | proc_asound |
Dan Cashman | 91d398d | 2017-09-26 12:58:29 -0700 | [diff] [blame] | 180 | proc_filesystems |
| 181 | proc_kmsg |
| 182 | proc_loadavg |
| 183 | proc_mounts |
| 184 | proc_pagetypeinfo |
Mark Salyzyn | d6eaed8 | 2018-06-14 07:34:19 -0700 | [diff] [blame] | 185 | proc_slabinfo |
Jeff Vander Stoep | 886aa54 | 2018-03-28 15:34:37 -0700 | [diff] [blame] | 186 | proc_stat |
Dan Cashman | 91d398d | 2017-09-26 12:58:29 -0700 | [diff] [blame] | 187 | proc_swaps |
Jeff Vander Stoep | 886aa54 | 2018-03-28 15:34:37 -0700 | [diff] [blame] | 188 | proc_uptime |
Dan Cashman | 91d398d | 2017-09-26 12:58:29 -0700 | [diff] [blame] | 189 | proc_version |
| 190 | proc_vmallocinfo |
Jeff Vander Stoep | 886aa54 | 2018-03-28 15:34:37 -0700 | [diff] [blame] | 191 | proc_vmstat |
Dan Cashman | 91d398d | 2017-09-26 12:58:29 -0700 | [diff] [blame] | 192 | }:file { no_rw_file_perms no_x_file_perms }; |
Fyodor Kupolov | b238fe6 | 2017-03-14 11:42:03 -0700 | [diff] [blame] | 193 | |
Sandeep Patil | 2da9cfd | 2017-04-21 11:25:29 -0700 | [diff] [blame] | 194 | # Avoid all access to kernel configuration |
| 195 | neverallow all_untrusted_apps config_gz:file { no_rw_file_perms no_x_file_perms }; |
| 196 | |
Fyodor Kupolov | b238fe6 | 2017-03-14 11:42:03 -0700 | [diff] [blame] | 197 | # Do not allow untrusted apps access to preloads data files |
| 198 | neverallow all_untrusted_apps preloads_data_file:file no_rw_file_perms; |
Nick Kralevich | 92c44a5 | 2017-03-22 10:35:24 -0700 | [diff] [blame] | 199 | |
| 200 | # Locking of files on /system could lead to denial of service attacks |
| 201 | # against privileged system components |
| 202 | neverallow all_untrusted_apps system_file:file lock; |
Alex Klyubin | 2a7f4fb | 2017-04-21 17:06:43 -0700 | [diff] [blame] | 203 | |
Alex Klyubin | 5c5b626 | 2017-04-24 15:09:19 -0700 | [diff] [blame] | 204 | # Do not permit untrusted apps to perform actions on HwBinder service_manager |
| 205 | # other than find actions for services listed below |
| 206 | neverallow all_untrusted_apps *:hwservice_manager ~find; |
| 207 | |
Alex Klyubin | 2a7f4fb | 2017-04-21 17:06:43 -0700 | [diff] [blame] | 208 | # Do not permit access from apps which host arbitrary code to HwBinder services, |
| 209 | # except those considered sufficiently safe for access from such apps. |
| 210 | # The two main reasons for this are: |
| 211 | # 1. HwBinder servers do not perform client authentication because HIDL |
| 212 | # currently does not expose caller UID information and, even if it did, many |
| 213 | # HwBinder services either operate at a level below that of apps (e.g., HALs) |
| 214 | # or must not rely on app identity for authorization. Thus, to be safe, the |
| 215 | # default assumption is that every HwBinder service treats all its clients as |
| 216 | # equally authorized to perform operations offered by the service. |
| 217 | # 2. HAL servers (a subset of HwBinder services) contain code with higher |
| 218 | # incidence rate of security issues than system/core components and have |
| 219 | # access to lower layes of the stack (all the way down to hardware) thus |
| 220 | # increasing opportunities for bypassing the Android security model. |
Dan Cashman | 3e307a4 | 2017-06-21 10:00:32 -0700 | [diff] [blame] | 221 | # |
| 222 | # Safe services include: |
| 223 | # - same process services: because they by definition run in the process |
| 224 | # of the client and thus have the same access as the client domain in which |
| 225 | # the process runs |
| 226 | # - coredomain_hwservice: are considered safe because they do not pose risks |
| 227 | # associated with reason #2 above. |
| 228 | # - hal_configstore_ISurfaceFlingerConfigs: becuase it has specifically been |
| 229 | # designed for use by any domain. |
| 230 | # - hal_graphics_allocator_hwservice: because these operations are also offered |
| 231 | # by surfaceflinger Binder service, which apps are permitted to access |
| 232 | # - hal_omx_hwservice: because this is a HwBinder version of the mediacodec |
| 233 | # Binder service which apps were permitted to access. |
Pawin Vongmasa | 19a74ec | 2018-03-28 21:09:23 -0700 | [diff] [blame] | 234 | # - hal_codec2_hwservice: because this is a newer version of hal_omx_hwservice. |
Alex Klyubin | 2a7f4fb | 2017-04-21 17:06:43 -0700 | [diff] [blame] | 235 | neverallow all_untrusted_apps { |
| 236 | hwservice_manager_type |
Alex Klyubin | 2a7f4fb | 2017-04-21 17:06:43 -0700 | [diff] [blame] | 237 | -same_process_hwservice |
Dan Cashman | 3e307a4 | 2017-06-21 10:00:32 -0700 | [diff] [blame] | 238 | -coredomain_hwservice |
Pawin Vongmasa | 19a74ec | 2018-03-28 21:09:23 -0700 | [diff] [blame] | 239 | -hal_codec2_hwservice |
Dan Cashman | 3e307a4 | 2017-06-21 10:00:32 -0700 | [diff] [blame] | 240 | -hal_configstore_ISurfaceFlingerConfigs |
Alex Klyubin | 2a7f4fb | 2017-04-21 17:06:43 -0700 | [diff] [blame] | 241 | -hal_graphics_allocator_hwservice |
Alex Klyubin | 2a7f4fb | 2017-04-21 17:06:43 -0700 | [diff] [blame] | 242 | -hal_omx_hwservice |
Dan Cashman | 91d398d | 2017-09-26 12:58:29 -0700 | [diff] [blame] | 243 | -hal_cas_hwservice |
Michael Butler | ea331aa | 2017-12-15 14:16:25 -0800 | [diff] [blame] | 244 | -hal_neuralnetworks_hwservice |
Tri Vo | 7f8b6cc | 2018-07-28 16:48:06 -0700 | [diff] [blame] | 245 | -untrusted_app_visible_hwservice_violators |
Dan Cashman | 3e307a4 | 2017-06-21 10:00:32 -0700 | [diff] [blame] | 246 | }:hwservice_manager find; |
Dan Cashman | 91d398d | 2017-09-26 12:58:29 -0700 | [diff] [blame] | 247 | |
Dan Cashman | 3e307a4 | 2017-06-21 10:00:32 -0700 | [diff] [blame] | 248 | # Make sure that the following services are never accessible by untrusted_apps |
| 249 | neverallow all_untrusted_apps { |
| 250 | default_android_hwservice |
Wei Wang | bc71a61 | 2018-09-19 16:06:28 -0700 | [diff] [blame] | 251 | hal_atrace_hwservice |
Dan Cashman | 3e307a4 | 2017-06-21 10:00:32 -0700 | [diff] [blame] | 252 | hal_audio_hwservice |
Andrew Scull | 64f35fa | 2018-01-10 16:11:46 +0000 | [diff] [blame] | 253 | hal_authsecret_hwservice |
Dan Cashman | 3e307a4 | 2017-06-21 10:00:32 -0700 | [diff] [blame] | 254 | hal_bluetooth_hwservice |
| 255 | hal_bootctl_hwservice |
| 256 | hal_camera_hwservice |
Janis Danisevskis | 97c56bd | 2018-01-09 17:42:53 -0500 | [diff] [blame] | 257 | hal_confirmationui_hwservice |
Dan Cashman | 3e307a4 | 2017-06-21 10:00:32 -0700 | [diff] [blame] | 258 | hal_contexthub_hwservice |
| 259 | hal_drm_hwservice |
| 260 | hal_dumpstate_hwservice |
| 261 | hal_fingerprint_hwservice |
| 262 | hal_gatekeeper_hwservice |
| 263 | hal_gnss_hwservice |
| 264 | hal_graphics_composer_hwservice |
| 265 | hal_health_hwservice |
Siarhei Vishniakou | 41a871b | 2018-01-17 12:27:06 -0800 | [diff] [blame] | 266 | hal_input_classifier_hwservice |
Dan Cashman | 3e307a4 | 2017-06-21 10:00:32 -0700 | [diff] [blame] | 267 | hal_ir_hwservice |
| 268 | hal_keymaster_hwservice |
| 269 | hal_light_hwservice |
| 270 | hal_memtrack_hwservice |
| 271 | hal_nfc_hwservice |
| 272 | hal_oemlock_hwservice |
| 273 | hal_power_hwservice |
Benjamin Schwartz | e7040ea | 2018-12-10 14:59:57 -0800 | [diff] [blame] | 274 | hal_power_stats_hwservice |
Ruchi Kandoi | 8a2b4a7 | 2018-01-04 10:33:20 -0800 | [diff] [blame] | 275 | hal_secure_element_hwservice |
Dan Cashman | 3e307a4 | 2017-06-21 10:00:32 -0700 | [diff] [blame] | 276 | hal_sensors_hwservice |
| 277 | hal_telephony_hwservice |
| 278 | hal_thermal_hwservice |
| 279 | hal_tv_cec_hwservice |
| 280 | hal_tv_input_hwservice |
| 281 | hal_usb_hwservice |
| 282 | hal_vibrator_hwservice |
| 283 | hal_vr_hwservice |
| 284 | hal_weaver_hwservice |
| 285 | hal_wifi_hwservice |
Dan Cashman | 91d398d | 2017-09-26 12:58:29 -0700 | [diff] [blame] | 286 | hal_wifi_offload_hwservice |
Dan Cashman | 3e307a4 | 2017-06-21 10:00:32 -0700 | [diff] [blame] | 287 | hal_wifi_supplicant_hwservice |
| 288 | hidl_base_hwservice |
Dan Cashman | 91d398d | 2017-09-26 12:58:29 -0700 | [diff] [blame] | 289 | system_net_netd_hwservice |
| 290 | thermalcallback_hwservice |
Alex Klyubin | 2a7f4fb | 2017-04-21 17:06:43 -0700 | [diff] [blame] | 291 | }:hwservice_manager find; |
| 292 | # HwBinder services offered by core components (as opposed to vendor components) |
| 293 | # are considered somewhat safer due to point #2 above. |
| 294 | neverallow all_untrusted_apps { |
| 295 | coredomain_hwservice |
| 296 | -same_process_hwservice |
Jiwen 'Steve' Cai | e17b293 | 2019-01-04 19:14:07 -0800 | [diff] [blame] | 297 | -fwk_bufferhub_hwservice # Designed for use by any domain |
Alex Klyubin | 2a7f4fb | 2017-04-21 17:06:43 -0700 | [diff] [blame] | 298 | -hidl_allocator_hwservice # Designed for use by any domain |
| 299 | -hidl_manager_hwservice # Designed for use by any domain |
| 300 | -hidl_memory_hwservice # Designed for use by any domain |
| 301 | -hidl_token_hwservice # Designed for use by any domain |
| 302 | }:hwservice_manager find; |
| 303 | |
Dan Cashman | 91d398d | 2017-09-26 12:58:29 -0700 | [diff] [blame] | 304 | # SELinux is not an API for untrusted apps to use |
| 305 | neverallow all_untrusted_apps selinuxfs:file no_rw_file_perms; |
| 306 | |
Alex Klyubin | 2a7f4fb | 2017-04-21 17:06:43 -0700 | [diff] [blame] | 307 | # Restrict *Binder access from apps to HAL domains. We can only do this on full |
| 308 | # Treble devices where *Binder communications between apps and HALs are tightly |
| 309 | # restricted. |
| 310 | full_treble_only(` |
| 311 | neverallow all_untrusted_apps { |
| 312 | halserverdomain |
| 313 | -coredomain |
| 314 | -hal_configstore_server |
| 315 | -hal_graphics_allocator_server |
Dan Cashman | 91d398d | 2017-09-26 12:58:29 -0700 | [diff] [blame] | 316 | -hal_cas_server |
Michael Butler | ea331aa | 2017-12-15 14:16:25 -0800 | [diff] [blame] | 317 | -hal_neuralnetworks_server |
Steven Moreland | 7baf725 | 2018-05-25 16:23:37 -0700 | [diff] [blame] | 318 | -hal_omx_server |
Alex Klyubin | 2a7f4fb | 2017-04-21 17:06:43 -0700 | [diff] [blame] | 319 | -binder_in_vendor_violators # TODO(b/35870313): Remove once all violations are gone |
Tri Vo | 7f8b6cc | 2018-07-28 16:48:06 -0700 | [diff] [blame] | 320 | -untrusted_app_visible_halserver_violators |
Alex Klyubin | 2a7f4fb | 2017-04-21 17:06:43 -0700 | [diff] [blame] | 321 | }:binder { call transfer }; |
| 322 | ') |
Dongwon Kang | 1134bd0 | 2017-11-06 11:19:07 -0800 | [diff] [blame] | 323 | |
| 324 | # Untrusted apps are not allowed to find mediaextractor update service. |
| 325 | neverallow all_untrusted_apps mediaextractor_update_service:service_manager find; |
Jeff Vander Stoep | ff511cb | 2018-09-07 07:39:28 -0700 | [diff] [blame] | 326 | |
| 327 | # Access to /proc/tty/drivers, to allow apps to determine if they |
| 328 | # are running in an emulated environment. |
| 329 | # b/33214085 b/33814662 b/33791054 b/33211769 |
| 330 | # https://github.com/strazzere/anti-emulator/blob/master/AntiEmulator/src/diff/strazzere/anti/emulator/FindEmulator.java |
| 331 | # This will go away in a future Android release |
| 332 | neverallow { all_untrusted_apps -untrusted_app_25 } proc_tty_drivers:file r_file_perms; |
| 333 | neverallow all_untrusted_apps proc_tty_drivers:file ~r_file_perms; |
Tri Vo | f55c989 | 2018-10-10 22:48:15 +0000 | [diff] [blame] | 334 | |
| 335 | # Untrusted apps are not allowed to use cgroups. |
| 336 | neverallow all_untrusted_apps cgroup:file *; |
Tri Vo | 73d0a67 | 2019-01-27 13:39:19 -0800 | [diff] [blame] | 337 | |
Tri Vo | 73d0a67 | 2019-01-27 13:39:19 -0800 | [diff] [blame] | 338 | # Untrusted apps targetting >= Q are not allowed to open /dev/ashmem directly. |
Tri Vo | 8b12ff5 | 2019-02-12 14:14:30 -0800 | [diff] [blame] | 339 | # They must use ASharedMemory NDK API instead. |
| 340 | neverallow { |
| 341 | all_untrusted_apps |
Tri Vo | 19200ae | 2019-04-09 11:48:35 -0700 | [diff] [blame] | 342 | -ephemeral_app |
Tri Vo | 8b12ff5 | 2019-02-12 14:14:30 -0800 | [diff] [blame] | 343 | -untrusted_app_25 |
| 344 | -untrusted_app_27 |
| 345 | } ashmem_device:chr_file open; |
Tri Vo | 8eff3e2 | 2019-04-11 15:23:24 -0700 | [diff] [blame] | 346 | |
| 347 | # /mnt/sdcard symlink was supposed to have been removed in Gingerbread. Apps |
| 348 | # must not use it. |
| 349 | neverallow { |
| 350 | all_untrusted_apps |
| 351 | -untrusted_app_25 |
| 352 | -untrusted_app_27 |
| 353 | } mnt_sdcard_file:lnk_file *; |