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) |
Chad Brubaker | 5c566d1 | 2017-01-17 13:28:24 -0800 | [diff] [blame] | 15 | app_domain(ephemeral_app) |
Alex Klyubin | baeac1f | 2017-01-09 15:34:27 -0800 | [diff] [blame] | 16 | |
| 17 | # App sandbox file accesses. |
| 18 | allow ephemeral_app ephemeral_data_file:dir create_dir_perms; |
| 19 | allow ephemeral_app ephemeral_data_file:{ file sock_file fifo_file } create_file_perms; |
| 20 | |
Alex Klyubin | baeac1f | 2017-01-09 15:34:27 -0800 | [diff] [blame] | 21 | # Allow apps to read/execute installed binaries |
Chad Brubaker | 5c566d1 | 2017-01-17 13:28:24 -0800 | [diff] [blame] | 22 | allow ephemeral_app ephemeral_apk_data_file:dir r_dir_perms; |
Alex Klyubin | baeac1f | 2017-01-09 15:34:27 -0800 | [diff] [blame] | 23 | allow ephemeral_app ephemeral_apk_data_file:file { r_file_perms execute }; |
| 24 | |
Chad Brubaker | 3d348fd | 2017-01-19 10:42:40 -0800 | [diff] [blame] | 25 | # Allow ephemeral apps to read/write files in visible storage if provided fds |
| 26 | allow ephemeral_app { sdcard_type media_rw_data_file }:file {read write getattr ioctl lock append}; |
| 27 | |
Alex Klyubin | baeac1f | 2017-01-09 15:34:27 -0800 | [diff] [blame] | 28 | # services |
Alex Klyubin | baeac1f | 2017-01-09 15:34:27 -0800 | [diff] [blame] | 29 | allow ephemeral_app surfaceflinger_service:service_manager find; |
Chad Brubaker | 5c566d1 | 2017-01-17 13:28:24 -0800 | [diff] [blame] | 30 | allow ephemeral_app radio_service:service_manager find; |
| 31 | # TODO: Replace app_api_service with a smaller ephemeral_api_service |
| 32 | allow ephemeral_app app_api_service:service_manager find; |
Alex Klyubin | baeac1f | 2017-01-09 15:34:27 -0800 | [diff] [blame] | 33 | |
| 34 | ### |
| 35 | ### neverallow rules |
| 36 | ### |
| 37 | |
| 38 | # Executable content should never be loaded from an ephemeral app home directory. |
| 39 | neverallow ephemeral_app ephemeral_data_file:file { execute execute_no_trans }; |
| 40 | |
| 41 | # Receive or send uevent messages. |
| 42 | neverallow ephemeral_app domain:netlink_kobject_uevent_socket *; |
| 43 | |
| 44 | # Receive or send generic netlink messages |
| 45 | neverallow ephemeral_app domain:netlink_socket *; |
| 46 | |
| 47 | # Too much leaky information in debugfs. It's a security |
| 48 | # best practice to ensure these files aren't readable. |
| 49 | neverallow ephemeral_app debugfs:file read; |
| 50 | |
| 51 | # execute gpu_device |
| 52 | neverallow ephemeral_app gpu_device:chr_file execute; |
| 53 | |
| 54 | # access files in /sys with the default sysfs label |
| 55 | neverallow ephemeral_app sysfs:file *; |
| 56 | |
| 57 | # Avoid reads from generically labeled /proc files |
| 58 | # Create a more specific label if needed |
| 59 | neverallow ephemeral_app proc:file { no_rw_file_perms no_x_file_perms }; |
Chad Brubaker | 3d348fd | 2017-01-19 10:42:40 -0800 | [diff] [blame] | 60 | |
| 61 | # Directly access external storage |
| 62 | neverallow ephemeral_app { sdcard_type media_rw_data_file }:file {open create}; |
| 63 | neverallow ephemeral_app { sdcard_type media_rw_data_file }:dir search; |