blob: 508653c1e1f7fb248895769e1e19ffd59f59342b [file] [log] [blame]
Alex Klyubinbaeac1f2017-01-09 15:34:27 -08001###
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 Klyubinf5446eb2017-03-23 14:27:32 -070014typeattribute ephemeral_app coredomain;
15
Alex Klyubinbaeac1f2017-01-09 15:34:27 -080016net_domain(ephemeral_app)
Chad Brubaker5c566d12017-01-17 13:28:24 -080017app_domain(ephemeral_app)
Alex Klyubinbaeac1f2017-01-09 15:34:27 -080018
Chad Brubaker3d348fd2017-01-19 10:42:40 -080019# Allow ephemeral apps to read/write files in visible storage if provided fds
20allow ephemeral_app { sdcard_type media_rw_data_file }:file {read write getattr ioctl lock append};
21
Chad Brubaker76506692017-10-25 12:41:11 -070022# Some apps ship with shared libraries and binaries that they write out
23# to their sandbox directory and then execute.
Nick Kralevich0eb0a162018-12-12 09:06:05 -080024allow ephemeral_app privapp_data_file:file { r_file_perms execute };
Nick Kralevich65a89c12018-12-21 10:03:50 -080025allow ephemeral_app app_data_file:file { r_file_perms execute };
Nick Kralevich0eb0a162018-12-12 09:06:05 -080026
Nick Kralevich87e91232019-01-24 13:05:03 -080027# Follow priv-app symlinks. This is used for dynamite functionality.
28allow ephemeral_app privapp_data_file:lnk_file r_file_perms;
29
Nick Kralevich0eb0a162018-12-12 09:06:05 -080030# Allow the renderscript compiler to be run.
31domain_auto_trans(ephemeral_app, rs_exec, rs)
32
Nick Kralevichfb66c6f2019-01-11 09:37:46 -080033# Allow loading and deleting shared libraries created by trusted system
34# components within an application home directory.
35allow ephemeral_app app_exec_data_file:file { r_file_perms execute unlink };
Chad Brubaker76506692017-10-25 12:41:11 -070036
Alex Klyubinbaeac1f2017-01-09 15:34:27 -080037# services
Chad Brubakerb93f0492017-03-29 14:53:09 -070038allow ephemeral_app audioserver_service:service_manager find;
39allow ephemeral_app cameraserver_service:service_manager find;
40allow ephemeral_app mediaserver_service:service_manager find;
41allow ephemeral_app mediaextractor_service:service_manager find;
Chad Brubakerb93f0492017-03-29 14:53:09 -070042allow ephemeral_app mediametrics_service:service_manager find;
Chad Brubakerd2b3a452017-05-30 10:17:34 -070043allow ephemeral_app mediadrmserver_service:service_manager find;
Marco Nelissen32359632017-10-04 16:18:27 -070044allow ephemeral_app drmserver_service:service_manager find;
Chad Brubaker5c566d12017-01-17 13:28:24 -080045allow ephemeral_app radio_service:service_manager find;
Alex Klyubin6237d8b2017-02-28 13:59:06 -080046allow ephemeral_app ephemeral_app_api_service:service_manager find;
Yiwei Zhang544d6b32019-02-07 15:00:55 -080047allow ephemeral_app gpu_service:service_manager find;
48
49# Allow ephemeral apps to interact with gpuservice
50binder_call(ephemeral_app, gpuservice)
Alex Klyubinbaeac1f2017-01-09 15:34:27 -080051
Primiano Tuccic80f9e02017-12-21 03:51:15 +010052# Write app-specific trace data to the Perfetto traced damon. This requires
53# connecting to its producer socket and obtaining a (per-process) tmpfs fd.
Florian Mayer5e522812019-10-08 16:15:14 +010054perfetto_producer(ephemeral_app)
Primiano Tuccic80f9e02017-12-21 03:51:15 +010055
Ryan Savitskica0690e2019-01-16 16:29:43 +000056# Allow heap profiling if the app opts in by being marked
57# profileable/debuggable.
58can_profile_heap(ephemeral_app)
59
Nathan Haroldee268642017-12-14 18:20:30 -080060# allow ephemeral apps to use UDP sockets provided by the system server but not
61# modify them other than to connect
Nathan Harold252b0152018-03-27 06:34:54 -070062allow ephemeral_app system_server:udp_socket {
63 connect getattr read recvfrom sendto write getopt setopt };
Nathan Haroldee268642017-12-14 18:20:30 -080064
Tri Vo19200ae2019-04-09 11:48:35 -070065allow ephemeral_app ashmem_device:chr_file rw_file_perms;
Tri Vo8b12ff52019-02-12 14:14:30 -080066
Alex Klyubinbaeac1f2017-01-09 15:34:27 -080067###
68### neverallow rules
69###
70
Nick Kralevich23c9d912018-08-02 15:54:23 -070071neverallow ephemeral_app { app_data_file privapp_data_file }:file execute_no_trans;
Alex Klyubinbaeac1f2017-01-09 15:34:27 -080072
73# Receive or send uevent messages.
74neverallow ephemeral_app domain:netlink_kobject_uevent_socket *;
75
76# Receive or send generic netlink messages
77neverallow ephemeral_app domain:netlink_socket *;
78
79# Too much leaky information in debugfs. It's a security
80# best practice to ensure these files aren't readable.
81neverallow ephemeral_app debugfs:file read;
82
83# execute gpu_device
84neverallow ephemeral_app gpu_device:chr_file execute;
85
86# access files in /sys with the default sysfs label
87neverallow ephemeral_app sysfs:file *;
88
89# Avoid reads from generically labeled /proc files
90# Create a more specific label if needed
91neverallow ephemeral_app proc:file { no_rw_file_perms no_x_file_perms };
Chad Brubaker3d348fd2017-01-19 10:42:40 -080092
93# Directly access external storage
94neverallow ephemeral_app { sdcard_type media_rw_data_file }:file {open create};
95neverallow ephemeral_app { sdcard_type media_rw_data_file }:dir search;
Chad Brubakerc4a938e2017-03-15 14:26:18 -070096
97# Avoid reads to proc_net, it contains too much device wide information about
98# ongoing connections.
99neverallow ephemeral_app proc_net:file no_rw_file_perms;