blob: 3f4a49b5c0476cb2e606810bf6bbc6b8d6ca96d8 [file] [log] [blame]
Bram Bonneb93f26f2022-03-15 18:28:02 +01001###
2### SDK Sandbox process.
3###
4### This file defines the security policy for the sdk sandbox processes.
5
Lokesh Gidra1269a172022-08-01 17:20:38 +00006type sdk_sandbox, domain;
7
8typeattribute sdk_sandbox coredomain;
9
10net_domain(sdk_sandbox)
11app_domain(sdk_sandbox)
12
Lokesh Gidra1269a172022-08-01 17:20:38 +000013# Write app-specific trace data to the Perfetto traced damon. This requires
14# connecting to its producer socket and obtaining a (per-process) tmpfs fd.
15perfetto_producer(sdk_sandbox)
16
17# Allow profiling if the app opts in by being marked profileable/debuggable.
18can_profile_heap(sdk_sandbox)
19can_profile_perf(sdk_sandbox)
20
21# allow sdk sandbox to use UDP sockets provided by the system server but not
22# modify them other than to connect
23allow sdk_sandbox system_server:udp_socket {
24 connect getattr read recvfrom sendto write getopt setopt };
25
26# allow sandbox to search in sdk system server directory
27# additionally, for webview to work, getattr has been permitted
28allow sdk_sandbox sdk_sandbox_system_data_file:dir { getattr search };
29# allow sandbox to create files and dirs in sdk data directory
30allow sdk_sandbox sdk_sandbox_data_file:dir create_dir_perms;
31allow sdk_sandbox sdk_sandbox_data_file:file create_file_perms;
Bram Bonneb93f26f2022-03-15 18:28:02 +010032
33###
34### neverallow rules
35###
36
Bram Bonne078b43c2022-04-25 13:28:52 +020037neverallow sdk_sandbox { app_data_file privapp_data_file sdk_sandbox_data_file }:file { execute execute_no_trans };
Bram Bonneb93f26f2022-03-15 18:28:02 +010038
39# Receive or send uevent messages.
40neverallow sdk_sandbox domain:netlink_kobject_uevent_socket *;
41
42# Receive or send generic netlink messages
43neverallow sdk_sandbox domain:netlink_socket *;
44
45# Too much leaky information in debugfs. It's a security
46# best practice to ensure these files aren't readable.
47neverallow sdk_sandbox debugfs:file read;
48
49# execute gpu_device
50neverallow sdk_sandbox gpu_device:chr_file execute;
51
52# access files in /sys with the default sysfs label
53neverallow sdk_sandbox sysfs:file *;
54
55# Avoid reads from generically labeled /proc files
56# Create a more specific label if needed
57neverallow sdk_sandbox proc:file { no_rw_file_perms no_x_file_perms };
58
59# Directly access external storage
60neverallow sdk_sandbox { sdcard_type media_rw_data_file }:file {open create};
61neverallow sdk_sandbox { sdcard_type media_rw_data_file }:dir search;
62
63# Avoid reads to proc_net, it contains too much device wide information about
64# ongoing connections.
65neverallow sdk_sandbox proc_net:file no_rw_file_perms;
66
67# SDK sandbox processes have their own storage not related to app_data_file or privapp_data_file
68neverallow sdk_sandbox { app_data_file privapp_data_file }:dir no_rw_file_perms;
69neverallow sdk_sandbox { app_data_file privapp_data_file }:file no_rw_file_perms;
70
71# SDK sandbox processes don't have any access to external storage
72neverallow sdk_sandbox { media_rw_data_file }:dir no_rw_file_perms;
73neverallow sdk_sandbox { media_rw_data_file }:file no_rw_file_perms;
74
75neverallow { sdk_sandbox } tmpfs:dir no_rw_file_perms;
Bram Bonne85dfe312022-03-23 17:48:48 +010076
77neverallow sdk_sandbox hal_drm_service:service_manager find;
Mohammad Samiul Islamd2ffd352022-05-11 21:43:54 +010078
79# Only certain system components should have access to sdk_sandbox_system_data_file
80# sdk_sandbox only needs search. Restricted in follow up neverallow rule.
81neverallow {
82 domain
83 -init
84 -installd
Sanjana Sunil56301632022-05-20 11:24:32 +000085 -system_server
86 -vold_prepare_subdirs
87} sdk_sandbox_system_data_file:dir { relabelfrom };
88
89neverallow {
90 domain
91 -init
92 -installd
Mohammad Samiul Islamd2ffd352022-05-11 21:43:54 +010093 -sdk_sandbox
94 -system_server
95 -vold_prepare_subdirs
Sanjana Sunil56301632022-05-20 11:24:32 +000096 -zygote
97} sdk_sandbox_system_data_file:dir { create_dir_perms relabelto };
Mohammad Samiul Islamd2ffd352022-05-11 21:43:54 +010098
99# sdk_sandbox only needs to traverse through the sdk_sandbox_system_data_file
100neverallow sdk_sandbox sdk_sandbox_system_data_file:dir ~{ getattr search };
101
102# Only dirs should be created at sdk_sandbox_system_data_file level
103neverallow { domain -init } sdk_sandbox_system_data_file:file *;