blob: e0547b6e5e971d5f75ba8695f89d4cf864643b28 [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.
24allow ephemeral_app app_data_file:file {r_file_perms execute};
25
Alex Klyubinbaeac1f2017-01-09 15:34:27 -080026# services
Chad Brubakerb93f0492017-03-29 14:53:09 -070027allow ephemeral_app audioserver_service:service_manager find;
28allow ephemeral_app cameraserver_service:service_manager find;
29allow ephemeral_app mediaserver_service:service_manager find;
30allow ephemeral_app mediaextractor_service:service_manager find;
31allow ephemeral_app mediacodec_service:service_manager find;
32allow ephemeral_app mediametrics_service:service_manager find;
Chad Brubakerd2b3a452017-05-30 10:17:34 -070033allow ephemeral_app mediadrmserver_service:service_manager find;
Marco Nelissen32359632017-10-04 16:18:27 -070034allow ephemeral_app drmserver_service:service_manager find;
Chad Brubaker5c566d12017-01-17 13:28:24 -080035allow ephemeral_app radio_service:service_manager find;
Alex Klyubin6237d8b2017-02-28 13:59:06 -080036allow ephemeral_app ephemeral_app_api_service:service_manager find;
Alex Klyubinbaeac1f2017-01-09 15:34:27 -080037
Primiano Tuccic80f9e02017-12-21 03:51:15 +010038# Write app-specific trace data to the Perfetto traced damon. This requires
39# connecting to its producer socket and obtaining a (per-process) tmpfs fd.
40allow ephemeral_app traced:fd use;
41allow ephemeral_app traced_tmpfs:file { read write getattr map };
42unix_socket_connect(ephemeral_app, traced_producer, traced)
43
Nathan Haroldee268642017-12-14 18:20:30 -080044# allow ephemeral apps to use UDP sockets provided by the system server but not
45# modify them other than to connect
46allow ephemeral_app system_server:udp_socket { connect getattr read recvfrom sendto write };
47
Alex Klyubinbaeac1f2017-01-09 15:34:27 -080048###
49### neverallow rules
50###
51
Chad Brubaker76506692017-10-25 12:41:11 -070052neverallow ephemeral_app app_data_file:file execute_no_trans;
Alex Klyubinbaeac1f2017-01-09 15:34:27 -080053
54# Receive or send uevent messages.
55neverallow ephemeral_app domain:netlink_kobject_uevent_socket *;
56
57# Receive or send generic netlink messages
58neverallow ephemeral_app domain:netlink_socket *;
59
60# Too much leaky information in debugfs. It's a security
61# best practice to ensure these files aren't readable.
62neverallow ephemeral_app debugfs:file read;
63
64# execute gpu_device
65neverallow ephemeral_app gpu_device:chr_file execute;
66
67# access files in /sys with the default sysfs label
68neverallow ephemeral_app sysfs:file *;
69
70# Avoid reads from generically labeled /proc files
71# Create a more specific label if needed
72neverallow ephemeral_app proc:file { no_rw_file_perms no_x_file_perms };
Chad Brubaker3d348fd2017-01-19 10:42:40 -080073
74# Directly access external storage
75neverallow ephemeral_app { sdcard_type media_rw_data_file }:file {open create};
76neverallow ephemeral_app { sdcard_type media_rw_data_file }:dir search;
Chad Brubakerc4a938e2017-03-15 14:26:18 -070077
78# Avoid reads to proc_net, it contains too much device wide information about
79# ongoing connections.
80neverallow ephemeral_app proc_net:file no_rw_file_perms;