Mugdha Lakhani | 2ae45c5 | 2023-04-28 09:22:15 +0000 | [diff] [blame^] | 1 | ### |
| 2 | ### sdk_sandbox_all |
| 3 | ### |
| 4 | ### This file defines the rules shared by all sdk_sandbox_all domains. |
| 5 | ### Apps are labeled based on mac_permissions.xml (maps signer and |
| 6 | ### optionally package name to seinfo value) and seapp_contexts (maps UID |
| 7 | ### and optionally seinfo value to domain for process and type for data |
| 8 | ### directory). The sdk_sandbox_all_all attribute is assigned to all default |
| 9 | ### seapp_contexts for any app with UID between FIRST_SDK_SANDBOX_UID (20000) |
| 10 | ### and LAST_SDK_SANDBOX_UID (29999) if the app has no specific seinfo |
| 11 | ### value as determined from mac_permissions.xml. |
| 12 | |
| 13 | allow sdk_sandbox_all system_linker_exec:file execute_no_trans; |
| 14 | |
| 15 | # Required to read CTS tests data from the shell_data_file location. |
| 16 | allow sdk_sandbox_all shell_data_file:file r_file_perms; |
| 17 | allow sdk_sandbox_all shell_data_file:dir r_dir_perms; |
| 18 | |
| 19 | # allow sdk sandbox to use UDP sockets provided by the system server but not |
| 20 | # modify them other than to connect |
| 21 | allow sdk_sandbox_all system_server:udp_socket { |
| 22 | connect getattr read recvfrom sendto write getopt setopt }; |
| 23 | |
| 24 | # allow sandbox to search in sdk system server directory |
| 25 | # additionally, for webview to work, getattr has been permitted |
| 26 | allow sdk_sandbox_all sdk_sandbox_system_data_file:dir { getattr search }; |
| 27 | # allow sandbox to create files and dirs in sdk data directory |
| 28 | allow sdk_sandbox_all sdk_sandbox_data_file:dir create_dir_perms; |
| 29 | allow sdk_sandbox_all sdk_sandbox_data_file:file create_file_perms; |
| 30 | |
| 31 | ### |
| 32 | ### neverallow rules |
| 33 | ### |
| 34 | |
| 35 | neverallow sdk_sandbox_all { app_data_file privapp_data_file sdk_sandbox_data_file }:file { execute execute_no_trans }; |
| 36 | |
| 37 | # Receive or send uevent messages. |
| 38 | neverallow sdk_sandbox_all domain:netlink_kobject_uevent_socket *; |
| 39 | |
| 40 | # Receive or send generic netlink messages |
| 41 | neverallow sdk_sandbox_all domain:netlink_socket *; |
| 42 | |
| 43 | # Too much leaky information in debugfs. It's a security |
| 44 | # best practice to ensure these files aren't readable. |
| 45 | neverallow sdk_sandbox_all debugfs:file read; |
| 46 | |
| 47 | # execute gpu_device |
| 48 | neverallow sdk_sandbox_all gpu_device:chr_file execute; |
| 49 | |
| 50 | # access files in /sys with the default sysfs label |
| 51 | neverallow sdk_sandbox_all sysfs:file *; |
| 52 | |
| 53 | # Avoid reads from generically labeled /proc files |
| 54 | # Create a more specific label if needed |
| 55 | neverallow sdk_sandbox_all proc:file { no_rw_file_perms no_x_file_perms }; |
| 56 | |
| 57 | # Directly access external storage |
| 58 | neverallow sdk_sandbox_all { sdcard_type media_rw_data_file }:file {open create}; |
| 59 | neverallow sdk_sandbox_all { sdcard_type media_rw_data_file }:dir search; |
| 60 | |
| 61 | # Avoid reads to proc_net, it contains too much device wide information about |
| 62 | # ongoing connections. |
| 63 | neverallow sdk_sandbox_all proc_net:file no_rw_file_perms; |
| 64 | |
| 65 | # SDK sandbox processes have their own storage not related to app_data_file or privapp_data_file |
| 66 | neverallow sdk_sandbox_all { app_data_file privapp_data_file }:dir no_rw_file_perms; |
| 67 | neverallow sdk_sandbox_all { app_data_file privapp_data_file }:file no_rw_file_perms; |
| 68 | |
| 69 | # SDK sandbox processes don't have any access to external storage |
| 70 | neverallow sdk_sandbox_all { media_rw_data_file }:dir no_rw_file_perms; |
| 71 | neverallow sdk_sandbox_all { media_rw_data_file }:file no_rw_file_perms; |
| 72 | |
| 73 | neverallow { sdk_sandbox_all } tmpfs:dir no_rw_file_perms; |
| 74 | |
| 75 | neverallow sdk_sandbox_all hal_drm_service:service_manager find; |
| 76 | |
| 77 | # Only certain system components should have access to sdk_sandbox_system_data_file |
| 78 | # sdk_sandbox only needs search. Restricted in follow up neverallow rule. |
| 79 | neverallow { |
| 80 | domain |
| 81 | -init |
| 82 | -installd |
| 83 | -system_server |
| 84 | -vold_prepare_subdirs |
| 85 | } sdk_sandbox_system_data_file:dir { relabelfrom }; |
| 86 | |
| 87 | neverallow { |
| 88 | domain |
| 89 | -init |
| 90 | -installd |
| 91 | -sdk_sandbox_all |
| 92 | -system_server |
| 93 | -vold_prepare_subdirs |
| 94 | -zygote |
| 95 | } sdk_sandbox_system_data_file:dir { create_dir_perms relabelto }; |
| 96 | |
| 97 | # Only certain system components should have access to sdk_sandbox_all_system_data_file |
| 98 | # sdk_sandbox_all only needs search. Restricted in follow up neverallow rule. |
| 99 | neverallow { |
| 100 | domain |
| 101 | -init |
| 102 | -installd |
| 103 | -system_server |
| 104 | -vold_prepare_subdirs |
| 105 | } sdk_sandbox_system_data_file:dir { relabelfrom }; |
| 106 | |
| 107 | neverallow { |
| 108 | domain |
| 109 | -init |
| 110 | -installd |
| 111 | -sdk_sandbox_all |
| 112 | -system_server |
| 113 | -vold_prepare_subdirs |
| 114 | -zygote |
| 115 | } sdk_sandbox_system_data_file:dir { create_dir_perms relabelto }; |
| 116 | |
| 117 | # sdk_sandbox_all only needs to traverse through the sdk_sandbox_all_system_data_file |
| 118 | neverallow sdk_sandbox_all sdk_sandbox_system_data_file:dir ~{ getattr search }; |
| 119 | |
| 120 | # Only dirs should be created at sdk_sandbox_all_system_data_file level |
| 121 | neverallow { domain -init } sdk_sandbox_system_data_file:file *; |
| 122 | |