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 | |
sandrom | e6971f1 | 2022-05-31 08:50:55 +0000 | [diff] [blame] | 6 | type sdk_sandbox; |
Bram Bonne | b93f26f | 2022-03-15 18:28:02 +0100 | [diff] [blame] | 7 | |
| 8 | ### |
| 9 | ### neverallow rules |
| 10 | ### |
| 11 | |
Bram Bonne | 078b43c | 2022-04-25 13:28:52 +0200 | [diff] [blame] | 12 | 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] | 13 | |
| 14 | # Receive or send uevent messages. |
| 15 | neverallow sdk_sandbox domain:netlink_kobject_uevent_socket *; |
| 16 | |
| 17 | # Receive or send generic netlink messages |
| 18 | neverallow sdk_sandbox domain:netlink_socket *; |
| 19 | |
| 20 | # Too much leaky information in debugfs. It's a security |
| 21 | # best practice to ensure these files aren't readable. |
| 22 | neverallow sdk_sandbox debugfs:file read; |
| 23 | |
| 24 | # execute gpu_device |
| 25 | neverallow sdk_sandbox gpu_device:chr_file execute; |
| 26 | |
| 27 | # access files in /sys with the default sysfs label |
| 28 | neverallow sdk_sandbox sysfs:file *; |
| 29 | |
| 30 | # Avoid reads from generically labeled /proc files |
| 31 | # Create a more specific label if needed |
| 32 | neverallow sdk_sandbox proc:file { no_rw_file_perms no_x_file_perms }; |
| 33 | |
| 34 | # Directly access external storage |
| 35 | neverallow sdk_sandbox { sdcard_type media_rw_data_file }:file {open create}; |
| 36 | neverallow sdk_sandbox { sdcard_type media_rw_data_file }:dir search; |
| 37 | |
| 38 | # Avoid reads to proc_net, it contains too much device wide information about |
| 39 | # ongoing connections. |
| 40 | neverallow sdk_sandbox proc_net:file no_rw_file_perms; |
| 41 | |
| 42 | # SDK sandbox processes have their own storage not related to app_data_file or privapp_data_file |
| 43 | neverallow sdk_sandbox { app_data_file privapp_data_file }:dir no_rw_file_perms; |
| 44 | neverallow sdk_sandbox { app_data_file privapp_data_file }:file no_rw_file_perms; |
| 45 | |
| 46 | # SDK sandbox processes don't have any access to external storage |
| 47 | neverallow sdk_sandbox { media_rw_data_file }:dir no_rw_file_perms; |
| 48 | neverallow sdk_sandbox { media_rw_data_file }:file no_rw_file_perms; |
| 49 | |
| 50 | neverallow { sdk_sandbox } tmpfs:dir no_rw_file_perms; |
Bram Bonne | 85dfe31 | 2022-03-23 17:48:48 +0100 | [diff] [blame] | 51 | |
| 52 | neverallow sdk_sandbox hal_drm_service:service_manager find; |
Mohammad Samiul Islam | d2ffd35 | 2022-05-11 21:43:54 +0100 | [diff] [blame] | 53 | |
| 54 | # Only certain system components should have access to sdk_sandbox_system_data_file |
| 55 | # sdk_sandbox only needs search. Restricted in follow up neverallow rule. |
| 56 | neverallow { |
| 57 | domain |
| 58 | -init |
| 59 | -installd |
Sanjana Sunil | 5630163 | 2022-05-20 11:24:32 +0000 | [diff] [blame] | 60 | -system_server |
| 61 | -vold_prepare_subdirs |
| 62 | } sdk_sandbox_system_data_file:dir { relabelfrom }; |
| 63 | |
| 64 | neverallow { |
| 65 | domain |
| 66 | -init |
| 67 | -installd |
Mohammad Samiul Islam | d2ffd35 | 2022-05-11 21:43:54 +0100 | [diff] [blame] | 68 | -sdk_sandbox |
| 69 | -system_server |
| 70 | -vold_prepare_subdirs |
Sanjana Sunil | 5630163 | 2022-05-20 11:24:32 +0000 | [diff] [blame] | 71 | -zygote |
| 72 | } sdk_sandbox_system_data_file:dir { create_dir_perms relabelto }; |
Mohammad Samiul Islam | d2ffd35 | 2022-05-11 21:43:54 +0100 | [diff] [blame] | 73 | |
| 74 | # sdk_sandbox only needs to traverse through the sdk_sandbox_system_data_file |
| 75 | neverallow sdk_sandbox sdk_sandbox_system_data_file:dir ~{ getattr search }; |
| 76 | |
| 77 | # Only dirs should be created at sdk_sandbox_system_data_file level |
| 78 | neverallow { domain -init } sdk_sandbox_system_data_file:file *; |