Alex Klyubin | baeac1f | 2017-01-09 15:34:27 -0800 | [diff] [blame] | 1 | ### |
| 2 | ### Ephemeral apps. |
| 3 | ### |
| 4 | ### This file defines the security policy for apps with the ephemeral |
| 5 | ### feature. |
| 6 | ### |
| 7 | ### The ephemeral_app domain is a reduced permissions sandbox allowing |
| 8 | ### ephemeral applications to be safely installed and run. Non ephemeral |
| 9 | ### applications may also opt-in to ephemeral to take advantage of the |
| 10 | ### additional security features. |
| 11 | ### |
| 12 | ### PackageManager flags an app as ephemeral at install time. |
| 13 | |
| 14 | net_domain(ephemeral_app) |
| 15 | |
dcashman | cc39f63 | 2016-07-22 13:13:11 -0700 | [diff] [blame] | 16 | # Define and allow access to our own type for ashmem regions. |
| 17 | # Label ashmem objects with our own unique type. |
Chad Brubaker | 06cf31e | 2016-10-06 13:15:44 -0700 | [diff] [blame] | 18 | tmpfs_domain(ephemeral_app) |
Alex Klyubin | baeac1f | 2017-01-09 15:34:27 -0800 | [diff] [blame] | 19 | |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 20 | # TODO: deal with tmpfs_domain pub/priv split properly |
| 21 | # Map with PROT_EXEC. |
| 22 | allow ephemeral_app ephemeral_app_tmpfs:file execute; |
| 23 | |
Alex Klyubin | baeac1f | 2017-01-09 15:34:27 -0800 | [diff] [blame] | 24 | # allow JITing |
| 25 | allow ephemeral_app self:process execmem; |
| 26 | allow ephemeral_app ashmem_device:chr_file execute; |
| 27 | |
| 28 | # Send logcat messages to logd. |
| 29 | write_logd(ephemeral_app) |
| 30 | |
| 31 | # Receive and use open file descriptors inherited from zygote. |
| 32 | allow ephemeral_app zygote:fd use; |
| 33 | |
| 34 | # Notify zygote of death; |
| 35 | allow ephemeral_app zygote:process sigchld; |
| 36 | |
| 37 | # application inherit logd write socket (urge is to deprecate this long term) |
| 38 | allow ephemeral_app zygote:unix_dgram_socket write; |
| 39 | |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 40 | # Read system properties managed by zygote. |
| 41 | allow ephemeral_app zygote_tmpfs:file read; |
Alex Klyubin | baeac1f | 2017-01-09 15:34:27 -0800 | [diff] [blame] | 42 | |
| 43 | # App sandbox file accesses. |
| 44 | allow ephemeral_app ephemeral_data_file:dir create_dir_perms; |
| 45 | allow ephemeral_app ephemeral_data_file:{ file sock_file fifo_file } create_file_perms; |
| 46 | |
| 47 | # Keychain and user-trusted credentials |
| 48 | r_dir_file(ephemeral_app, keychain_data_file) |
| 49 | allow ephemeral_app misc_user_data_file:dir r_dir_perms; |
| 50 | allow ephemeral_app misc_user_data_file:file r_file_perms; |
| 51 | |
| 52 | # Allow apps to read/execute installed binaries |
| 53 | allow ephemeral_app ephemeral_apk_data_file:dir search; |
| 54 | allow ephemeral_app ephemeral_apk_data_file:file { r_file_perms execute }; |
| 55 | |
| 56 | # For art. |
| 57 | allow ephemeral_app dalvikcache_data_file:file { execute r_file_perms }; |
| 58 | allow ephemeral_app dalvikcache_data_file:lnk_file r_file_perms; |
| 59 | allow ephemeral_app dalvikcache_data_file:dir getattr; |
| 60 | |
| 61 | # Grant GPU access. ephemeral_app needs that to render the standard UI. |
| 62 | allow ephemeral_app gpu_device:chr_file rw_file_perms; |
| 63 | |
| 64 | # Use the Binder. |
| 65 | binder_use(ephemeral_app) |
| 66 | # Perform binder IPC to binder services. |
| 67 | binder_call(ephemeral_app, surfaceflinger) |
| 68 | binder_call(ephemeral_app, system_server) |
| 69 | # Perform binder IPC to apps. |
| 70 | binder_call(ephemeral_app, appdomain) |
| 71 | |
| 72 | # Allow read access to ion memory allocation device |
| 73 | allow ephemeral_app ion_device:chr_file { read open }; |
| 74 | |
| 75 | # Use pipes and sockets provided by system_server via binder or local socket. |
| 76 | allow ephemeral_app system_server:fifo_file rw_file_perms; |
| 77 | allow ephemeral_app system_server:unix_stream_socket { read write setopt getattr getopt shutdown }; |
| 78 | allow ephemeral_app system_server:tcp_socket { read write getattr getopt shutdown }; |
| 79 | |
| 80 | # Inherit or receive open files from system_server. |
| 81 | allow ephemeral_app system_server:fd use; |
| 82 | |
| 83 | # Communicate with surfaceflinger. |
| 84 | allow ephemeral_app surfaceflinger:unix_stream_socket { read write setopt getattr getopt shutdown }; |
| 85 | |
| 86 | # Read files already opened under /data. |
| 87 | allow ephemeral_app system_data_file:file { getattr read }; |
| 88 | allow ephemeral_app system_data_file:lnk_file read; |
| 89 | |
| 90 | # System file accesses. Check for libraries |
| 91 | allow ephemeral_app system_file:dir getattr; |
| 92 | |
| 93 | # services |
| 94 | allow ephemeral_app accessibility_service:service_manager find; |
| 95 | allow ephemeral_app activity_service:service_manager find; |
| 96 | allow ephemeral_app assetatlas_service:service_manager find; |
| 97 | allow ephemeral_app connectivity_service:service_manager find; |
| 98 | allow ephemeral_app display_service:service_manager find; |
| 99 | allow ephemeral_app graphicsstats_service:service_manager find; |
| 100 | allow ephemeral_app input_method_service:service_manager find; |
| 101 | allow ephemeral_app input_service:service_manager find; |
| 102 | allow ephemeral_app surfaceflinger_service:service_manager find; |
| 103 | allow ephemeral_app textservices_service:service_manager find; |
| 104 | |
| 105 | ### |
| 106 | ### neverallow rules |
| 107 | ### |
| 108 | |
| 109 | # Executable content should never be loaded from an ephemeral app home directory. |
| 110 | neverallow ephemeral_app ephemeral_data_file:file { execute execute_no_trans }; |
| 111 | |
| 112 | # Receive or send uevent messages. |
| 113 | neverallow ephemeral_app domain:netlink_kobject_uevent_socket *; |
| 114 | |
| 115 | # Receive or send generic netlink messages |
| 116 | neverallow ephemeral_app domain:netlink_socket *; |
| 117 | |
| 118 | # Too much leaky information in debugfs. It's a security |
| 119 | # best practice to ensure these files aren't readable. |
| 120 | neverallow ephemeral_app debugfs:file read; |
| 121 | |
| 122 | # execute gpu_device |
| 123 | neverallow ephemeral_app gpu_device:chr_file execute; |
| 124 | |
| 125 | # access files in /sys with the default sysfs label |
| 126 | neverallow ephemeral_app sysfs:file *; |
| 127 | |
| 128 | # Avoid reads from generically labeled /proc files |
| 129 | # Create a more specific label if needed |
| 130 | neverallow ephemeral_app proc:file { no_rw_file_perms no_x_file_perms }; |