xref: /aosp_15_r20/system/sepolicy/private/priv_app.te (revision e4a36f4174b17bbab9dc043f4a65dc8d87377290)
1*e4a36f41SAndroid Build Coastguard Worker###
2*e4a36f41SAndroid Build Coastguard Worker### A domain for further sandboxing privileged apps.
3*e4a36f41SAndroid Build Coastguard Worker###
4*e4a36f41SAndroid Build Coastguard Worker
5*e4a36f41SAndroid Build Coastguard Workertypeattribute priv_app coredomain;
6*e4a36f41SAndroid Build Coastguard Workerapp_domain(priv_app)
7*e4a36f41SAndroid Build Coastguard Worker
8*e4a36f41SAndroid Build Coastguard Worker# Access the network.
9*e4a36f41SAndroid Build Coastguard Workernet_domain(priv_app)
10*e4a36f41SAndroid Build Coastguard Worker# Access bluetooth.
11*e4a36f41SAndroid Build Coastguard Workerbluetooth_domain(priv_app)
12*e4a36f41SAndroid Build Coastguard Worker
13*e4a36f41SAndroid Build Coastguard Worker# Allow the allocation and use of ptys
14*e4a36f41SAndroid Build Coastguard Worker# Used by: https://play.privileged.com/store/apps/details?id=jackpal.androidterm
15*e4a36f41SAndroid Build Coastguard Workercreate_pty(priv_app)
16*e4a36f41SAndroid Build Coastguard Worker
17*e4a36f41SAndroid Build Coastguard Worker# Allow loading executable code from writable priv-app home
18*e4a36f41SAndroid Build Coastguard Worker# directories. This is a W^X violation, however, it needs
19*e4a36f41SAndroid Build Coastguard Worker# to be supported for now for the following reasons.
20*e4a36f41SAndroid Build Coastguard Worker# * /data/user_*/0/*/code_cache/* POSSIBLE uses (b/117841367)
21*e4a36f41SAndroid Build Coastguard Worker#   1) com.android.opengl.shaders_cache
22*e4a36f41SAndroid Build Coastguard Worker#   2) com.android.skia.shaders_cache
23*e4a36f41SAndroid Build Coastguard Worker#   3) com.android.renderscript.cache
24*e4a36f41SAndroid Build Coastguard Worker# * /data/user_de/0/com.google.android.gms/app_chimera
25*e4a36f41SAndroid Build Coastguard Worker# TODO: Tighten (b/112357170)
26*e4a36f41SAndroid Build Coastguard Workerallow priv_app privapp_data_file:file execute;
27*e4a36f41SAndroid Build Coastguard Worker
28*e4a36f41SAndroid Build Coastguard Worker# Chrome Crashpad uses the the dynamic linker to load native executables
29*e4a36f41SAndroid Build Coastguard Worker# from an APK (b/112050209, crbug.com/928422)
30*e4a36f41SAndroid Build Coastguard Workerallow priv_app system_linker_exec:file execute_no_trans;
31*e4a36f41SAndroid Build Coastguard Worker
32*e4a36f41SAndroid Build Coastguard Workerallow priv_app privapp_data_file:lnk_file create_file_perms;
33*e4a36f41SAndroid Build Coastguard Worker
34*e4a36f41SAndroid Build Coastguard Worker# Priv apps can find services that expose both @SystemAPI and normal APIs.
35*e4a36f41SAndroid Build Coastguard Workerallow priv_app app_api_service:service_manager find;
36*e4a36f41SAndroid Build Coastguard Workerallow priv_app system_api_service:service_manager find;
37*e4a36f41SAndroid Build Coastguard Worker
38*e4a36f41SAndroid Build Coastguard Workerallow priv_app audioserver_service:service_manager find;
39*e4a36f41SAndroid Build Coastguard Workerallow priv_app cameraserver_service:service_manager find;
40*e4a36f41SAndroid Build Coastguard Workerallow priv_app drmserver_service:service_manager find;
41*e4a36f41SAndroid Build Coastguard Workerallow priv_app mediadrmserver_service:service_manager find;
42*e4a36f41SAndroid Build Coastguard Workerallow priv_app mediaextractor_service:service_manager find;
43*e4a36f41SAndroid Build Coastguard Workerallow priv_app mediametrics_service:service_manager find;
44*e4a36f41SAndroid Build Coastguard Workerallow priv_app mediaserver_service:service_manager find;
45*e4a36f41SAndroid Build Coastguard Workerallow priv_app music_recognition_service:service_manager find;
46*e4a36f41SAndroid Build Coastguard Workerallow priv_app network_watchlist_service:service_manager find;
47*e4a36f41SAndroid Build Coastguard Workerallow priv_app nfc_service:service_manager find;
48*e4a36f41SAndroid Build Coastguard Workerallow priv_app oem_lock_service:service_manager find;
49*e4a36f41SAndroid Build Coastguard Workerallow priv_app persistent_data_block_service:service_manager find;
50*e4a36f41SAndroid Build Coastguard Workerallow priv_app radio_service:service_manager find;
51*e4a36f41SAndroid Build Coastguard Workerallow priv_app recovery_service:service_manager find;
52*e4a36f41SAndroid Build Coastguard Workerallow priv_app stats_service:service_manager find;
53*e4a36f41SAndroid Build Coastguard Worker
54*e4a36f41SAndroid Build Coastguard Worker# Write to /cache.
55*e4a36f41SAndroid Build Coastguard Workerallow priv_app { cache_file cache_recovery_file }:dir create_dir_perms;
56*e4a36f41SAndroid Build Coastguard Workerallow priv_app { cache_file cache_recovery_file }:file create_file_perms;
57*e4a36f41SAndroid Build Coastguard Worker# /cache is a symlink to /data/cache on some devices. Allow reading the link.
58*e4a36f41SAndroid Build Coastguard Workerallow priv_app cache_file:lnk_file r_file_perms;
59*e4a36f41SAndroid Build Coastguard Worker
60*e4a36f41SAndroid Build Coastguard Worker# Access to /data/media.
61*e4a36f41SAndroid Build Coastguard Workerallow priv_app media_rw_data_file:dir create_dir_perms;
62*e4a36f41SAndroid Build Coastguard Workerallow priv_app media_rw_data_file:file create_file_perms;
63*e4a36f41SAndroid Build Coastguard Worker
64*e4a36f41SAndroid Build Coastguard Worker# Used by Finsky / Android "Verify Apps" functionality when
65*e4a36f41SAndroid Build Coastguard Worker# running "adb install foo.apk".
66*e4a36f41SAndroid Build Coastguard Workerallow priv_app shell_data_file:file r_file_perms;
67*e4a36f41SAndroid Build Coastguard Workerallow priv_app shell_data_file:dir r_dir_perms;
68*e4a36f41SAndroid Build Coastguard Worker
69*e4a36f41SAndroid Build Coastguard Worker# Allow traceur to pass file descriptors through a content provider to betterbug
70*e4a36f41SAndroid Build Coastguard Workerallow priv_app trace_data_file:file { getattr read };
71*e4a36f41SAndroid Build Coastguard Worker
72*e4a36f41SAndroid Build Coastguard Worker# Allow betterbug to read profile reports generated by profcollect.
73*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
74*e4a36f41SAndroid Build Coastguard Worker  allow priv_app profcollectd_data_file:file r_file_perms;
75*e4a36f41SAndroid Build Coastguard Worker')
76*e4a36f41SAndroid Build Coastguard Worker
77*e4a36f41SAndroid Build Coastguard Worker# Allow the bug reporting frontend to read the presence and timestamp of the
78*e4a36f41SAndroid Build Coastguard Worker# trace attached to the bugreport (but not its contents, which will go in the
79*e4a36f41SAndroid Build Coastguard Worker# usual bugreport .zip file). This is used by the bug reporting UI to tell if
80*e4a36f41SAndroid Build Coastguard Worker# the bugreport will contain a system trace or not while the bugreport is still
81*e4a36f41SAndroid Build Coastguard Worker# in progress.
82*e4a36f41SAndroid Build Coastguard Workerallow priv_app wm_trace_data_file:dir r_dir_perms;
83*e4a36f41SAndroid Build Coastguard Workerallow priv_app wm_trace_data_file:file getattr;
84*e4a36f41SAndroid Build Coastguard Workerallow priv_app perfetto_traces_bugreport_data_file:dir r_dir_perms;
85*e4a36f41SAndroid Build Coastguard Workerallow priv_app perfetto_traces_bugreport_data_file:file { getattr };
86*e4a36f41SAndroid Build Coastguard Worker# Required to traverse the parent dir (/data/misc/perfetto-traces).
87*e4a36f41SAndroid Build Coastguard Workerallow priv_app perfetto_traces_data_file:dir { search };
88*e4a36f41SAndroid Build Coastguard Worker
89*e4a36f41SAndroid Build Coastguard Worker# Allow priv apps (e.g. BetterBug) to receive Perfetto traces through
90*e4a36f41SAndroid Build Coastguard Worker# the framework (i.e. TracingServiceProxy) and sendfile them into their private
91*e4a36f41SAndroid Build Coastguard Worker# directories for reporting when network and battery conditions are
92*e4a36f41SAndroid Build Coastguard Worker# appropriate.
93*e4a36f41SAndroid Build Coastguard Workerallow priv_app perfetto:fd use;
94*e4a36f41SAndroid Build Coastguard Workerallow priv_app perfetto_traces_data_file:file { read getattr };
95*e4a36f41SAndroid Build Coastguard Worker
96*e4a36f41SAndroid Build Coastguard Worker# Allow verifier to access staged apks.
97*e4a36f41SAndroid Build Coastguard Workerallow priv_app { apk_tmp_file apk_private_tmp_file }:dir r_dir_perms;
98*e4a36f41SAndroid Build Coastguard Workerallow priv_app { apk_tmp_file apk_private_tmp_file }:file r_file_perms;
99*e4a36f41SAndroid Build Coastguard Workerallowxperm priv_app { apk_tmp_file apk_private_tmp_file }:file ioctl FS_IOC_MEASURE_VERITY;
100*e4a36f41SAndroid Build Coastguard Worker
101*e4a36f41SAndroid Build Coastguard Worker# For AppFuse.
102*e4a36f41SAndroid Build Coastguard Workerallow priv_app vold:fd use;
103*e4a36f41SAndroid Build Coastguard Workerallow priv_app fuse_device:chr_file { read write };
104*e4a36f41SAndroid Build Coastguard Worker
105*e4a36f41SAndroid Build Coastguard Worker# /proc access
106*e4a36f41SAndroid Build Coastguard Workerallow priv_app {
107*e4a36f41SAndroid Build Coastguard Worker  proc_vmstat
108*e4a36f41SAndroid Build Coastguard Worker}:file r_file_perms;
109*e4a36f41SAndroid Build Coastguard Worker
110*e4a36f41SAndroid Build Coastguard Workerallow priv_app sysfs_type:dir search;
111*e4a36f41SAndroid Build Coastguard Worker# Read access to /sys/block/zram*/mm_stat
112*e4a36f41SAndroid Build Coastguard Workerr_dir_file(priv_app, sysfs_zram)
113*e4a36f41SAndroid Build Coastguard Worker
114*e4a36f41SAndroid Build Coastguard Workerr_dir_file(priv_app, rootfs)
115*e4a36f41SAndroid Build Coastguard Worker
116*e4a36f41SAndroid Build Coastguard Worker# Allow com.android.vending to communicate with statsd.
117*e4a36f41SAndroid Build Coastguard Workerbinder_call(priv_app, statsd)
118*e4a36f41SAndroid Build Coastguard Worker
119*e4a36f41SAndroid Build Coastguard Worker# Allow Phone to read/write cached ringtones (opened by system).
120*e4a36f41SAndroid Build Coastguard Workerallow priv_app ringtone_file:file { getattr read write };
121*e4a36f41SAndroid Build Coastguard Worker
122*e4a36f41SAndroid Build Coastguard Worker# Access to /data/preloads
123*e4a36f41SAndroid Build Coastguard Workerallow priv_app preloads_data_file:file r_file_perms;
124*e4a36f41SAndroid Build Coastguard Workerallow priv_app preloads_data_file:dir r_dir_perms;
125*e4a36f41SAndroid Build Coastguard Workerallow priv_app preloads_media_file:file r_file_perms;
126*e4a36f41SAndroid Build Coastguard Workerallow priv_app preloads_media_file:dir r_dir_perms;
127*e4a36f41SAndroid Build Coastguard Worker
128*e4a36f41SAndroid Build Coastguard Workerread_runtime_log_tags(priv_app)
129*e4a36f41SAndroid Build Coastguard Worker
130*e4a36f41SAndroid Build Coastguard Worker# Allow priv_apps to request and collect incident reports.
131*e4a36f41SAndroid Build Coastguard Worker# (Also requires DUMP and PACKAGE_USAGE_STATS permissions)
132*e4a36f41SAndroid Build Coastguard Workerallow priv_app incident_service:service_manager find;
133*e4a36f41SAndroid Build Coastguard Workerbinder_call(priv_app, incidentd)
134*e4a36f41SAndroid Build Coastguard Workerallow priv_app incidentd:fifo_file { read write };
135*e4a36f41SAndroid Build Coastguard Worker
136*e4a36f41SAndroid Build Coastguard Worker# Allow priv_apps to check whether Dynamic System Update is enabled
137*e4a36f41SAndroid Build Coastguard Workerget_prop(priv_app, dynamic_system_prop)
138*e4a36f41SAndroid Build Coastguard Worker
139*e4a36f41SAndroid Build Coastguard Worker# Allow privileged apps to read trade in mode property
140*e4a36f41SAndroid Build Coastguard Workerget_prop(priv_app, adbd_tradeinmode_prop)
141*e4a36f41SAndroid Build Coastguard Worker
142*e4a36f41SAndroid Build Coastguard Worker# suppress denials for non-API accesses.
143*e4a36f41SAndroid Build Coastguard Workerdontaudit priv_app exec_type:file getattr;
144*e4a36f41SAndroid Build Coastguard Workerdontaudit priv_app device:dir read;
145*e4a36f41SAndroid Build Coastguard Workerdontaudit priv_app fs_bpf:dir search;
146*e4a36f41SAndroid Build Coastguard Workerdontaudit priv_app net_dns_prop:file read;
147*e4a36f41SAndroid Build Coastguard Workerdontaudit priv_app proc:file read;
148*e4a36f41SAndroid Build Coastguard Workerdontaudit priv_app proc_interrupts:file read;
149*e4a36f41SAndroid Build Coastguard Workerdontaudit priv_app proc_modules:file read;
150*e4a36f41SAndroid Build Coastguard Workerdontaudit priv_app proc_net:file read;
151*e4a36f41SAndroid Build Coastguard Workerdontaudit priv_app proc_stat:file read;
152*e4a36f41SAndroid Build Coastguard Workerdontaudit priv_app proc_version:file read;
153*e4a36f41SAndroid Build Coastguard Workerdontaudit priv_app sysfs:dir read;
154*e4a36f41SAndroid Build Coastguard Workerdontaudit priv_app sysfs:file read;
155*e4a36f41SAndroid Build Coastguard Workerdontaudit priv_app sysfs_android_usb:file read;
156*e4a36f41SAndroid Build Coastguard Workerdontaudit priv_app sysfs_dm:file r_file_perms;
157*e4a36f41SAndroid Build Coastguard Workerdontaudit priv_app { wifi_prop wifi_config_prop wifi_hal_prop }:file read;
158*e4a36f41SAndroid Build Coastguard Worker
159*e4a36f41SAndroid Build Coastguard Worker# allow privileged apps to use UDP sockets provided by the system server but not
160*e4a36f41SAndroid Build Coastguard Worker# modify them other than to connect
161*e4a36f41SAndroid Build Coastguard Workerallow priv_app system_server:udp_socket {
162*e4a36f41SAndroid Build Coastguard Worker        connect getattr read recvfrom sendto write getopt setopt };
163*e4a36f41SAndroid Build Coastguard Worker
164*e4a36f41SAndroid Build Coastguard Worker# allow apps like Phonesky to check the file signature of an apk installed on
165*e4a36f41SAndroid Build Coastguard Worker# the Incremental File System, fill missing blocks and get the app status and loading progress
166*e4a36f41SAndroid Build Coastguard Workerallowxperm priv_app apk_data_file:file ioctl {
167*e4a36f41SAndroid Build Coastguard Worker  INCFS_IOCTL_READ_SIGNATURE
168*e4a36f41SAndroid Build Coastguard Worker  INCFS_IOCTL_FILL_BLOCKS
169*e4a36f41SAndroid Build Coastguard Worker  INCFS_IOCTL_GET_BLOCK_COUNT
170*e4a36f41SAndroid Build Coastguard Worker  INCFS_IOCTL_GET_FILLED_BLOCKS
171*e4a36f41SAndroid Build Coastguard Worker};
172*e4a36f41SAndroid Build Coastguard Worker
173*e4a36f41SAndroid Build Coastguard Worker# allow privileged data loader apps (e.g. com.android.vending) to read logs from Incremental File System
174*e4a36f41SAndroid Build Coastguard Workerallow priv_app incremental_control_file:file { read getattr ioctl };
175*e4a36f41SAndroid Build Coastguard Worker
176*e4a36f41SAndroid Build Coastguard Worker# allow apps like Phonesky to request permission to fill blocks of an apk file
177*e4a36f41SAndroid Build Coastguard Worker# on the Incremental File System.
178*e4a36f41SAndroid Build Coastguard Workerallowxperm priv_app incremental_control_file:file ioctl INCFS_IOCTL_PERMIT_FILL;
179*e4a36f41SAndroid Build Coastguard Worker
180*e4a36f41SAndroid Build Coastguard Worker# allow privileged apps to read the vendor property that indicates if Incremental File System is enabled
181*e4a36f41SAndroid Build Coastguard Workerget_prop(priv_app, incremental_prop)
182*e4a36f41SAndroid Build Coastguard Worker
183*e4a36f41SAndroid Build Coastguard Worker# allow privileged apps to read the device config flags.
184*e4a36f41SAndroid Build Coastguard Workerget_prop(priv_app, device_config_aconfig_flags_prop)
185*e4a36f41SAndroid Build Coastguard Worker
186*e4a36f41SAndroid Build Coastguard Worker# allow privileged apps to read boot reason property
187*e4a36f41SAndroid Build Coastguard Workerget_prop(priv_app, system_boot_reason_prop)
188*e4a36f41SAndroid Build Coastguard Worker
189*e4a36f41SAndroid Build Coastguard Worker# Required for Phonesky to be able to read APEX files under /data/apex/active/.
190*e4a36f41SAndroid Build Coastguard Workerallow priv_app apex_data_file:dir search;
191*e4a36f41SAndroid Build Coastguard Workerallow priv_app staging_data_file:file r_file_perms;
192*e4a36f41SAndroid Build Coastguard Worker# Required for Phonesky to be able to read staged files under /data/app-staging.
193*e4a36f41SAndroid Build Coastguard Workerallow priv_app staging_data_file:dir r_dir_perms;
194*e4a36f41SAndroid Build Coastguard Worker
195*e4a36f41SAndroid Build Coastguard Worker# Allow com.android.vending to access files under vendor/apex as well as system apex files.
196*e4a36f41SAndroid Build Coastguard Worker# This is required for com.android.vending to handle APEXes for e.g. delta patch optimization.
197*e4a36f41SAndroid Build Coastguard Workerallow priv_app vendor_apex_file:dir r_dir_perms;
198*e4a36f41SAndroid Build Coastguard Workerallow priv_app vendor_apex_file:file r_file_perms;
199*e4a36f41SAndroid Build Coastguard Worker
200*e4a36f41SAndroid Build Coastguard Worker# allow priv app to access the system app data files for ContentProvider case.
201*e4a36f41SAndroid Build Coastguard Workerallow priv_app system_app_data_file:file { read getattr };
202*e4a36f41SAndroid Build Coastguard Worker
203*e4a36f41SAndroid Build Coastguard Worker# Allow the renderscript compiler to be run.
204*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(priv_app, rs_exec, rs)
205*e4a36f41SAndroid Build Coastguard Worker
206*e4a36f41SAndroid Build Coastguard Worker# Allow loading and deleting executable shared libraries
207*e4a36f41SAndroid Build Coastguard Worker# within an application home directory. Such shared libraries would be
208*e4a36f41SAndroid Build Coastguard Worker# created by things like renderscript or via other mechanisms.
209*e4a36f41SAndroid Build Coastguard Workerallow priv_app app_exec_data_file:file { r_file_perms execute unlink };
210*e4a36f41SAndroid Build Coastguard Worker
211*e4a36f41SAndroid Build Coastguard Worker# Allow privileged apps to create a VM. Note that access is still
212*e4a36f41SAndroid Build Coastguard Worker# guarded with the `android.permission.MANAGE_VIRTUAL_MACHINE`
213*e4a36f41SAndroid Build Coastguard Worker# permission.
214*e4a36f41SAndroid Build Coastguard Workervirtualizationservice_use(priv_app)
215*e4a36f41SAndroid Build Coastguard Worker
216*e4a36f41SAndroid Build Coastguard Worker###
217*e4a36f41SAndroid Build Coastguard Worker### neverallow rules
218*e4a36f41SAndroid Build Coastguard Worker###
219*e4a36f41SAndroid Build Coastguard Worker
220*e4a36f41SAndroid Build Coastguard Worker# Receive or send uevent messages.
221*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app domain:netlink_kobject_uevent_socket *;
222*e4a36f41SAndroid Build Coastguard Worker
223*e4a36f41SAndroid Build Coastguard Worker# Receive or send generic netlink messages
224*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app domain:netlink_socket *;
225*e4a36f41SAndroid Build Coastguard Worker
226*e4a36f41SAndroid Build Coastguard Worker# Read or write kernel printk buffer
227*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app kmsg_device:chr_file no_rw_file_perms;
228*e4a36f41SAndroid Build Coastguard Worker
229*e4a36f41SAndroid Build Coastguard Worker# Too much leaky information in debugfs. It's a security
230*e4a36f41SAndroid Build Coastguard Worker# best practice to ensure these files aren't readable.
231*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app debugfs_type:file read;
232*e4a36f41SAndroid Build Coastguard Worker
233*e4a36f41SAndroid Build Coastguard Worker# Do not allow privileged apps to register services.
234*e4a36f41SAndroid Build Coastguard Worker# Only trusted components of Android should be registering
235*e4a36f41SAndroid Build Coastguard Worker# services.
236*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app service_manager_type:service_manager add;
237*e4a36f41SAndroid Build Coastguard Worker
238*e4a36f41SAndroid Build Coastguard Worker# Do not allow privileged apps to connect to the property service
239*e4a36f41SAndroid Build Coastguard Worker# or set properties. b/10243159
240*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app property_socket:sock_file write;
241*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app init:unix_stream_socket connectto;
242*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app property_type:property_service set;
243*e4a36f41SAndroid Build Coastguard Worker
244*e4a36f41SAndroid Build Coastguard Worker# Do not allow priv_app to be assigned mlstrustedsubject.
245*e4a36f41SAndroid Build Coastguard Worker# This would undermine the per-user isolation model being
246*e4a36f41SAndroid Build Coastguard Worker# enforced via levelFrom=user in seapp_contexts and the mls
247*e4a36f41SAndroid Build Coastguard Worker# constraints.  As there is no direct way to specify a neverallow
248*e4a36f41SAndroid Build Coastguard Worker# on attribute assignment, this relies on the fact that fork
249*e4a36f41SAndroid Build Coastguard Worker# permission only makes sense within a domain (hence should
250*e4a36f41SAndroid Build Coastguard Worker# never be granted to any other domain within mlstrustedsubject)
251*e4a36f41SAndroid Build Coastguard Worker# and priv_app is allowed fork permission to itself.
252*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app mlstrustedsubject:process fork;
253*e4a36f41SAndroid Build Coastguard Worker
254*e4a36f41SAndroid Build Coastguard Worker# Do not allow priv_app to hard link to any files.
255*e4a36f41SAndroid Build Coastguard Worker# In particular, if priv_app links to other app data
256*e4a36f41SAndroid Build Coastguard Worker# files, installd will not be able to guarantee the deletion
257*e4a36f41SAndroid Build Coastguard Worker# of the linked to file. Hard links also contribute to security
258*e4a36f41SAndroid Build Coastguard Worker# bugs, so we want to ensure priv_app never has this
259*e4a36f41SAndroid Build Coastguard Worker# capability.
260*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app file_type:file link;
261*e4a36f41SAndroid Build Coastguard Worker
262*e4a36f41SAndroid Build Coastguard Worker# priv apps should not be able to open trace data files, they should depend
263*e4a36f41SAndroid Build Coastguard Worker# upon traceur to pass a file descriptor which they can then read
264*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app trace_data_file:dir *;
265*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app trace_data_file:file { no_w_file_perms open };
266*e4a36f41SAndroid Build Coastguard Worker
267*e4a36f41SAndroid Build Coastguard Worker# Do not allow priv_app access to cgroups.
268*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app cgroup:file *;
269*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app cgroup_v2:file *;
270*e4a36f41SAndroid Build Coastguard Worker
271*e4a36f41SAndroid Build Coastguard Worker# Do not allow loading executable code from non-privileged
272*e4a36f41SAndroid Build Coastguard Worker# application home directories. Code loading across a security boundary
273*e4a36f41SAndroid Build Coastguard Worker# is dangerous and allows a full compromise of a privileged process
274*e4a36f41SAndroid Build Coastguard Worker# by an unprivileged process. b/112357170
275*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app { app_data_file_type -privapp_data_file }:file no_x_file_perms;
276*e4a36f41SAndroid Build Coastguard Worker
277*e4a36f41SAndroid Build Coastguard Worker# Do not follow any app provided symlinks
278*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app { app_data_file_type -privapp_data_file }:lnk_file { open read getattr };
279*e4a36f41SAndroid Build Coastguard Worker
280*e4a36f41SAndroid Build Coastguard Worker# Do not allow getting permission-protected network information from sysfs.
281*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app sysfs_net:file *;
282*e4a36f41SAndroid Build Coastguard Worker
283*e4a36f41SAndroid Build Coastguard Worker# Restrict socket ioctls. Either 1. disallow privileged ioctls, 2. disallow the
284*e4a36f41SAndroid Build Coastguard Worker# ioctl permission, or 3. disallow the socket class.
285*e4a36f41SAndroid Build Coastguard Workerneverallowxperm priv_app domain:{ icmp_socket rawip_socket tcp_socket udp_socket } ioctl priv_sock_ioctls;
286*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app *:{ netlink_route_socket netlink_selinux_socket } ioctl;
287*e4a36f41SAndroid Build Coastguard Workerneverallow priv_app *:{
288*e4a36f41SAndroid Build Coastguard Worker  socket netlink_socket packet_socket key_socket appletalk_socket
289*e4a36f41SAndroid Build Coastguard Worker  netlink_tcpdiag_socket netlink_nflog_socket
290*e4a36f41SAndroid Build Coastguard Worker  netlink_xfrm_socket netlink_audit_socket
291*e4a36f41SAndroid Build Coastguard Worker  netlink_dnrt_socket netlink_kobject_uevent_socket tun_socket
292*e4a36f41SAndroid Build Coastguard Worker  netlink_iscsi_socket netlink_fib_lookup_socket netlink_connector_socket
293*e4a36f41SAndroid Build Coastguard Worker  netlink_netfilter_socket netlink_generic_socket netlink_scsitransport_socket
294*e4a36f41SAndroid Build Coastguard Worker  netlink_rdma_socket netlink_crypto_socket sctp_socket
295*e4a36f41SAndroid Build Coastguard Worker  ax25_socket ipx_socket netrom_socket atmpvc_socket x25_socket rose_socket decnet_socket
296*e4a36f41SAndroid Build Coastguard Worker  atmsvc_socket rds_socket irda_socket pppox_socket llc_socket can_socket tipc_socket
297*e4a36f41SAndroid Build Coastguard Worker  bluetooth_socket iucv_socket rxrpc_socket isdn_socket phonet_socket ieee802154_socket caif_socket
298*e4a36f41SAndroid Build Coastguard Worker  alg_socket nfc_socket kcm_socket qipcrtr_socket smc_socket xdp_socket
299*e4a36f41SAndroid Build Coastguard Worker} *;
300