xref: /aosp_15_r20/system/sepolicy/prebuilts/api/31.0/public/app.te (revision e4a36f4174b17bbab9dc043f4a65dc8d87377290)
1*e4a36f41SAndroid Build Coastguard Worker###
2*e4a36f41SAndroid Build Coastguard Worker### Domain for all zygote spawned apps
3*e4a36f41SAndroid Build Coastguard Worker###
4*e4a36f41SAndroid Build Coastguard Worker### This file is the base policy for all zygote spawned apps.
5*e4a36f41SAndroid Build Coastguard Worker### Other policy files, such as isolated_app.te, untrusted_app.te, etc
6*e4a36f41SAndroid Build Coastguard Worker### extend from this policy. Only policies which should apply to ALL
7*e4a36f41SAndroid Build Coastguard Worker### zygote spawned apps should be added here.
8*e4a36f41SAndroid Build Coastguard Worker###
9*e4a36f41SAndroid Build Coastguard Workertype appdomain_tmpfs, file_type;
10*e4a36f41SAndroid Build Coastguard Worker
11*e4a36f41SAndroid Build Coastguard Worker# WebView and other application-specific JIT compilers
12*e4a36f41SAndroid Build Coastguard Workerallow appdomain self:process execmem;
13*e4a36f41SAndroid Build Coastguard Worker
14*e4a36f41SAndroid Build Coastguard Workerallow appdomain { ashmem_device ashmem_libcutils_device }:chr_file execute;
15*e4a36f41SAndroid Build Coastguard Worker
16*e4a36f41SAndroid Build Coastguard Worker# Receive and use open file descriptors inherited from zygote.
17*e4a36f41SAndroid Build Coastguard Workerallow appdomain zygote:fd use;
18*e4a36f41SAndroid Build Coastguard Worker
19*e4a36f41SAndroid Build Coastguard Worker# Receive and use open file descriptors inherited from app zygote.
20*e4a36f41SAndroid Build Coastguard Workerallow appdomain app_zygote:fd use;
21*e4a36f41SAndroid Build Coastguard Worker
22*e4a36f41SAndroid Build Coastguard Worker# gdbserver for ndk-gdb reads the zygote.
23*e4a36f41SAndroid Build Coastguard Worker# valgrind needs mmap exec for zygote
24*e4a36f41SAndroid Build Coastguard Workerallow appdomain zygote_exec:file rx_file_perms;
25*e4a36f41SAndroid Build Coastguard Worker
26*e4a36f41SAndroid Build Coastguard Worker# Notify zygote of death;
27*e4a36f41SAndroid Build Coastguard Workerallow appdomain zygote:process sigchld;
28*e4a36f41SAndroid Build Coastguard Worker
29*e4a36f41SAndroid Build Coastguard Worker# Read /data/dalvik-cache.
30*e4a36f41SAndroid Build Coastguard Workerallow appdomain dalvikcache_data_file:dir { search getattr };
31*e4a36f41SAndroid Build Coastguard Workerallow appdomain dalvikcache_data_file:file r_file_perms;
32*e4a36f41SAndroid Build Coastguard Worker
33*e4a36f41SAndroid Build Coastguard Worker# Read the /sdcard and /mnt/sdcard symlinks
34*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } rootfs:lnk_file r_file_perms;
35*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } tmpfs:lnk_file r_file_perms;
36*e4a36f41SAndroid Build Coastguard Worker
37*e4a36f41SAndroid Build Coastguard Worker# Search /storage/emulated tmpfs mount.
38*e4a36f41SAndroid Build Coastguard Workerallow appdomain tmpfs:dir r_dir_perms;
39*e4a36f41SAndroid Build Coastguard Worker
40*e4a36f41SAndroid Build Coastguard Worker# Notify zygote of the wrapped process PID when using --invoke-with.
41*e4a36f41SAndroid Build Coastguard Workerallow appdomain zygote:fifo_file write;
42*e4a36f41SAndroid Build Coastguard Worker
43*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
44*e4a36f41SAndroid Build Coastguard Worker  # Allow apps to create and write method traces in /data/misc/trace.
45*e4a36f41SAndroid Build Coastguard Worker  allow appdomain method_trace_data_file:dir w_dir_perms;
46*e4a36f41SAndroid Build Coastguard Worker  allow appdomain method_trace_data_file:file { create w_file_perms };
47*e4a36f41SAndroid Build Coastguard Worker')
48*e4a36f41SAndroid Build Coastguard Worker
49*e4a36f41SAndroid Build Coastguard Worker# Notify shell and adbd of death when spawned via runas for ndk-gdb.
50*e4a36f41SAndroid Build Coastguard Workerallow appdomain shell:process sigchld;
51*e4a36f41SAndroid Build Coastguard Workerallow appdomain adbd:process sigchld;
52*e4a36f41SAndroid Build Coastguard Worker
53*e4a36f41SAndroid Build Coastguard Worker# child shell or gdbserver pty access for runas.
54*e4a36f41SAndroid Build Coastguard Workerallow appdomain devpts:chr_file { getattr read write ioctl };
55*e4a36f41SAndroid Build Coastguard Worker
56*e4a36f41SAndroid Build Coastguard Worker# Use pipes and sockets provided by system_server via binder or local socket.
57*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_server:fd use;
58*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_server:fifo_file rw_file_perms;
59*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_server:unix_stream_socket { read write setopt getattr getopt shutdown };
60*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_server:tcp_socket { read write getattr getopt shutdown };
61*e4a36f41SAndroid Build Coastguard Worker
62*e4a36f41SAndroid Build Coastguard Worker# For AppFuse.
63*e4a36f41SAndroid Build Coastguard Workerallow appdomain vold:fd use;
64*e4a36f41SAndroid Build Coastguard Worker
65*e4a36f41SAndroid Build Coastguard Worker# Communication with other apps via fifos
66*e4a36f41SAndroid Build Coastguard Workerallow appdomain appdomain:fifo_file rw_file_perms;
67*e4a36f41SAndroid Build Coastguard Worker
68*e4a36f41SAndroid Build Coastguard Worker# Communicate with surfaceflinger.
69*e4a36f41SAndroid Build Coastguard Workerallow appdomain surfaceflinger:unix_stream_socket { read write setopt getattr getopt shutdown };
70*e4a36f41SAndroid Build Coastguard Worker
71*e4a36f41SAndroid Build Coastguard Worker# App sandbox file accesses.
72*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -mlstrustedsubject } { app_data_file privapp_data_file }:dir create_dir_perms;
73*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -mlstrustedsubject } { app_data_file privapp_data_file }:file create_file_perms;
74*e4a36f41SAndroid Build Coastguard Worker
75*e4a36f41SAndroid Build Coastguard Worker# Access via already open fds is ok even for mlstrustedsubject.
76*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } { app_data_file privapp_data_file system_app_data_file }:file { getattr map read write };
77*e4a36f41SAndroid Build Coastguard Worker
78*e4a36f41SAndroid Build Coastguard Worker# Traverse into expanded storage
79*e4a36f41SAndroid Build Coastguard Workerallow appdomain mnt_expand_file:dir r_dir_perms;
80*e4a36f41SAndroid Build Coastguard Worker
81*e4a36f41SAndroid Build Coastguard Worker# Keychain and user-trusted credentials
82*e4a36f41SAndroid Build Coastguard Workerr_dir_file(appdomain, keychain_data_file)
83*e4a36f41SAndroid Build Coastguard Workerallow appdomain misc_user_data_file:dir r_dir_perms;
84*e4a36f41SAndroid Build Coastguard Workerallow appdomain misc_user_data_file:file r_file_perms;
85*e4a36f41SAndroid Build Coastguard Worker
86*e4a36f41SAndroid Build Coastguard Worker# TextClassifier
87*e4a36f41SAndroid Build Coastguard Workerr_dir_file({ appdomain -isolated_app }, textclassifier_data_file)
88*e4a36f41SAndroid Build Coastguard Worker
89*e4a36f41SAndroid Build Coastguard Worker# Access to OEM provided data and apps
90*e4a36f41SAndroid Build Coastguard Workerallow appdomain oemfs:dir r_dir_perms;
91*e4a36f41SAndroid Build Coastguard Workerallow appdomain oemfs:file rx_file_perms;
92*e4a36f41SAndroid Build Coastguard Worker
93*e4a36f41SAndroid Build Coastguard Worker# Execute the shell or other system executables.
94*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -ephemeral_app } shell_exec:file rx_file_perms;
95*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -ephemeral_app } toolbox_exec:file rx_file_perms;
96*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_file:file x_file_perms;
97*e4a36f41SAndroid Build Coastguard Workernot_full_treble(`allow { appdomain -ephemeral_app } vendor_file:file x_file_perms;')
98*e4a36f41SAndroid Build Coastguard Worker
99*e4a36f41SAndroid Build Coastguard Worker# Renderscript needs the ability to read directories on /system
100*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_file:dir r_dir_perms;
101*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_file:lnk_file { getattr open read };
102*e4a36f41SAndroid Build Coastguard Worker# Renderscript specific permissions to open /system/vendor/lib64.
103*e4a36f41SAndroid Build Coastguard Workernot_full_treble(`
104*e4a36f41SAndroid Build Coastguard Worker    allow appdomain vendor_file_type:dir r_dir_perms;
105*e4a36f41SAndroid Build Coastguard Worker    allow appdomain vendor_file_type:lnk_file { getattr open read };
106*e4a36f41SAndroid Build Coastguard Worker')
107*e4a36f41SAndroid Build Coastguard Worker
108*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(`
109*e4a36f41SAndroid Build Coastguard Worker    # For looking up Renderscript vendor drivers
110*e4a36f41SAndroid Build Coastguard Worker    allow { appdomain -isolated_app } vendor_file:dir { open read };
111*e4a36f41SAndroid Build Coastguard Worker')
112*e4a36f41SAndroid Build Coastguard Worker
113*e4a36f41SAndroid Build Coastguard Worker# Allow apps access to /vendor/app except for privileged
114*e4a36f41SAndroid Build Coastguard Worker# apps which cannot be in /vendor.
115*e4a36f41SAndroid Build Coastguard Workerr_dir_file({ appdomain -ephemeral_app }, vendor_app_file)
116*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -ephemeral_app } vendor_app_file:file execute;
117*e4a36f41SAndroid Build Coastguard Worker
118*e4a36f41SAndroid Build Coastguard Worker# Allow apps access to /vendor/overlay
119*e4a36f41SAndroid Build Coastguard Workerr_dir_file(appdomain, vendor_overlay_file)
120*e4a36f41SAndroid Build Coastguard Worker
121*e4a36f41SAndroid Build Coastguard Worker# Allow apps access to /vendor/framework
122*e4a36f41SAndroid Build Coastguard Worker# for vendor provided libraries.
123*e4a36f41SAndroid Build Coastguard Workerr_dir_file(appdomain, vendor_framework_file)
124*e4a36f41SAndroid Build Coastguard Worker
125*e4a36f41SAndroid Build Coastguard Worker# Allow apps read / execute access to vendor public libraries.
126*e4a36f41SAndroid Build Coastguard Workerallow appdomain {vendor_public_framework_file vendor_public_lib_file}:dir r_dir_perms;
127*e4a36f41SAndroid Build Coastguard Workerallow appdomain {vendor_public_framework_file vendor_public_lib_file}:file { execute read open getattr map };
128*e4a36f41SAndroid Build Coastguard Worker
129*e4a36f41SAndroid Build Coastguard Worker# Read/write wallpaper file (opened by system).
130*e4a36f41SAndroid Build Coastguard Workerallow appdomain wallpaper_file:file { getattr read write map };
131*e4a36f41SAndroid Build Coastguard Worker
132*e4a36f41SAndroid Build Coastguard Worker# Read/write cached ringtones (opened by system).
133*e4a36f41SAndroid Build Coastguard Workerallow appdomain ringtone_file:file { getattr read write map };
134*e4a36f41SAndroid Build Coastguard Worker
135*e4a36f41SAndroid Build Coastguard Worker# Read ShortcutManager icon files (opened by system).
136*e4a36f41SAndroid Build Coastguard Workerallow appdomain shortcut_manager_icons:file { getattr read map };
137*e4a36f41SAndroid Build Coastguard Worker
138*e4a36f41SAndroid Build Coastguard Worker# Read icon file (opened by system).
139*e4a36f41SAndroid Build Coastguard Workerallow appdomain icon_file:file { getattr read map };
140*e4a36f41SAndroid Build Coastguard Worker
141*e4a36f41SAndroid Build Coastguard Worker# Old stack dumping scheme : append to a global trace file (/data/anr/traces.txt).
142*e4a36f41SAndroid Build Coastguard Worker#
143*e4a36f41SAndroid Build Coastguard Worker# TODO: All of these permissions except for anr_data_file:file append can be
144*e4a36f41SAndroid Build Coastguard Worker# withdrawn once we've switched to the new stack dumping mechanism, see b/32064548
145*e4a36f41SAndroid Build Coastguard Worker# and the rules below.
146*e4a36f41SAndroid Build Coastguard Workerallow appdomain anr_data_file:dir search;
147*e4a36f41SAndroid Build Coastguard Workerallow appdomain anr_data_file:file { open append };
148*e4a36f41SAndroid Build Coastguard Worker
149*e4a36f41SAndroid Build Coastguard Worker# New stack dumping scheme : request an output FD from tombstoned via a unix
150*e4a36f41SAndroid Build Coastguard Worker# domain socket.
151*e4a36f41SAndroid Build Coastguard Worker#
152*e4a36f41SAndroid Build Coastguard Worker# Allow apps to connect and write to the tombstoned java trace socket in
153*e4a36f41SAndroid Build Coastguard Worker# order to dump their traces. Also allow them to append traces to pipes
154*e4a36f41SAndroid Build Coastguard Worker# created by dumptrace. (Also see the rules below where they are given
155*e4a36f41SAndroid Build Coastguard Worker# additional permissions to dumpstate pipes for other aspects of bug report
156*e4a36f41SAndroid Build Coastguard Worker# creation).
157*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(appdomain, tombstoned_java_trace, tombstoned)
158*e4a36f41SAndroid Build Coastguard Workerallow appdomain tombstoned:fd use;
159*e4a36f41SAndroid Build Coastguard Workerallow appdomain dumpstate:fifo_file append;
160*e4a36f41SAndroid Build Coastguard Workerallow appdomain incidentd:fifo_file append;
161*e4a36f41SAndroid Build Coastguard Worker
162*e4a36f41SAndroid Build Coastguard Worker# Allow apps to send dump information to dumpstate
163*e4a36f41SAndroid Build Coastguard Workerallow appdomain dumpstate:fd use;
164*e4a36f41SAndroid Build Coastguard Workerallow appdomain dumpstate:unix_stream_socket { read write getopt getattr shutdown };
165*e4a36f41SAndroid Build Coastguard Workerallow appdomain dumpstate:fifo_file { write getattr };
166*e4a36f41SAndroid Build Coastguard Workerallow appdomain shell_data_file:file { write getattr };
167*e4a36f41SAndroid Build Coastguard Worker
168*e4a36f41SAndroid Build Coastguard Worker# Allow apps to send dump information to incidentd
169*e4a36f41SAndroid Build Coastguard Workerallow appdomain incidentd:fd use;
170*e4a36f41SAndroid Build Coastguard Workerallow appdomain incidentd:fifo_file { write getattr };
171*e4a36f41SAndroid Build Coastguard Worker
172*e4a36f41SAndroid Build Coastguard Worker# Allow apps to send information to statsd socket.
173*e4a36f41SAndroid Build Coastguard Workerunix_socket_send(appdomain, statsdw, statsd)
174*e4a36f41SAndroid Build Coastguard Worker
175*e4a36f41SAndroid Build Coastguard Worker# Write profiles /data/misc/profiles
176*e4a36f41SAndroid Build Coastguard Workerallow appdomain user_profile_root_file:dir search;
177*e4a36f41SAndroid Build Coastguard Workerallow appdomain user_profile_data_file:dir { search write add_name };
178*e4a36f41SAndroid Build Coastguard Workerallow appdomain user_profile_data_file:file create_file_perms;
179*e4a36f41SAndroid Build Coastguard Worker
180*e4a36f41SAndroid Build Coastguard Worker# Send heap dumps to system_server via an already open file descriptor
181*e4a36f41SAndroid Build Coastguard Worker# % adb shell am set-watch-heap com.android.systemui 1048576
182*e4a36f41SAndroid Build Coastguard Worker# % adb shell dumpsys procstats --start-testing
183*e4a36f41SAndroid Build Coastguard Worker# debuggable builds only.
184*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
185*e4a36f41SAndroid Build Coastguard Worker  allow appdomain heapdump_data_file:file append;
186*e4a36f41SAndroid Build Coastguard Worker')
187*e4a36f41SAndroid Build Coastguard Worker
188*e4a36f41SAndroid Build Coastguard Worker# /proc/net access.
189*e4a36f41SAndroid Build Coastguard Worker# TODO(b/9496886) Audit access for removal.
190*e4a36f41SAndroid Build Coastguard Worker# proc_net access for the negated domains below is granted (or not) in their
191*e4a36f41SAndroid Build Coastguard Worker# individual .te files.
192*e4a36f41SAndroid Build Coastguard Workerr_dir_file({
193*e4a36f41SAndroid Build Coastguard Worker  appdomain
194*e4a36f41SAndroid Build Coastguard Worker  -ephemeral_app
195*e4a36f41SAndroid Build Coastguard Worker  -isolated_app
196*e4a36f41SAndroid Build Coastguard Worker  -platform_app
197*e4a36f41SAndroid Build Coastguard Worker  -priv_app
198*e4a36f41SAndroid Build Coastguard Worker  -shell
199*e4a36f41SAndroid Build Coastguard Worker  -system_app
200*e4a36f41SAndroid Build Coastguard Worker  -untrusted_app_all
201*e4a36f41SAndroid Build Coastguard Worker}, proc_net_type)
202*e4a36f41SAndroid Build Coastguard Worker# audit access for all these non-core app domains.
203*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
204*e4a36f41SAndroid Build Coastguard Worker  auditallow {
205*e4a36f41SAndroid Build Coastguard Worker    appdomain
206*e4a36f41SAndroid Build Coastguard Worker    -ephemeral_app
207*e4a36f41SAndroid Build Coastguard Worker    -isolated_app
208*e4a36f41SAndroid Build Coastguard Worker    -platform_app
209*e4a36f41SAndroid Build Coastguard Worker    -priv_app
210*e4a36f41SAndroid Build Coastguard Worker    -shell
211*e4a36f41SAndroid Build Coastguard Worker    -su
212*e4a36f41SAndroid Build Coastguard Worker    -system_app
213*e4a36f41SAndroid Build Coastguard Worker    -untrusted_app_all
214*e4a36f41SAndroid Build Coastguard Worker  } proc_net_type:{ dir file lnk_file } { getattr open read };
215*e4a36f41SAndroid Build Coastguard Worker')
216*e4a36f41SAndroid Build Coastguard Worker
217*e4a36f41SAndroid Build Coastguard Worker# Grant GPU access to all processes started by Zygote.
218*e4a36f41SAndroid Build Coastguard Worker# They need that to render the standard UI.
219*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } gpu_device:chr_file rw_file_perms;
220*e4a36f41SAndroid Build Coastguard Worker
221*e4a36f41SAndroid Build Coastguard Worker# Use the Binder.
222*e4a36f41SAndroid Build Coastguard Workerbinder_use(appdomain)
223*e4a36f41SAndroid Build Coastguard Worker# Perform binder IPC to binder services.
224*e4a36f41SAndroid Build Coastguard Workerbinder_call(appdomain, binderservicedomain)
225*e4a36f41SAndroid Build Coastguard Worker# Perform binder IPC to other apps.
226*e4a36f41SAndroid Build Coastguard Workerbinder_call(appdomain, appdomain)
227*e4a36f41SAndroid Build Coastguard Worker# Perform binder IPC to ephemeral apps.
228*e4a36f41SAndroid Build Coastguard Workerbinder_call(appdomain, ephemeral_app)
229*e4a36f41SAndroid Build Coastguard Worker# Perform binder IPC to gpuservice.
230*e4a36f41SAndroid Build Coastguard Workerbinder_call({ appdomain -isolated_app }, gpuservice)
231*e4a36f41SAndroid Build Coastguard Worker
232*e4a36f41SAndroid Build Coastguard Worker# Talk with graphics composer fences
233*e4a36f41SAndroid Build Coastguard Workerallow appdomain hal_graphics_composer:fd use;
234*e4a36f41SAndroid Build Coastguard Worker
235*e4a36f41SAndroid Build Coastguard Worker# Already connected, unnamed sockets being passed over some other IPC
236*e4a36f41SAndroid Build Coastguard Worker# hence no sock_file or connectto permission. This appears to be how
237*e4a36f41SAndroid Build Coastguard Worker# Chrome works, may need to be updated as more apps using isolated services
238*e4a36f41SAndroid Build Coastguard Worker# are examined.
239*e4a36f41SAndroid Build Coastguard Workerallow appdomain appdomain:unix_stream_socket { getopt getattr read write shutdown };
240*e4a36f41SAndroid Build Coastguard Worker
241*e4a36f41SAndroid Build Coastguard Worker# Backup ability for every app. BMS opens and passes the fd
242*e4a36f41SAndroid Build Coastguard Worker# to any app that has backup ability. Hence, no open permissions here.
243*e4a36f41SAndroid Build Coastguard Workerallow appdomain backup_data_file:file { read write getattr map };
244*e4a36f41SAndroid Build Coastguard Workerallow appdomain cache_backup_file:file { read write getattr map };
245*e4a36f41SAndroid Build Coastguard Workerallow appdomain cache_backup_file:dir getattr;
246*e4a36f41SAndroid Build Coastguard Worker# Backup ability using 'adb backup'
247*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_data_file:lnk_file r_file_perms;
248*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_data_file:file { getattr read map };
249*e4a36f41SAndroid Build Coastguard Worker
250*e4a36f41SAndroid Build Coastguard Worker# Allow read/stat of /data/media files passed by Binder or local socket IPC.
251*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } media_rw_data_file:file { read getattr };
252*e4a36f41SAndroid Build Coastguard Worker
253*e4a36f41SAndroid Build Coastguard Worker# Read and write /data/data/com.android.providers.telephony files passed over Binder.
254*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } radio_data_file:file { read write getattr };
255*e4a36f41SAndroid Build Coastguard Worker
256*e4a36f41SAndroid Build Coastguard Worker# Allow access to external storage; we have several visible mount points under /storage
257*e4a36f41SAndroid Build Coastguard Worker# and symlinks to primary storage at places like /storage/sdcard0 and /mnt/user/0/primary
258*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app } storage_file:dir r_dir_perms;
259*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app } storage_file:lnk_file r_file_perms;
260*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app } mnt_user_file:dir r_dir_perms;
261*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app } mnt_user_file:lnk_file r_file_perms;
262*e4a36f41SAndroid Build Coastguard Worker
263*e4a36f41SAndroid Build Coastguard Worker# Read/write visible storage
264*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app } sdcard_type:dir create_dir_perms;
265*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app } sdcard_type:file create_file_perms;
266*e4a36f41SAndroid Build Coastguard Worker# This should be removed if sdcardfs is modified to alter the secontext for its
267*e4a36f41SAndroid Build Coastguard Worker# accesses to the underlying FS.
268*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app } media_rw_data_file:dir create_dir_perms;
269*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app } media_rw_data_file:file create_file_perms;
270*e4a36f41SAndroid Build Coastguard Worker
271*e4a36f41SAndroid Build Coastguard Worker# Allow apps to use the USB Accessory interface.
272*e4a36f41SAndroid Build Coastguard Worker# http://developer.android.com/guide/topics/connectivity/usb/accessory.html
273*e4a36f41SAndroid Build Coastguard Worker#
274*e4a36f41SAndroid Build Coastguard Worker# USB devices are first opened by the system server (USBDeviceManagerService)
275*e4a36f41SAndroid Build Coastguard Worker# and the file descriptor is passed to the right Activity via binder.
276*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app } usb_device:chr_file { read write getattr ioctl };
277*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app } usbaccessory_device:chr_file { read write getattr };
278*e4a36f41SAndroid Build Coastguard Worker
279*e4a36f41SAndroid Build Coastguard Worker# For art.
280*e4a36f41SAndroid Build Coastguard Workerallow appdomain dalvikcache_data_file:file execute;
281*e4a36f41SAndroid Build Coastguard Workerallow appdomain dalvikcache_data_file:lnk_file r_file_perms;
282*e4a36f41SAndroid Build Coastguard Worker
283*e4a36f41SAndroid Build Coastguard Worker# Allow any app to read shared RELRO files.
284*e4a36f41SAndroid Build Coastguard Workerallow appdomain shared_relro_file:dir search;
285*e4a36f41SAndroid Build Coastguard Workerallow appdomain shared_relro_file:file r_file_perms;
286*e4a36f41SAndroid Build Coastguard Worker
287*e4a36f41SAndroid Build Coastguard Worker# Allow apps to read/execute installed binaries
288*e4a36f41SAndroid Build Coastguard Workerallow appdomain apk_data_file:dir r_dir_perms;
289*e4a36f41SAndroid Build Coastguard Workerallow appdomain apk_data_file:file rx_file_perms;
290*e4a36f41SAndroid Build Coastguard Worker
291*e4a36f41SAndroid Build Coastguard Worker# /data/resource-cache
292*e4a36f41SAndroid Build Coastguard Workerallow appdomain resourcecache_data_file:file r_file_perms;
293*e4a36f41SAndroid Build Coastguard Workerallow appdomain resourcecache_data_file:dir r_dir_perms;
294*e4a36f41SAndroid Build Coastguard Worker
295*e4a36f41SAndroid Build Coastguard Worker# logd access
296*e4a36f41SAndroid Build Coastguard Workerread_logd(appdomain)
297*e4a36f41SAndroid Build Coastguard Workercontrol_logd({ appdomain -ephemeral_app })
298*e4a36f41SAndroid Build Coastguard Worker# application inherit logd write socket (urge is to deprecate this long term)
299*e4a36f41SAndroid Build Coastguard Workerallow appdomain zygote:unix_dgram_socket write;
300*e4a36f41SAndroid Build Coastguard Worker
301*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app } keystore:keystore_key { get_state get insert delete exist list sign verify };
302*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app } keystore:keystore2_key { delete use get_info rebind update };
303*e4a36f41SAndroid Build Coastguard Worker
304*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app } keystore_maintenance_service:service_manager find;
305*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app } keystore:keystore2 get_state;
306*e4a36f41SAndroid Build Coastguard Worker
307*e4a36f41SAndroid Build Coastguard Workeruse_keystore({ appdomain -isolated_app -ephemeral_app })
308*e4a36f41SAndroid Build Coastguard Worker
309*e4a36f41SAndroid Build Coastguard Workeruse_credstore({ appdomain -isolated_app -ephemeral_app })
310*e4a36f41SAndroid Build Coastguard Worker
311*e4a36f41SAndroid Build Coastguard Workerallow appdomain console_device:chr_file { read write };
312*e4a36f41SAndroid Build Coastguard Worker
313*e4a36f41SAndroid Build Coastguard Worker# only allow unprivileged socket ioctl commands
314*e4a36f41SAndroid Build Coastguard Workerallowxperm { appdomain -bluetooth } self:{ rawip_socket tcp_socket udp_socket }
315*e4a36f41SAndroid Build Coastguard Worker  ioctl { unpriv_sock_ioctls unpriv_tty_ioctls };
316*e4a36f41SAndroid Build Coastguard Worker
317*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } ion_device:chr_file r_file_perms;
318*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } dmabuf_system_heap_device:chr_file r_file_perms;
319*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } dmabuf_system_secure_heap_device:chr_file r_file_perms;
320*e4a36f41SAndroid Build Coastguard Worker
321*e4a36f41SAndroid Build Coastguard Worker# Allow AAudio apps to use shared memory file descriptors from the HAL
322*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } hal_audio:fd use;
323*e4a36f41SAndroid Build Coastguard Worker
324*e4a36f41SAndroid Build Coastguard Worker# Allow app to access shared memory created by camera HAL1
325*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } hal_camera:fd use;
326*e4a36f41SAndroid Build Coastguard Worker
327*e4a36f41SAndroid Build Coastguard Worker# Allow apps to access shared memory file descriptor from the tuner HAL
328*e4a36f41SAndroid Build Coastguard Workerallow {appdomain -isolated_app} hal_tv_tuner_server:fd use;
329*e4a36f41SAndroid Build Coastguard Worker
330*e4a36f41SAndroid Build Coastguard Worker# RenderScript always-passthrough HAL
331*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } hal_renderscript_hwservice:hwservice_manager find;
332*e4a36f41SAndroid Build Coastguard Workerallow appdomain same_process_hal_file:file { execute read open getattr map };
333*e4a36f41SAndroid Build Coastguard Worker
334*e4a36f41SAndroid Build Coastguard Worker# TODO: switch to meminfo service
335*e4a36f41SAndroid Build Coastguard Workerallow appdomain proc_meminfo:file r_file_perms;
336*e4a36f41SAndroid Build Coastguard Worker
337*e4a36f41SAndroid Build Coastguard Worker# For app fuse.
338*e4a36f41SAndroid Build Coastguard Workerallow appdomain app_fuse_file:file { getattr read append write map };
339*e4a36f41SAndroid Build Coastguard Worker
340*e4a36f41SAndroid Build Coastguard Workerpdx_client({ appdomain -isolated_app -ephemeral_app }, display_client)
341*e4a36f41SAndroid Build Coastguard Workerpdx_client({ appdomain -isolated_app -ephemeral_app }, display_manager)
342*e4a36f41SAndroid Build Coastguard Workerpdx_client({ appdomain -isolated_app -ephemeral_app }, display_vsync)
343*e4a36f41SAndroid Build Coastguard Workerpdx_client({ appdomain -isolated_app -ephemeral_app }, performance_client)
344*e4a36f41SAndroid Build Coastguard Worker# Apps do not directly open the IPC socket for bufferhubd.
345*e4a36f41SAndroid Build Coastguard Workerpdx_use({ appdomain -isolated_app -ephemeral_app }, bufferhub_client)
346*e4a36f41SAndroid Build Coastguard Worker
347*e4a36f41SAndroid Build Coastguard Worker###
348*e4a36f41SAndroid Build Coastguard Worker### CTS-specific rules
349*e4a36f41SAndroid Build Coastguard Worker###
350*e4a36f41SAndroid Build Coastguard Worker
351*e4a36f41SAndroid Build Coastguard Worker# For cts/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java.
352*e4a36f41SAndroid Build Coastguard Worker# testRunAsHasCorrectCapabilities
353*e4a36f41SAndroid Build Coastguard Workerallow appdomain runas_exec:file getattr;
354*e4a36f41SAndroid Build Coastguard Worker# Others are either allowed elsewhere or not desired.
355*e4a36f41SAndroid Build Coastguard Worker
356*e4a36f41SAndroid Build Coastguard Worker# Apps receive an open tun fd from the framework for
357*e4a36f41SAndroid Build Coastguard Worker# device traffic. Do not allow untrusted app to directly open tun_device
358*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app } tun_device:chr_file { read write getattr append ioctl };
359*e4a36f41SAndroid Build Coastguard Workerallowxperm { appdomain -isolated_app -ephemeral_app } tun_device:chr_file ioctl TUNGETIFF;
360*e4a36f41SAndroid Build Coastguard Worker
361*e4a36f41SAndroid Build Coastguard Worker# Connect to adbd and use a socket transferred from it.
362*e4a36f41SAndroid Build Coastguard Worker# This is used for e.g. adb backup/restore.
363*e4a36f41SAndroid Build Coastguard Workerallow appdomain adbd:unix_stream_socket connectto;
364*e4a36f41SAndroid Build Coastguard Workerallow appdomain adbd:fd use;
365*e4a36f41SAndroid Build Coastguard Workerallow appdomain adbd:unix_stream_socket { getattr getopt ioctl read write shutdown };
366*e4a36f41SAndroid Build Coastguard Worker
367*e4a36f41SAndroid Build Coastguard Workerallow appdomain cache_file:dir getattr;
368*e4a36f41SAndroid Build Coastguard Worker
369*e4a36f41SAndroid Build Coastguard Worker# Allow apps to run with asanwrapper.
370*e4a36f41SAndroid Build Coastguard Workerwith_asan(`allow appdomain asanwrapper_exec:file rx_file_perms;')
371*e4a36f41SAndroid Build Coastguard Worker
372*e4a36f41SAndroid Build Coastguard Worker# Read access to FDs from the DropboxManagerService.
373*e4a36f41SAndroid Build Coastguard Workerallow appdomain dropbox_data_file:file { getattr read };
374*e4a36f41SAndroid Build Coastguard Worker
375*e4a36f41SAndroid Build Coastguard Worker# Read tmpfs types from these processes.
376*e4a36f41SAndroid Build Coastguard Workerallow appdomain audioserver_tmpfs:file { getattr map read write };
377*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_server_tmpfs:file { getattr map read write };
378*e4a36f41SAndroid Build Coastguard Workerallow appdomain zygote_tmpfs:file { map read };
379*e4a36f41SAndroid Build Coastguard Worker
380*e4a36f41SAndroid Build Coastguard Worker###
381*e4a36f41SAndroid Build Coastguard Worker### Neverallow rules
382*e4a36f41SAndroid Build Coastguard Worker###
383*e4a36f41SAndroid Build Coastguard Worker### These are things that Android apps should NEVER be able to do
384*e4a36f41SAndroid Build Coastguard Worker###
385*e4a36f41SAndroid Build Coastguard Worker
386*e4a36f41SAndroid Build Coastguard Worker# Superuser capabilities.
387*e4a36f41SAndroid Build Coastguard Worker# bluetooth requires net_admin and wake_alarm. network stack app requires net_admin.
388*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -bluetooth -network_stack } self:capability_class_set *;
389*e4a36f41SAndroid Build Coastguard Worker
390*e4a36f41SAndroid Build Coastguard Worker# Block device access.
391*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain dev_type:blk_file { read write };
392*e4a36f41SAndroid Build Coastguard Worker
393*e4a36f41SAndroid Build Coastguard Worker# Access to any of the following character devices.
394*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain {
395*e4a36f41SAndroid Build Coastguard Worker    audio_device
396*e4a36f41SAndroid Build Coastguard Worker    camera_device
397*e4a36f41SAndroid Build Coastguard Worker    dm_device
398*e4a36f41SAndroid Build Coastguard Worker    radio_device
399*e4a36f41SAndroid Build Coastguard Worker    rpmsg_device
400*e4a36f41SAndroid Build Coastguard Worker    video_device
401*e4a36f41SAndroid Build Coastguard Worker}:chr_file { read write };
402*e4a36f41SAndroid Build Coastguard Worker
403*e4a36f41SAndroid Build Coastguard Worker# Note: Try expanding list of app domains in the future.
404*e4a36f41SAndroid Build Coastguard Workerneverallow { untrusted_app isolated_app shell } graphics_device:chr_file { read write };
405*e4a36f41SAndroid Build Coastguard Worker
406*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -nfc } nfc_device:chr_file
407*e4a36f41SAndroid Build Coastguard Worker    { read write };
408*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -bluetooth } hci_attach_dev:chr_file
409*e4a36f41SAndroid Build Coastguard Worker    { read write };
410*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain tee_device:chr_file { read write };
411*e4a36f41SAndroid Build Coastguard Worker
412*e4a36f41SAndroid Build Coastguard Worker# Privileged netlink socket interfaces.
413*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -network_stack }
414*e4a36f41SAndroid Build Coastguard Worker    domain:{
415*e4a36f41SAndroid Build Coastguard Worker        netlink_tcpdiag_socket
416*e4a36f41SAndroid Build Coastguard Worker        netlink_nflog_socket
417*e4a36f41SAndroid Build Coastguard Worker        netlink_xfrm_socket
418*e4a36f41SAndroid Build Coastguard Worker        netlink_audit_socket
419*e4a36f41SAndroid Build Coastguard Worker        netlink_dnrt_socket
420*e4a36f41SAndroid Build Coastguard Worker    } *;
421*e4a36f41SAndroid Build Coastguard Worker
422*e4a36f41SAndroid Build Coastguard Worker# These messages are broadcast messages from the kernel to userspace.
423*e4a36f41SAndroid Build Coastguard Worker# Do not allow the writing of netlink messages, which has been a source
424*e4a36f41SAndroid Build Coastguard Worker# of rooting vulns in the past.
425*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain domain:netlink_kobject_uevent_socket { write append };
426*e4a36f41SAndroid Build Coastguard Worker
427*e4a36f41SAndroid Build Coastguard Worker# Sockets under /dev/socket that are not specifically typed.
428*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain socket_device:sock_file write;
429*e4a36f41SAndroid Build Coastguard Worker
430*e4a36f41SAndroid Build Coastguard Worker# Unix domain sockets.
431*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain adbd_socket:sock_file write;
432*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -radio } rild_socket:sock_file write;
433*e4a36f41SAndroid Build Coastguard Worker
434*e4a36f41SAndroid Build Coastguard Worker# ptrace access to non-app domains.
435*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain { domain -appdomain }:process ptrace;
436*e4a36f41SAndroid Build Coastguard Worker
437*e4a36f41SAndroid Build Coastguard Worker# The Android security model guarantees the confidentiality and integrity
438*e4a36f41SAndroid Build Coastguard Worker# of application data and execution state. Ptrace bypasses those
439*e4a36f41SAndroid Build Coastguard Worker# confidentiality guarantees. Disallow ptrace access from system components
440*e4a36f41SAndroid Build Coastguard Worker# to apps. Crash_dump is excluded, as it needs ptrace access to
441*e4a36f41SAndroid Build Coastguard Worker# produce stack traces.  llkd is excluded, as it needs ptrace access to
442*e4a36f41SAndroid Build Coastguard Worker# inspect stack traces for live lock conditions.
443*e4a36f41SAndroid Build Coastguard Worker
444*e4a36f41SAndroid Build Coastguard Workerneverallow {
445*e4a36f41SAndroid Build Coastguard Worker  domain
446*e4a36f41SAndroid Build Coastguard Worker  -appdomain
447*e4a36f41SAndroid Build Coastguard Worker  -crash_dump
448*e4a36f41SAndroid Build Coastguard Worker  userdebug_or_eng(`-llkd')
449*e4a36f41SAndroid Build Coastguard Worker} appdomain:process ptrace;
450*e4a36f41SAndroid Build Coastguard Worker
451*e4a36f41SAndroid Build Coastguard Worker# Read or write access to /proc/pid entries for any non-app domain.
452*e4a36f41SAndroid Build Coastguard Worker# A different form of hidepid=2 like protections
453*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain { domain -appdomain }:file no_w_file_perms;
454*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -shell } { domain -appdomain }:file no_rw_file_perms;
455*e4a36f41SAndroid Build Coastguard Worker
456*e4a36f41SAndroid Build Coastguard Worker# signal access to non-app domains.
457*e4a36f41SAndroid Build Coastguard Worker# sigchld allowed for parent death notification.
458*e4a36f41SAndroid Build Coastguard Worker# signull allowed for kill(pid, 0) existence test.
459*e4a36f41SAndroid Build Coastguard Worker# All others prohibited.
460*e4a36f41SAndroid Build Coastguard Worker# -perfetto is to allow shell (which is an appdomain) to kill perfetto
461*e4a36f41SAndroid Build Coastguard Worker# (see private/shell.te).
462*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain { domain -appdomain -perfetto }:process
463*e4a36f41SAndroid Build Coastguard Worker    { sigkill sigstop signal };
464*e4a36f41SAndroid Build Coastguard Worker
465*e4a36f41SAndroid Build Coastguard Worker# Write to rootfs.
466*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain rootfs:dir_file_class_set
467*e4a36f41SAndroid Build Coastguard Worker    { create write setattr relabelfrom relabelto append unlink link rename };
468*e4a36f41SAndroid Build Coastguard Worker
469*e4a36f41SAndroid Build Coastguard Worker# Write to /system.
470*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain system_file:dir_file_class_set
471*e4a36f41SAndroid Build Coastguard Worker    { create write setattr relabelfrom relabelto append unlink link rename };
472*e4a36f41SAndroid Build Coastguard Worker
473*e4a36f41SAndroid Build Coastguard Worker# Write to entrypoint executables.
474*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain exec_type:file
475*e4a36f41SAndroid Build Coastguard Worker    { create write setattr relabelfrom relabelto append unlink link rename };
476*e4a36f41SAndroid Build Coastguard Worker
477*e4a36f41SAndroid Build Coastguard Worker# Write to system-owned parts of /data.
478*e4a36f41SAndroid Build Coastguard Worker# This is the default type for anything under /data not otherwise
479*e4a36f41SAndroid Build Coastguard Worker# specified in file_contexts.  Define a different type for portions
480*e4a36f41SAndroid Build Coastguard Worker# that should be writable by apps.
481*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain system_data_file:dir_file_class_set
482*e4a36f41SAndroid Build Coastguard Worker    { create write setattr relabelfrom relabelto append unlink link rename };
483*e4a36f41SAndroid Build Coastguard Worker
484*e4a36f41SAndroid Build Coastguard Worker# Write to various other parts of /data.
485*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain drm_data_file:dir_file_class_set
486*e4a36f41SAndroid Build Coastguard Worker    { create write setattr relabelfrom relabelto append unlink link rename };
487*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -platform_app }
488*e4a36f41SAndroid Build Coastguard Worker    apk_data_file:dir_file_class_set
489*e4a36f41SAndroid Build Coastguard Worker    { create write setattr relabelfrom relabelto append unlink link rename };
490*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -platform_app }
491*e4a36f41SAndroid Build Coastguard Worker    apk_tmp_file:dir_file_class_set
492*e4a36f41SAndroid Build Coastguard Worker    { create write setattr relabelfrom relabelto append unlink link rename };
493*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -platform_app }
494*e4a36f41SAndroid Build Coastguard Worker    apk_private_data_file:dir_file_class_set
495*e4a36f41SAndroid Build Coastguard Worker    { create write setattr relabelfrom relabelto append unlink link rename };
496*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -platform_app }
497*e4a36f41SAndroid Build Coastguard Worker    apk_private_tmp_file:dir_file_class_set
498*e4a36f41SAndroid Build Coastguard Worker    { create write setattr relabelfrom relabelto append unlink link rename };
499*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -shell }
500*e4a36f41SAndroid Build Coastguard Worker    shell_data_file:dir_file_class_set
501*e4a36f41SAndroid Build Coastguard Worker    { create setattr relabelfrom relabelto append unlink link rename };
502*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -bluetooth }
503*e4a36f41SAndroid Build Coastguard Worker    bluetooth_data_file:dir_file_class_set
504*e4a36f41SAndroid Build Coastguard Worker    { create write setattr relabelfrom relabelto append unlink link rename };
505*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -credstore -init } credstore_data_file:dir_file_class_set *;
506*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain
507*e4a36f41SAndroid Build Coastguard Worker    keystore_data_file:dir_file_class_set
508*e4a36f41SAndroid Build Coastguard Worker    { create write setattr relabelfrom relabelto append unlink link rename };
509*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain
510*e4a36f41SAndroid Build Coastguard Worker    systemkeys_data_file:dir_file_class_set
511*e4a36f41SAndroid Build Coastguard Worker    { create write setattr relabelfrom relabelto append unlink link rename };
512*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain
513*e4a36f41SAndroid Build Coastguard Worker    wifi_data_file:dir_file_class_set
514*e4a36f41SAndroid Build Coastguard Worker    { create write setattr relabelfrom relabelto append unlink link rename };
515*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain
516*e4a36f41SAndroid Build Coastguard Worker    dhcp_data_file:dir_file_class_set
517*e4a36f41SAndroid Build Coastguard Worker    { create write setattr relabelfrom relabelto append unlink link rename };
518*e4a36f41SAndroid Build Coastguard Worker
519*e4a36f41SAndroid Build Coastguard Worker# access tmp apk files
520*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -untrusted_app_all -platform_app -priv_app }
521*e4a36f41SAndroid Build Coastguard Worker    { apk_tmp_file apk_private_tmp_file }:dir_file_class_set *;
522*e4a36f41SAndroid Build Coastguard Worker
523*e4a36f41SAndroid Build Coastguard Workerneverallow untrusted_app_all { apk_tmp_file apk_private_tmp_file }:{ devfile_class_set dir fifo_file lnk_file sock_file } *;
524*e4a36f41SAndroid Build Coastguard Workerneverallow untrusted_app_all { apk_tmp_file apk_private_tmp_file }:file ~{ getattr read };
525*e4a36f41SAndroid Build Coastguard Worker
526*e4a36f41SAndroid Build Coastguard Worker# Access to factory files.
527*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain efs_file:dir_file_class_set write;
528*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -shell } efs_file:dir_file_class_set read;
529*e4a36f41SAndroid Build Coastguard Worker
530*e4a36f41SAndroid Build Coastguard Worker# Write to various pseudo file systems.
531*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -bluetooth -nfc }
532*e4a36f41SAndroid Build Coastguard Worker    sysfs:dir_file_class_set write;
533*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain
534*e4a36f41SAndroid Build Coastguard Worker    proc:dir_file_class_set write;
535*e4a36f41SAndroid Build Coastguard Worker
536*e4a36f41SAndroid Build Coastguard Worker# Access to syslog(2) or /proc/kmsg.
537*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain kernel:system { syslog_read syslog_mod syslog_console };
538*e4a36f41SAndroid Build Coastguard Worker
539*e4a36f41SAndroid Build Coastguard Worker# SELinux is not an API for apps to use
540*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -shell } *:security { compute_av check_context };
541*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -shell } *:netlink_selinux_socket *;
542*e4a36f41SAndroid Build Coastguard Worker
543*e4a36f41SAndroid Build Coastguard Worker# Ability to perform any filesystem operation other than statfs(2).
544*e4a36f41SAndroid Build Coastguard Worker# i.e. no mount(2), unmount(2), etc.
545*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain fs_type:filesystem ~getattr;
546*e4a36f41SAndroid Build Coastguard Worker
547*e4a36f41SAndroid Build Coastguard Worker# prevent creation/manipulation of globally readable symlinks
548*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain {
549*e4a36f41SAndroid Build Coastguard Worker  apk_data_file
550*e4a36f41SAndroid Build Coastguard Worker  cache_file
551*e4a36f41SAndroid Build Coastguard Worker  cache_recovery_file
552*e4a36f41SAndroid Build Coastguard Worker  dev_type
553*e4a36f41SAndroid Build Coastguard Worker  rootfs
554*e4a36f41SAndroid Build Coastguard Worker  system_file
555*e4a36f41SAndroid Build Coastguard Worker  tmpfs
556*e4a36f41SAndroid Build Coastguard Worker}:lnk_file no_w_file_perms;
557*e4a36f41SAndroid Build Coastguard Worker
558*e4a36f41SAndroid Build Coastguard Worker# Applications should use the activity model for receiving events
559*e4a36f41SAndroid Build Coastguard Workerneverallow {
560*e4a36f41SAndroid Build Coastguard Worker  appdomain
561*e4a36f41SAndroid Build Coastguard Worker  -shell # bugreport
562*e4a36f41SAndroid Build Coastguard Worker} input_device:chr_file ~getattr;
563*e4a36f41SAndroid Build Coastguard Worker
564*e4a36f41SAndroid Build Coastguard Worker# Do not allow access to Bluetooth-related system properties except for a few allowed domains.
565*e4a36f41SAndroid Build Coastguard Worker# neverallow rules for access to Bluetooth-related data files are above.
566*e4a36f41SAndroid Build Coastguard Workerneverallow {
567*e4a36f41SAndroid Build Coastguard Worker  appdomain
568*e4a36f41SAndroid Build Coastguard Worker  -bluetooth
569*e4a36f41SAndroid Build Coastguard Worker  -system_app
570*e4a36f41SAndroid Build Coastguard Worker} { bluetooth_audio_hal_prop bluetooth_a2dp_offload_prop bluetooth_prop exported_bluetooth_prop }:file create_file_perms;
571*e4a36f41SAndroid Build Coastguard Worker
572*e4a36f41SAndroid Build Coastguard Worker# Apps cannot access proc_uid_time_in_state
573*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain proc_uid_time_in_state:file *;
574*e4a36f41SAndroid Build Coastguard Worker
575*e4a36f41SAndroid Build Coastguard Worker# Apps cannot access proc_uid_concurrent_active_time
576*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain proc_uid_concurrent_active_time:file *;
577*e4a36f41SAndroid Build Coastguard Worker
578*e4a36f41SAndroid Build Coastguard Worker# Apps cannot access proc_uid_concurrent_policy_time
579*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain proc_uid_concurrent_policy_time:file *;
580*e4a36f41SAndroid Build Coastguard Worker
581*e4a36f41SAndroid Build Coastguard Worker# Apps cannot access proc_uid_cpupower
582*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain proc_uid_cpupower:file *;
583*e4a36f41SAndroid Build Coastguard Worker
584*e4a36f41SAndroid Build Coastguard Worker# Apps may not read /proc/net/{tcp,tcp6,udp,udp6}. These files leak information across the
585*e4a36f41SAndroid Build Coastguard Worker# application boundary. VPN apps may use the ConnectivityManager.getConnectionOwnerUid() API to
586*e4a36f41SAndroid Build Coastguard Worker# perform UID lookups.
587*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -shell } proc_net_tcp_udp:file *;
588*e4a36f41SAndroid Build Coastguard Worker
589*e4a36f41SAndroid Build Coastguard Worker# Apps cannot access bootstrap files. The bootstrap files are only for
590*e4a36f41SAndroid Build Coastguard Worker# extremely early processes (like init, etc.) which are started before
591*e4a36f41SAndroid Build Coastguard Worker# the runtime APEX is activated and Bionic libs are provided from there.
592*e4a36f41SAndroid Build Coastguard Worker# If app process accesses (or even load/execute) the bootstrap files,
593*e4a36f41SAndroid Build Coastguard Worker# it might cause problems such as ODR violation, etc.
594*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain system_bootstrap_lib_file:file
595*e4a36f41SAndroid Build Coastguard Worker    { open read write append execute execute_no_trans map };
596*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain system_bootstrap_lib_file:dir
597*e4a36f41SAndroid Build Coastguard Worker    { open read getattr search };
598*e4a36f41SAndroid Build Coastguard Worker
599*e4a36f41SAndroid Build Coastguard Worker# Allow to read ro.vendor.camera.extensions.enabled
600*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, camera2_extensions_prop)
601*e4a36f41SAndroid Build Coastguard Worker
602*e4a36f41SAndroid Build Coastguard Worker# Allow to ro.camerax.extensions.enabled
603*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, camerax_extensions_prop)
604