blob: 9a3f05f7592e7335748026e5aae8c341c600803e [file] [log] [blame]
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +00001###
2### sdk_sandbox_all
3###
4### This file defines the rules shared by all sdk_sandbox_all domains.
5### Apps are labeled based on mac_permissions.xml (maps signer and
6### optionally package name to seinfo value) and seapp_contexts (maps UID
7### and optionally seinfo value to domain for process and type for data
8### directory). The sdk_sandbox_all_all attribute is assigned to all default
9### seapp_contexts for any app with UID between FIRST_SDK_SANDBOX_UID (20000)
10### and LAST_SDK_SANDBOX_UID (29999) if the app has no specific seinfo
11### value as determined from mac_permissions.xml.
12
13allow sdk_sandbox_all system_linker_exec:file execute_no_trans;
14
15# Required to read CTS tests data from the shell_data_file location.
16allow sdk_sandbox_all shell_data_file:file r_file_perms;
17allow sdk_sandbox_all shell_data_file:dir r_dir_perms;
18
19# allow sdk sandbox to use UDP sockets provided by the system server but not
20# modify them other than to connect
21allow sdk_sandbox_all system_server:udp_socket {
22 connect getattr read recvfrom sendto write getopt setopt };
23
24# allow sandbox to search in sdk system server directory
25# additionally, for webview to work, getattr has been permitted
26allow sdk_sandbox_all sdk_sandbox_system_data_file:dir { getattr search };
27# allow sandbox to create files and dirs in sdk data directory
28allow sdk_sandbox_all sdk_sandbox_data_file:dir create_dir_perms;
29allow sdk_sandbox_all sdk_sandbox_data_file:file create_file_perms;
30
31###
32### neverallow rules
33###
34
35neverallow sdk_sandbox_all { app_data_file privapp_data_file sdk_sandbox_data_file }:file { execute execute_no_trans };
36
37# Receive or send uevent messages.
38neverallow sdk_sandbox_all domain:netlink_kobject_uevent_socket *;
39
40# Receive or send generic netlink messages
41neverallow sdk_sandbox_all domain:netlink_socket *;
42
43# Too much leaky information in debugfs. It's a security
44# best practice to ensure these files aren't readable.
45neverallow sdk_sandbox_all debugfs:file read;
46
47# execute gpu_device
48neverallow sdk_sandbox_all gpu_device:chr_file execute;
49
50# access files in /sys with the default sysfs label
51neverallow sdk_sandbox_all sysfs:file *;
52
53# Avoid reads from generically labeled /proc files
54# Create a more specific label if needed
55neverallow sdk_sandbox_all proc:file { no_rw_file_perms no_x_file_perms };
56
57# Directly access external storage
58neverallow sdk_sandbox_all { sdcard_type media_rw_data_file }:file {open create};
59neverallow sdk_sandbox_all { sdcard_type media_rw_data_file }:dir search;
60
61# Avoid reads to proc_net, it contains too much device wide information about
62# ongoing connections.
63neverallow sdk_sandbox_all proc_net:file no_rw_file_perms;
64
65# SDK sandbox processes have their own storage not related to app_data_file or privapp_data_file
66neverallow sdk_sandbox_all { app_data_file privapp_data_file }:dir no_rw_file_perms;
67neverallow sdk_sandbox_all { app_data_file privapp_data_file }:file no_rw_file_perms;
68
69# SDK sandbox processes don't have any access to external storage
70neverallow sdk_sandbox_all { media_rw_data_file }:dir no_rw_file_perms;
71neverallow sdk_sandbox_all { media_rw_data_file }:file no_rw_file_perms;
72
73neverallow { sdk_sandbox_all } tmpfs:dir no_rw_file_perms;
74
75neverallow sdk_sandbox_all hal_drm_service:service_manager find;
76
77# Only certain system components should have access to sdk_sandbox_system_data_file
78# sdk_sandbox only needs search. Restricted in follow up neverallow rule.
79neverallow {
80 domain
81 -init
82 -installd
83 -system_server
84 -vold_prepare_subdirs
85} sdk_sandbox_system_data_file:dir { relabelfrom };
86
87neverallow {
88 domain
89 -init
90 -installd
91 -sdk_sandbox_all
92 -system_server
93 -vold_prepare_subdirs
94 -zygote
95} sdk_sandbox_system_data_file:dir { create_dir_perms relabelto };
96
97# Only certain system components should have access to sdk_sandbox_all_system_data_file
98# sdk_sandbox_all only needs search. Restricted in follow up neverallow rule.
99neverallow {
100 domain
101 -init
102 -installd
103 -system_server
104 -vold_prepare_subdirs
105} sdk_sandbox_system_data_file:dir { relabelfrom };
106
107neverallow {
108 domain
109 -init
110 -installd
111 -sdk_sandbox_all
112 -system_server
113 -vold_prepare_subdirs
114 -zygote
115} sdk_sandbox_system_data_file:dir { create_dir_perms relabelto };
116
117# sdk_sandbox_all only needs to traverse through the sdk_sandbox_all_system_data_file
118neverallow sdk_sandbox_all sdk_sandbox_system_data_file:dir ~{ getattr search };
119
120# Only dirs should be created at sdk_sandbox_all_system_data_file level
121neverallow { domain -init } sdk_sandbox_system_data_file:file *;
122