Bram Bonne | b93f26f | 2022-03-15 18:28:02 +0100 | [diff] [blame] | 1 | ### |
| 2 | ### SDK Sandbox process. |
| 3 | ### |
| 4 | ### This file defines the security policy for the sdk sandbox processes. |
| 5 | |
Lokesh Gidra | 1269a17 | 2022-08-01 17:20:38 +0000 | [diff] [blame^] | 6 | type sdk_sandbox, domain; |
| 7 | |
| 8 | typeattribute sdk_sandbox coredomain; |
| 9 | |
| 10 | net_domain(sdk_sandbox) |
| 11 | app_domain(sdk_sandbox) |
| 12 | |
| 13 | # Allow finding services. This is different from ephemeral_app policy. |
| 14 | # Adding services manually to the allowlist is preferred hence app_api_service is not used. |
| 15 | # Audit the access to signal that we are still investigating whether sdk_sandbox |
| 16 | # should have access to audio_service |
| 17 | # TODO(b/211632068): remove this line |
| 18 | auditallow sdk_sandbox audio_service:service_manager find; |
| 19 | |
| 20 | allow sdk_sandbox activity_service:service_manager find; |
| 21 | allow sdk_sandbox activity_task_service:service_manager find; |
| 22 | allow sdk_sandbox appops_service:service_manager find; |
| 23 | allow sdk_sandbox audio_service:service_manager find; |
| 24 | allow sdk_sandbox audioserver_service:service_manager find; |
| 25 | allow sdk_sandbox batteryproperties_service:service_manager find; |
| 26 | allow sdk_sandbox batterystats_service:service_manager find; |
| 27 | allow sdk_sandbox connectivity_service:service_manager find; |
| 28 | allow sdk_sandbox connmetrics_service:service_manager find; |
| 29 | allow sdk_sandbox deviceidle_service:service_manager find; |
| 30 | allow sdk_sandbox display_service:service_manager find; |
| 31 | allow sdk_sandbox dropbox_service:service_manager find; |
| 32 | allow sdk_sandbox font_service:service_manager find; |
| 33 | allow sdk_sandbox game_service:service_manager find; |
| 34 | allow sdk_sandbox gpu_service:service_manager find; |
| 35 | allow sdk_sandbox graphicsstats_service:service_manager find; |
| 36 | allow sdk_sandbox hardware_properties_service:service_manager find; |
| 37 | allow sdk_sandbox hint_service:service_manager find; |
| 38 | allow sdk_sandbox imms_service:service_manager find; |
| 39 | allow sdk_sandbox input_method_service:service_manager find; |
| 40 | allow sdk_sandbox input_service:service_manager find; |
| 41 | allow sdk_sandbox IProxyService_service:service_manager find; |
| 42 | allow sdk_sandbox ipsec_service:service_manager find; |
| 43 | allow sdk_sandbox launcherapps_service:service_manager find; |
| 44 | allow sdk_sandbox legacy_permission_service:service_manager find; |
| 45 | allow sdk_sandbox light_service:service_manager find; |
| 46 | allow sdk_sandbox locale_service:service_manager find; |
| 47 | allow sdk_sandbox media_communication_service:service_manager find; |
| 48 | allow sdk_sandbox mediaextractor_service:service_manager find; |
| 49 | allow sdk_sandbox mediametrics_service:service_manager find; |
| 50 | allow sdk_sandbox media_projection_service:service_manager find; |
| 51 | allow sdk_sandbox media_router_service:service_manager find; |
| 52 | allow sdk_sandbox mediaserver_service:service_manager find; |
| 53 | allow sdk_sandbox media_session_service:service_manager find; |
| 54 | allow sdk_sandbox memtrackproxy_service:service_manager find; |
| 55 | allow sdk_sandbox midi_service:service_manager find; |
| 56 | allow sdk_sandbox netpolicy_service:service_manager find; |
| 57 | allow sdk_sandbox netstats_service:service_manager find; |
| 58 | allow sdk_sandbox network_management_service:service_manager find; |
| 59 | allow sdk_sandbox notification_service:service_manager find; |
| 60 | allow sdk_sandbox package_service:service_manager find; |
| 61 | allow sdk_sandbox permission_checker_service:service_manager find; |
| 62 | allow sdk_sandbox permission_service:service_manager find; |
| 63 | allow sdk_sandbox permissionmgr_service:service_manager find; |
| 64 | allow sdk_sandbox platform_compat_service:service_manager find; |
| 65 | allow sdk_sandbox power_service:service_manager find; |
| 66 | allow sdk_sandbox procstats_service:service_manager find; |
| 67 | allow sdk_sandbox registry_service:service_manager find; |
| 68 | allow sdk_sandbox restrictions_service:service_manager find; |
| 69 | allow sdk_sandbox rttmanager_service:service_manager find; |
| 70 | allow sdk_sandbox search_service:service_manager find; |
| 71 | allow sdk_sandbox selection_toolbar_service:service_manager find; |
| 72 | allow sdk_sandbox sensor_privacy_service:service_manager find; |
| 73 | allow sdk_sandbox sensorservice_service:service_manager find; |
| 74 | allow sdk_sandbox servicediscovery_service:service_manager find; |
| 75 | allow sdk_sandbox settings_service:service_manager find; |
| 76 | allow sdk_sandbox speech_recognition_service:service_manager find; |
| 77 | allow sdk_sandbox statusbar_service:service_manager find; |
| 78 | allow sdk_sandbox storagestats_service:service_manager find; |
| 79 | allow sdk_sandbox surfaceflinger_service:service_manager find; |
| 80 | allow sdk_sandbox telecom_service:service_manager find; |
| 81 | allow sdk_sandbox tethering_service:service_manager find; |
| 82 | allow sdk_sandbox textclassification_service:service_manager find; |
| 83 | allow sdk_sandbox textservices_service:service_manager find; |
| 84 | allow sdk_sandbox texttospeech_service:service_manager find; |
| 85 | allow sdk_sandbox thermal_service:service_manager find; |
| 86 | allow sdk_sandbox translation_service:service_manager find; |
| 87 | allow sdk_sandbox tv_iapp_service:service_manager find; |
| 88 | allow sdk_sandbox tv_input_service:service_manager find; |
| 89 | allow sdk_sandbox uimode_service:service_manager find; |
| 90 | allow sdk_sandbox vcn_management_service:service_manager find; |
| 91 | allow sdk_sandbox webviewupdate_service:service_manager find; |
| 92 | |
| 93 | allow sdk_sandbox system_linker_exec:file execute_no_trans; |
| 94 | |
| 95 | # Write app-specific trace data to the Perfetto traced damon. This requires |
| 96 | # connecting to its producer socket and obtaining a (per-process) tmpfs fd. |
| 97 | perfetto_producer(sdk_sandbox) |
| 98 | |
| 99 | # Allow profiling if the app opts in by being marked profileable/debuggable. |
| 100 | can_profile_heap(sdk_sandbox) |
| 101 | can_profile_perf(sdk_sandbox) |
| 102 | |
| 103 | # allow sdk sandbox to use UDP sockets provided by the system server but not |
| 104 | # modify them other than to connect |
| 105 | allow sdk_sandbox system_server:udp_socket { |
| 106 | connect getattr read recvfrom sendto write getopt setopt }; |
| 107 | |
| 108 | # allow sandbox to search in sdk system server directory |
| 109 | # additionally, for webview to work, getattr has been permitted |
| 110 | allow sdk_sandbox sdk_sandbox_system_data_file:dir { getattr search }; |
| 111 | # allow sandbox to create files and dirs in sdk data directory |
| 112 | allow sdk_sandbox sdk_sandbox_data_file:dir create_dir_perms; |
| 113 | allow sdk_sandbox sdk_sandbox_data_file:file create_file_perms; |
Bram Bonne | b93f26f | 2022-03-15 18:28:02 +0100 | [diff] [blame] | 114 | |
| 115 | ### |
| 116 | ### neverallow rules |
| 117 | ### |
| 118 | |
Bram Bonne | 078b43c | 2022-04-25 13:28:52 +0200 | [diff] [blame] | 119 | neverallow sdk_sandbox { app_data_file privapp_data_file sdk_sandbox_data_file }:file { execute execute_no_trans }; |
Bram Bonne | b93f26f | 2022-03-15 18:28:02 +0100 | [diff] [blame] | 120 | |
| 121 | # Receive or send uevent messages. |
| 122 | neverallow sdk_sandbox domain:netlink_kobject_uevent_socket *; |
| 123 | |
| 124 | # Receive or send generic netlink messages |
| 125 | neverallow sdk_sandbox domain:netlink_socket *; |
| 126 | |
| 127 | # Too much leaky information in debugfs. It's a security |
| 128 | # best practice to ensure these files aren't readable. |
| 129 | neverallow sdk_sandbox debugfs:file read; |
| 130 | |
| 131 | # execute gpu_device |
| 132 | neverallow sdk_sandbox gpu_device:chr_file execute; |
| 133 | |
| 134 | # access files in /sys with the default sysfs label |
| 135 | neverallow sdk_sandbox sysfs:file *; |
| 136 | |
| 137 | # Avoid reads from generically labeled /proc files |
| 138 | # Create a more specific label if needed |
| 139 | neverallow sdk_sandbox proc:file { no_rw_file_perms no_x_file_perms }; |
| 140 | |
| 141 | # Directly access external storage |
| 142 | neverallow sdk_sandbox { sdcard_type media_rw_data_file }:file {open create}; |
| 143 | neverallow sdk_sandbox { sdcard_type media_rw_data_file }:dir search; |
| 144 | |
| 145 | # Avoid reads to proc_net, it contains too much device wide information about |
| 146 | # ongoing connections. |
| 147 | neverallow sdk_sandbox proc_net:file no_rw_file_perms; |
| 148 | |
| 149 | # SDK sandbox processes have their own storage not related to app_data_file or privapp_data_file |
| 150 | neverallow sdk_sandbox { app_data_file privapp_data_file }:dir no_rw_file_perms; |
| 151 | neverallow sdk_sandbox { app_data_file privapp_data_file }:file no_rw_file_perms; |
| 152 | |
| 153 | # SDK sandbox processes don't have any access to external storage |
| 154 | neverallow sdk_sandbox { media_rw_data_file }:dir no_rw_file_perms; |
| 155 | neverallow sdk_sandbox { media_rw_data_file }:file no_rw_file_perms; |
| 156 | |
| 157 | neverallow { sdk_sandbox } tmpfs:dir no_rw_file_perms; |
Bram Bonne | 85dfe31 | 2022-03-23 17:48:48 +0100 | [diff] [blame] | 158 | |
| 159 | neverallow sdk_sandbox hal_drm_service:service_manager find; |
Mohammad Samiul Islam | d2ffd35 | 2022-05-11 21:43:54 +0100 | [diff] [blame] | 160 | |
| 161 | # Only certain system components should have access to sdk_sandbox_system_data_file |
| 162 | # sdk_sandbox only needs search. Restricted in follow up neverallow rule. |
| 163 | neverallow { |
| 164 | domain |
| 165 | -init |
| 166 | -installd |
Sanjana Sunil | 5630163 | 2022-05-20 11:24:32 +0000 | [diff] [blame] | 167 | -system_server |
| 168 | -vold_prepare_subdirs |
| 169 | } sdk_sandbox_system_data_file:dir { relabelfrom }; |
| 170 | |
| 171 | neverallow { |
| 172 | domain |
| 173 | -init |
| 174 | -installd |
Mohammad Samiul Islam | d2ffd35 | 2022-05-11 21:43:54 +0100 | [diff] [blame] | 175 | -sdk_sandbox |
| 176 | -system_server |
| 177 | -vold_prepare_subdirs |
Sanjana Sunil | 5630163 | 2022-05-20 11:24:32 +0000 | [diff] [blame] | 178 | -zygote |
| 179 | } sdk_sandbox_system_data_file:dir { create_dir_perms relabelto }; |
Mohammad Samiul Islam | d2ffd35 | 2022-05-11 21:43:54 +0100 | [diff] [blame] | 180 | |
| 181 | # sdk_sandbox only needs to traverse through the sdk_sandbox_system_data_file |
| 182 | neverallow sdk_sandbox sdk_sandbox_system_data_file:dir ~{ getattr search }; |
| 183 | |
| 184 | # Only dirs should be created at sdk_sandbox_system_data_file level |
| 185 | neverallow { domain -init } sdk_sandbox_system_data_file:file *; |