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 | |
Alex Klyubin | f5446eb | 2017-03-23 14:27:32 -0700 | [diff] [blame] | 14 | typeattribute ephemeral_app coredomain; |
| 15 | |
Alex Klyubin | baeac1f | 2017-01-09 15:34:27 -0800 | [diff] [blame] | 16 | net_domain(ephemeral_app) |
Chad Brubaker | 5c566d1 | 2017-01-17 13:28:24 -0800 | [diff] [blame] | 17 | app_domain(ephemeral_app) |
Alex Klyubin | baeac1f | 2017-01-09 15:34:27 -0800 | [diff] [blame] | 18 | |
Chad Brubaker | 3d348fd | 2017-01-19 10:42:40 -0800 | [diff] [blame] | 19 | # Allow ephemeral apps to read/write files in visible storage if provided fds |
| 20 | allow ephemeral_app { sdcard_type media_rw_data_file }:file {read write getattr ioctl lock append}; |
| 21 | |
Chad Brubaker | 7650669 | 2017-10-25 12:41:11 -0700 | [diff] [blame] | 22 | # Some apps ship with shared libraries and binaries that they write out |
| 23 | # to their sandbox directory and then execute. |
Nick Kralevich | 0eb0a16 | 2018-12-12 09:06:05 -0800 | [diff] [blame] | 24 | allow ephemeral_app privapp_data_file:file { r_file_perms execute }; |
Nick Kralevich | 65a89c1 | 2018-12-21 10:03:50 -0800 | [diff] [blame] | 25 | allow ephemeral_app app_data_file:file { r_file_perms execute }; |
Nick Kralevich | 0eb0a16 | 2018-12-12 09:06:05 -0800 | [diff] [blame] | 26 | |
| 27 | # Allow the renderscript compiler to be run. |
| 28 | domain_auto_trans(ephemeral_app, rs_exec, rs) |
| 29 | |
| 30 | # Allow loading and deleting renderscript created shared libraries |
| 31 | # within an application home directory. |
| 32 | allow ephemeral_app rs_data_file:file { r_file_perms execute unlink }; |
Chad Brubaker | 7650669 | 2017-10-25 12:41:11 -0700 | [diff] [blame] | 33 | |
Alex Klyubin | baeac1f | 2017-01-09 15:34:27 -0800 | [diff] [blame] | 34 | # services |
Chad Brubaker | b93f049 | 2017-03-29 14:53:09 -0700 | [diff] [blame] | 35 | allow ephemeral_app audioserver_service:service_manager find; |
| 36 | allow ephemeral_app cameraserver_service:service_manager find; |
| 37 | allow ephemeral_app mediaserver_service:service_manager find; |
| 38 | allow ephemeral_app mediaextractor_service:service_manager find; |
| 39 | allow ephemeral_app mediacodec_service:service_manager find; |
| 40 | allow ephemeral_app mediametrics_service:service_manager find; |
Chad Brubaker | d2b3a45 | 2017-05-30 10:17:34 -0700 | [diff] [blame] | 41 | allow ephemeral_app mediadrmserver_service:service_manager find; |
Marco Nelissen | 3235963 | 2017-10-04 16:18:27 -0700 | [diff] [blame] | 42 | allow ephemeral_app drmserver_service:service_manager find; |
Chad Brubaker | 5c566d1 | 2017-01-17 13:28:24 -0800 | [diff] [blame] | 43 | allow ephemeral_app radio_service:service_manager find; |
Alex Klyubin | 6237d8b | 2017-02-28 13:59:06 -0800 | [diff] [blame] | 44 | allow ephemeral_app ephemeral_app_api_service:service_manager find; |
Alex Klyubin | baeac1f | 2017-01-09 15:34:27 -0800 | [diff] [blame] | 45 | |
Primiano Tucci | c80f9e0 | 2017-12-21 03:51:15 +0100 | [diff] [blame] | 46 | # Write app-specific trace data to the Perfetto traced damon. This requires |
| 47 | # connecting to its producer socket and obtaining a (per-process) tmpfs fd. |
| 48 | allow ephemeral_app traced:fd use; |
| 49 | allow ephemeral_app traced_tmpfs:file { read write getattr map }; |
| 50 | unix_socket_connect(ephemeral_app, traced_producer, traced) |
| 51 | |
Nathan Harold | ee26864 | 2017-12-14 18:20:30 -0800 | [diff] [blame] | 52 | # allow ephemeral apps to use UDP sockets provided by the system server but not |
| 53 | # modify them other than to connect |
Nathan Harold | 252b015 | 2018-03-27 06:34:54 -0700 | [diff] [blame] | 54 | allow ephemeral_app system_server:udp_socket { |
| 55 | connect getattr read recvfrom sendto write getopt setopt }; |
Nathan Harold | ee26864 | 2017-12-14 18:20:30 -0800 | [diff] [blame] | 56 | |
Alex Klyubin | baeac1f | 2017-01-09 15:34:27 -0800 | [diff] [blame] | 57 | ### |
| 58 | ### neverallow rules |
| 59 | ### |
| 60 | |
Nick Kralevich | 23c9d91 | 2018-08-02 15:54:23 -0700 | [diff] [blame] | 61 | neverallow ephemeral_app { app_data_file privapp_data_file }:file execute_no_trans; |
Alex Klyubin | baeac1f | 2017-01-09 15:34:27 -0800 | [diff] [blame] | 62 | |
| 63 | # Receive or send uevent messages. |
| 64 | neverallow ephemeral_app domain:netlink_kobject_uevent_socket *; |
| 65 | |
| 66 | # Receive or send generic netlink messages |
| 67 | neverallow ephemeral_app domain:netlink_socket *; |
| 68 | |
| 69 | # Too much leaky information in debugfs. It's a security |
| 70 | # best practice to ensure these files aren't readable. |
| 71 | neverallow ephemeral_app debugfs:file read; |
| 72 | |
| 73 | # execute gpu_device |
| 74 | neverallow ephemeral_app gpu_device:chr_file execute; |
| 75 | |
| 76 | # access files in /sys with the default sysfs label |
| 77 | neverallow ephemeral_app sysfs:file *; |
| 78 | |
| 79 | # Avoid reads from generically labeled /proc files |
| 80 | # Create a more specific label if needed |
| 81 | 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] | 82 | |
| 83 | # Directly access external storage |
| 84 | neverallow ephemeral_app { sdcard_type media_rw_data_file }:file {open create}; |
| 85 | neverallow ephemeral_app { sdcard_type media_rw_data_file }:dir search; |
Chad Brubaker | c4a938e | 2017-03-15 14:26:18 -0700 | [diff] [blame] | 86 | |
| 87 | # Avoid reads to proc_net, it contains too much device wide information about |
| 88 | # ongoing connections. |
| 89 | neverallow ephemeral_app proc_net:file no_rw_file_perms; |