xref: /aosp_15_r20/system/sepolicy/private/system_app.te (revision e4a36f4174b17bbab9dc043f4a65dc8d87377290)
1*e4a36f41SAndroid Build Coastguard Worker###
2*e4a36f41SAndroid Build Coastguard Worker### Apps that run with the system UID, e.g. com.android.system.ui,
3*e4a36f41SAndroid Build Coastguard Worker### com.android.settings.  These are not as privileged as the system
4*e4a36f41SAndroid Build Coastguard Worker### server.
5*e4a36f41SAndroid Build Coastguard Worker###
6*e4a36f41SAndroid Build Coastguard Worker
7*e4a36f41SAndroid Build Coastguard Workertypeattribute system_app coredomain, mlstrustedsubject;
8*e4a36f41SAndroid Build Coastguard Worker
9*e4a36f41SAndroid Build Coastguard Workerapp_domain(system_app)
10*e4a36f41SAndroid Build Coastguard Workernet_domain(system_app)
11*e4a36f41SAndroid Build Coastguard Workerbinder_service(system_app)
12*e4a36f41SAndroid Build Coastguard Worker
13*e4a36f41SAndroid Build Coastguard Worker# android.ui and system.ui
14*e4a36f41SAndroid Build Coastguard Workerallow system_app rootfs:dir getattr;
15*e4a36f41SAndroid Build Coastguard Worker
16*e4a36f41SAndroid Build Coastguard Worker# read/write certain subdirectories of /data/data for system UID apps.
17*e4a36f41SAndroid Build Coastguard Workerallow system_app system_app_data_file:dir create_dir_perms;
18*e4a36f41SAndroid Build Coastguard Workerallow system_app system_app_data_file:{ file lnk_file } create_file_perms;
19*e4a36f41SAndroid Build Coastguard Worker
20*e4a36f41SAndroid Build Coastguard Worker# Read and write to /data/misc/user.
21*e4a36f41SAndroid Build Coastguard Workerallow system_app misc_user_data_file:dir create_dir_perms;
22*e4a36f41SAndroid Build Coastguard Workerallow system_app misc_user_data_file:file create_file_perms;
23*e4a36f41SAndroid Build Coastguard Worker
24*e4a36f41SAndroid Build Coastguard Worker# Access to apex files stored on /data (b/136063500)
25*e4a36f41SAndroid Build Coastguard Worker# Needed so that Settings can access NOTICE files inside apex
26*e4a36f41SAndroid Build Coastguard Worker# files located in the assets/ directory.
27*e4a36f41SAndroid Build Coastguard Workerallow system_app apex_data_file:dir search;
28*e4a36f41SAndroid Build Coastguard Workerallow system_app staging_data_file:file r_file_perms;
29*e4a36f41SAndroid Build Coastguard Worker
30*e4a36f41SAndroid Build Coastguard Worker# Read wallpaper file.
31*e4a36f41SAndroid Build Coastguard Workerallow system_app wallpaper_file:file r_file_perms;
32*e4a36f41SAndroid Build Coastguard Worker
33*e4a36f41SAndroid Build Coastguard Worker# Read icon file.
34*e4a36f41SAndroid Build Coastguard Workerallow system_app icon_file:file r_file_perms;
35*e4a36f41SAndroid Build Coastguard Worker
36*e4a36f41SAndroid Build Coastguard Worker# Write to properties
37*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, adaptive_haptics_prop)
38*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, arm64_memtag_prop)
39*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, bluetooth_a2dp_offload_prop)
40*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, bluetooth_audio_hal_prop)
41*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, bluetooth_prop)
42*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, debug_prop)
43*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, system_prop)
44*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, exported_bluetooth_prop)
45*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, exported_system_prop)
46*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, exported3_system_prop)
47*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, gesture_prop)
48*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, locale_prop)
49*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, logd_prop)
50*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, net_radio_prop)
51*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, timezone_prop)
52*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, usb_control_prop)
53*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, usb_prop)
54*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, log_tag_prop)
55*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, drm_forcel3_prop)
56*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`set_prop(system_app, logpersistd_logging_prop)')
57*e4a36f41SAndroid Build Coastguard Workerauditallow system_app net_radio_prop:property_service set;
58*e4a36f41SAndroid Build Coastguard Workerauditallow system_app usb_control_prop:property_service set;
59*e4a36f41SAndroid Build Coastguard Workerauditallow system_app usb_prop:property_service set;
60*e4a36f41SAndroid Build Coastguard Worker# Allow Settings to enable Dynamic System Update
61*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, dynamic_system_prop)
62*e4a36f41SAndroid Build Coastguard Worker
63*e4a36f41SAndroid Build Coastguard Worker# ctl interface
64*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, ctl_default_prop)
65*e4a36f41SAndroid Build Coastguard Workerset_prop(system_app, ctl_bugreport_prop)
66*e4a36f41SAndroid Build Coastguard Worker
67*e4a36f41SAndroid Build Coastguard Worker# Allow developer settings to query gsid status
68*e4a36f41SAndroid Build Coastguard Workerget_prop(system_app, gsid_prop)
69*e4a36f41SAndroid Build Coastguard Worker
70*e4a36f41SAndroid Build Coastguard Worker# Allow developer settings to check 16k pages boot option status
71*e4a36f41SAndroid Build Coastguard Workerget_prop(system_app, enable_16k_pages_prop)
72*e4a36f41SAndroid Build Coastguard Worker
73*e4a36f41SAndroid Build Coastguard Worker# Create /data/anr/traces.txt.
74*e4a36f41SAndroid Build Coastguard Workerallow system_app anr_data_file:dir ra_dir_perms;
75*e4a36f41SAndroid Build Coastguard Workerallow system_app anr_data_file:file create_file_perms;
76*e4a36f41SAndroid Build Coastguard Worker
77*e4a36f41SAndroid Build Coastguard Worker# Settings need to access app name and icon from asec
78*e4a36f41SAndroid Build Coastguard Workerallow system_app asec_apk_file:file r_file_perms;
79*e4a36f41SAndroid Build Coastguard Worker
80*e4a36f41SAndroid Build Coastguard Worker# Allow system apps (like Settings) to interact with statsd
81*e4a36f41SAndroid Build Coastguard Workerbinder_call(system_app, statsd)
82*e4a36f41SAndroid Build Coastguard Worker
83*e4a36f41SAndroid Build Coastguard Worker# Allow system apps to interact with incidentd
84*e4a36f41SAndroid Build Coastguard Workerbinder_call(system_app, incidentd)
85*e4a36f41SAndroid Build Coastguard Worker
86*e4a36f41SAndroid Build Coastguard Worker# Allow system apps (Settings) to call into update_engine
87*e4a36f41SAndroid Build Coastguard Worker# in order to apply update to switch from 4k kernel to 16K and vice-versa
88*e4a36f41SAndroid Build Coastguard Workerbinder_use(system_app)
89*e4a36f41SAndroid Build Coastguard Workerallow system_app update_engine_stable_service:service_manager find;
90*e4a36f41SAndroid Build Coastguard Workerbinder_call(system_app, update_engine)
91*e4a36f41SAndroid Build Coastguard Worker
92*e4a36f41SAndroid Build Coastguard Worker# Allow system app to interact with Dumpstate HAL
93*e4a36f41SAndroid Build Coastguard Workerhal_client_domain(system_app, hal_dumpstate)
94*e4a36f41SAndroid Build Coastguard Worker
95*e4a36f41SAndroid Build Coastguard Workerallow system_app servicemanager:service_manager list;
96*e4a36f41SAndroid Build Coastguard Worker# TODO: scope this down? Too broad?
97*e4a36f41SAndroid Build Coastguard Workerallow system_app {
98*e4a36f41SAndroid Build Coastguard Worker  service_manager_type
99*e4a36f41SAndroid Build Coastguard Worker  -apex_service
100*e4a36f41SAndroid Build Coastguard Worker  -dnsresolver_service
101*e4a36f41SAndroid Build Coastguard Worker  -dumpstate_service
102*e4a36f41SAndroid Build Coastguard Worker  -installd_service
103*e4a36f41SAndroid Build Coastguard Worker  -lpdump_service
104*e4a36f41SAndroid Build Coastguard Worker  -mdns_service
105*e4a36f41SAndroid Build Coastguard Worker  -netd_service
106*e4a36f41SAndroid Build Coastguard Worker  -system_suspend_control_internal_service
107*e4a36f41SAndroid Build Coastguard Worker  -system_suspend_control_service
108*e4a36f41SAndroid Build Coastguard Worker  -tracingproxy_service
109*e4a36f41SAndroid Build Coastguard Worker  -virtual_touchpad_service
110*e4a36f41SAndroid Build Coastguard Worker  -vold_service
111*e4a36f41SAndroid Build Coastguard Worker  -default_android_service
112*e4a36f41SAndroid Build Coastguard Worker}:service_manager find;
113*e4a36f41SAndroid Build Coastguard Worker# suppress denials for services system_app should not be accessing.
114*e4a36f41SAndroid Build Coastguard Workerdontaudit system_app {
115*e4a36f41SAndroid Build Coastguard Worker  dnsresolver_service
116*e4a36f41SAndroid Build Coastguard Worker  dumpstate_service
117*e4a36f41SAndroid Build Coastguard Worker  installd_service
118*e4a36f41SAndroid Build Coastguard Worker  mdns_service
119*e4a36f41SAndroid Build Coastguard Worker  netd_service
120*e4a36f41SAndroid Build Coastguard Worker  virtual_touchpad_service
121*e4a36f41SAndroid Build Coastguard Worker  vold_service
122*e4a36f41SAndroid Build Coastguard Worker}:service_manager find;
123*e4a36f41SAndroid Build Coastguard Worker
124*e4a36f41SAndroid Build Coastguard Worker# suppress denials caused by debugfs_tracing
125*e4a36f41SAndroid Build Coastguard Workerdontaudit system_app debugfs_tracing:file rw_file_perms;
126*e4a36f41SAndroid Build Coastguard Worker
127*e4a36f41SAndroid Build Coastguard Worker# Ignore access to memory properties for Settings.
128*e4a36f41SAndroid Build Coastguard Workerdontaudit system_app proc_pagetypeinfo:file r_file_perms;
129*e4a36f41SAndroid Build Coastguard Workerdontaudit system_app sysfs_zram:dir search;
130*e4a36f41SAndroid Build Coastguard Worker
131*e4a36f41SAndroid Build Coastguard Workerallow system_app keystore:keystore2_key {
132*e4a36f41SAndroid Build Coastguard Worker    delete
133*e4a36f41SAndroid Build Coastguard Worker    get_info
134*e4a36f41SAndroid Build Coastguard Worker    grant
135*e4a36f41SAndroid Build Coastguard Worker    rebind
136*e4a36f41SAndroid Build Coastguard Worker    update
137*e4a36f41SAndroid Build Coastguard Worker    use
138*e4a36f41SAndroid Build Coastguard Worker};
139*e4a36f41SAndroid Build Coastguard Worker
140*e4a36f41SAndroid Build Coastguard Worker# Allow Settings to manage WI-FI keys.
141*e4a36f41SAndroid Build Coastguard Workerallow system_app wifi_key:keystore2_key {
142*e4a36f41SAndroid Build Coastguard Worker    delete
143*e4a36f41SAndroid Build Coastguard Worker    get_info
144*e4a36f41SAndroid Build Coastguard Worker    rebind
145*e4a36f41SAndroid Build Coastguard Worker    update
146*e4a36f41SAndroid Build Coastguard Worker    use
147*e4a36f41SAndroid Build Coastguard Worker};
148*e4a36f41SAndroid Build Coastguard Worker
149*e4a36f41SAndroid Build Coastguard Worker# settings app reads /proc/version
150*e4a36f41SAndroid Build Coastguard Workerallow system_app {
151*e4a36f41SAndroid Build Coastguard Worker  proc_version
152*e4a36f41SAndroid Build Coastguard Worker}:file r_file_perms;
153*e4a36f41SAndroid Build Coastguard Worker
154*e4a36f41SAndroid Build Coastguard Worker# Allow system apps to modify cgroup attributes and migrate processes
155*e4a36f41SAndroid Build Coastguard Workerallow system_app cgroup:file w_file_perms;
156*e4a36f41SAndroid Build Coastguard Workerallow system_app cgroup_v2:file w_file_perms;
157*e4a36f41SAndroid Build Coastguard Workerallow system_app cgroup_v2:dir w_dir_perms;
158*e4a36f41SAndroid Build Coastguard Worker
159*e4a36f41SAndroid Build Coastguard Workercontrol_logd(system_app)
160*e4a36f41SAndroid Build Coastguard Workerread_runtime_log_tags(system_app)
161*e4a36f41SAndroid Build Coastguard Workerget_prop(system_app, device_logging_prop)
162*e4a36f41SAndroid Build Coastguard Worker
163*e4a36f41SAndroid Build Coastguard Worker# allow system apps to use UDP sockets provided by the system server but not
164*e4a36f41SAndroid Build Coastguard Worker# modify them other than to connect
165*e4a36f41SAndroid Build Coastguard Workerallow system_app system_server:udp_socket {
166*e4a36f41SAndroid Build Coastguard Worker        connect getattr read recvfrom sendto write getopt setopt };
167*e4a36f41SAndroid Build Coastguard Worker
168*e4a36f41SAndroid Build Coastguard Worker# allow system apps to read game manager related sysrops
169*e4a36f41SAndroid Build Coastguard Workerget_prop(system_app, game_manager_config_prop)
170*e4a36f41SAndroid Build Coastguard Worker
171*e4a36f41SAndroid Build Coastguard Worker# Settings app reads ro.oem_unlock_supported
172*e4a36f41SAndroid Build Coastguard Workerget_prop(system_app, oem_unlock_prop)
173*e4a36f41SAndroid Build Coastguard Worker
174*e4a36f41SAndroid Build Coastguard Worker# Settings app reads ro.usb.uvc.enabled
175*e4a36f41SAndroid Build Coastguard Workerget_prop(system_app, usb_uvc_enabled_prop)
176*e4a36f41SAndroid Build Coastguard Worker
177*e4a36f41SAndroid Build Coastguard Worker# Settings app reads and writes the wifi blob database
178*e4a36f41SAndroid Build Coastguard Workerallow system_app connectivityblob_data_file:dir rw_dir_perms;
179*e4a36f41SAndroid Build Coastguard Workerallow system_app connectivityblob_data_file:file create_file_perms;
180*e4a36f41SAndroid Build Coastguard Worker
181*e4a36f41SAndroid Build Coastguard Worker###
182*e4a36f41SAndroid Build Coastguard Worker### Neverallow rules
183*e4a36f41SAndroid Build Coastguard Worker###
184*e4a36f41SAndroid Build Coastguard Worker
185*e4a36f41SAndroid Build Coastguard Worker# app domains which access /dev/fuse should not run as system_app
186*e4a36f41SAndroid Build Coastguard Workerneverallow system_app fuse_device:chr_file *;
187*e4a36f41SAndroid Build Coastguard Worker
188*e4a36f41SAndroid Build Coastguard Worker# Apps which run as UID=system should not rely on any attacker controlled
189*e4a36f41SAndroid Build Coastguard Worker# filesystem locations, such as /data/local/tmp. For /data/local/tmp, we
190*e4a36f41SAndroid Build Coastguard Worker# allow writes to files passed by file descriptor to support dumpstate and
191*e4a36f41SAndroid Build Coastguard Worker# bug reports, but not reads.
192*e4a36f41SAndroid Build Coastguard Workerneverallow system_app shell_data_file:dir { no_w_dir_perms open search read };
193*e4a36f41SAndroid Build Coastguard Workerneverallow system_app shell_data_file:file { open read ioctl lock };
194*e4a36f41SAndroid Build Coastguard Worker
195*e4a36f41SAndroid Build Coastguard Worker# system_app should be the only domain writing the adaptive haptics prop
196*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_app } adaptive_haptics_prop:property_service set;
197*e4a36f41SAndroid Build Coastguard Worker# system_app should be the only domain writing the force l3 prop
198*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_app } drm_forcel3_prop:property_service set;
199*e4a36f41SAndroid Build Coastguard Worker
200*e4a36f41SAndroid Build Coastguard Workerallow system_app vendor_boot_ota_file:dir { r_dir_perms };
201*e4a36f41SAndroid Build Coastguard Workerallow system_app vendor_boot_ota_file:file { r_file_perms };
202*e4a36f41SAndroid Build Coastguard Worker
203*e4a36f41SAndroid Build Coastguard Worker# allow system_app to read system_dlkm_file for /system_dlkm/etc/NOTICE.xml.gz
204*e4a36f41SAndroid Build Coastguard Workerallow system_app system_dlkm_file:dir search;
205*e4a36f41SAndroid Build Coastguard Workerallow system_app system_dlkm_file:file { getattr open read };
206