xref: /aosp_15_r20/system/sepolicy/private/untrusted_app_all.te (revision e4a36f4174b17bbab9dc043f4a65dc8d87377290)
1*e4a36f41SAndroid Build Coastguard Worker###
2*e4a36f41SAndroid Build Coastguard Worker### Untrusted_app_all.
3*e4a36f41SAndroid Build Coastguard Worker###
4*e4a36f41SAndroid Build Coastguard Worker### This file defines the rules shared by all untrusted app domains except
5*e4a36f41SAndroid Build Coastguard Worker### ephemeral_app for instant apps and isolated_app (which has a reduced
6*e4a36f41SAndroid Build Coastguard Worker### permission set).
7*e4a36f41SAndroid Build Coastguard Worker### Apps are labeled based on mac_permissions.xml (maps signer and
8*e4a36f41SAndroid Build Coastguard Worker### optionally package name to seinfo value) and seapp_contexts (maps UID
9*e4a36f41SAndroid Build Coastguard Worker### and optionally seinfo value to domain for process and type for data
10*e4a36f41SAndroid Build Coastguard Worker### directory).  The untrusted_app_all attribute is assigned to all default
11*e4a36f41SAndroid Build Coastguard Worker### seapp_contexts for any app with UID between APP_AID (10000)
12*e4a36f41SAndroid Build Coastguard Worker### and AID_ISOLATED_START (99000) if the app has no specific seinfo
13*e4a36f41SAndroid Build Coastguard Worker### value as determined from mac_permissions.xml.  In current AOSP, this
14*e4a36f41SAndroid Build Coastguard Worker### attribute is assigned to all non-system apps as well as to any system apps
15*e4a36f41SAndroid Build Coastguard Worker### that are not signed by the platform key.  To move
16*e4a36f41SAndroid Build Coastguard Worker### a system app into a specific domain, add a signer entry for it to
17*e4a36f41SAndroid Build Coastguard Worker### mac_permissions.xml and assign it one of the pre-existing seinfo values
18*e4a36f41SAndroid Build Coastguard Worker### or define and use a new seinfo value in both mac_permissions.xml and
19*e4a36f41SAndroid Build Coastguard Worker### seapp_contexts.
20*e4a36f41SAndroid Build Coastguard Worker###
21*e4a36f41SAndroid Build Coastguard Worker### Note that rules that should apply to all untrusted apps must be in app.te or also
22*e4a36f41SAndroid Build Coastguard Worker### added to ephemeral_app.te.
23*e4a36f41SAndroid Build Coastguard Worker
24*e4a36f41SAndroid Build Coastguard Worker# Some apps ship with shared libraries and binaries that they write out
25*e4a36f41SAndroid Build Coastguard Worker# to their sandbox directory and then execute.
26*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all privapp_data_file:file { r_file_perms execute };
27*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all app_data_file:file     { r_file_perms execute };
28*e4a36f41SAndroid Build Coastguard Workerauditallow untrusted_app_all app_data_file:file execute;
29*e4a36f41SAndroid Build Coastguard Worker
30*e4a36f41SAndroid Build Coastguard Worker# Chrome Crashpad uses the the dynamic linker to load native executables
31*e4a36f41SAndroid Build Coastguard Worker# from an APK (b/112050209, crbug.com/928422)
32*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all system_linker_exec:file execute_no_trans;
33*e4a36f41SAndroid Build Coastguard Worker
34*e4a36f41SAndroid Build Coastguard Worker# Follow priv-app symlinks. This is used for dynamite functionality.
35*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all privapp_data_file:lnk_file r_file_perms;
36*e4a36f41SAndroid Build Coastguard Worker
37*e4a36f41SAndroid Build Coastguard Worker# Allow handling of less common filesystem objects
38*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all app_data_file:{ lnk_file sock_file fifo_file } create_file_perms;
39*e4a36f41SAndroid Build Coastguard Worker
40*e4a36f41SAndroid Build Coastguard Worker# Allow loading and deleting executable shared libraries
41*e4a36f41SAndroid Build Coastguard Worker# within an application home directory. Such shared libraries would be
42*e4a36f41SAndroid Build Coastguard Worker# created by things like renderscript or via other mechanisms.
43*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all app_exec_data_file:file { r_file_perms execute unlink };
44*e4a36f41SAndroid Build Coastguard Worker
45*e4a36f41SAndroid Build Coastguard Worker# ASEC
46*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all asec_apk_file:file r_file_perms;
47*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all asec_apk_file:dir r_dir_perms;
48*e4a36f41SAndroid Build Coastguard Worker# Execute libs in asec containers.
49*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all asec_public_file:file { execute };
50*e4a36f41SAndroid Build Coastguard Worker
51*e4a36f41SAndroid Build Coastguard Worker# Used by Finsky / Android "Verify Apps" functionality when
52*e4a36f41SAndroid Build Coastguard Worker# running "adb install foo.apk".
53*e4a36f41SAndroid Build Coastguard Worker# TODO: Long term, we don't want apps probing into shell data files.
54*e4a36f41SAndroid Build Coastguard Worker# Figure out a way to remove these rules.
55*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all shell_data_file:file r_file_perms;
56*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all shell_data_file:dir r_dir_perms;
57*e4a36f41SAndroid Build Coastguard Worker
58*e4a36f41SAndroid Build Coastguard Worker# Allow traceur to pass file descriptors through a content provider to untrusted apps
59*e4a36f41SAndroid Build Coastguard Worker# for the purpose of sharing files through e.g. gmail
60*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all trace_data_file:file { getattr read };
61*e4a36f41SAndroid Build Coastguard Worker
62*e4a36f41SAndroid Build Coastguard Worker# untrusted apps should not be able to open trace data files, they should depend
63*e4a36f41SAndroid Build Coastguard Worker# upon traceur to pass a file descriptor
64*e4a36f41SAndroid Build Coastguard Workerneverallow untrusted_app_all trace_data_file:dir *;
65*e4a36f41SAndroid Build Coastguard Workerneverallow untrusted_app_all trace_data_file:file { no_w_file_perms open };
66*e4a36f41SAndroid Build Coastguard Worker
67*e4a36f41SAndroid Build Coastguard Worker# neverallow untrusted apps accessing debugfs_tracing
68*e4a36f41SAndroid Build Coastguard Workerneverallow untrusted_app_all debugfs_tracing:file no_rw_file_perms;
69*e4a36f41SAndroid Build Coastguard Worker
70*e4a36f41SAndroid Build Coastguard Worker# Allow to read staged apks.
71*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all { apk_tmp_file apk_private_tmp_file }:file {read getattr};
72*e4a36f41SAndroid Build Coastguard Worker
73*e4a36f41SAndroid Build Coastguard Worker# Read and write system app data files passed over Binder.
74*e4a36f41SAndroid Build Coastguard Worker# Motivating case was /data/data/com.android.settings/cache/*.jpg for
75*e4a36f41SAndroid Build Coastguard Worker# cropping or taking user photos.
76*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all system_app_data_file:file { read write getattr };
77*e4a36f41SAndroid Build Coastguard Worker
78*e4a36f41SAndroid Build Coastguard Worker#
79*e4a36f41SAndroid Build Coastguard Worker# Rules migrated from old app domains coalesced into untrusted_app.
80*e4a36f41SAndroid Build Coastguard Worker# This includes what used to be media_app, shared_app, and release_app.
81*e4a36f41SAndroid Build Coastguard Worker#
82*e4a36f41SAndroid Build Coastguard Worker
83*e4a36f41SAndroid Build Coastguard Worker# Access to /data/media.
84*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all media_rw_data_file:dir create_dir_perms;
85*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all media_rw_data_file:file create_file_perms;
86*e4a36f41SAndroid Build Coastguard Worker
87*e4a36f41SAndroid Build Coastguard Worker# allow cts to query all services
88*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all servicemanager:service_manager list;
89*e4a36f41SAndroid Build Coastguard Worker
90*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all audioserver_service:service_manager find;
91*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all cameraserver_service:service_manager find;
92*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all drmserver_service:service_manager find;
93*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all mediaserver_service:service_manager find;
94*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all mediaextractor_service:service_manager find;
95*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all mediametrics_service:service_manager find;
96*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all mediadrmserver_service:service_manager find;
97*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all nfc_service:service_manager find;
98*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all radio_service:service_manager find;
99*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all app_api_service:service_manager find;
100*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all vr_manager_service:service_manager find;
101*e4a36f41SAndroid Build Coastguard Worker
102*e4a36f41SAndroid Build Coastguard Worker# gdbserver for ndk-gdb ptrace attaches to app process.
103*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all self:process ptrace;
104*e4a36f41SAndroid Build Coastguard Worker
105*e4a36f41SAndroid Build Coastguard Worker# Android Studio Instant Run has the application connect to a
106*e4a36f41SAndroid Build Coastguard Worker# runas_app socket listening in the abstract namespace.
107*e4a36f41SAndroid Build Coastguard Worker# https://developer.android.com/studio/run/
108*e4a36f41SAndroid Build Coastguard Worker# b/123297648
109*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all runas_app:unix_stream_socket connectto;
110*e4a36f41SAndroid Build Coastguard Worker
111*e4a36f41SAndroid Build Coastguard Worker# Untrusted apps need to be able to send a SIGCHLD to runas_app
112*e4a36f41SAndroid Build Coastguard Worker# when running under a debugger (b/123612207)
113*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all runas_app:process sigchld;
114*e4a36f41SAndroid Build Coastguard Worker
115*e4a36f41SAndroid Build Coastguard Worker# Cts: HwRngTest
116*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all sysfs_hwrandom:dir search;
117*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all sysfs_hwrandom:file r_file_perms;
118*e4a36f41SAndroid Build Coastguard Worker
119*e4a36f41SAndroid Build Coastguard Worker# Allow apps to view preloaded media content
120*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all preloads_media_file:dir r_dir_perms;
121*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all preloads_media_file:file r_file_perms;
122*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all preloads_data_file:dir search;
123*e4a36f41SAndroid Build Coastguard Worker
124*e4a36f41SAndroid Build Coastguard Worker# Allow untrusted apps read / execute access to /vendor/app for there can
125*e4a36f41SAndroid Build Coastguard Worker# be pre-installed vendor apps that package a library within themselves.
126*e4a36f41SAndroid Build Coastguard Worker# TODO (b/37784178) Consider creating  a special type for /vendor/app installed
127*e4a36f41SAndroid Build Coastguard Worker# apps.
128*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all vendor_app_file:dir { open getattr read search };
129*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all vendor_app_file:file { r_file_perms execute };
130*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all vendor_app_file:lnk_file { open getattr read };
131*e4a36f41SAndroid Build Coastguard Worker
132*e4a36f41SAndroid Build Coastguard Worker# allow untrusted apps to use UDP sockets provided by the system server but not
133*e4a36f41SAndroid Build Coastguard Worker# modify them other than to connect
134*e4a36f41SAndroid Build Coastguard Workerallow untrusted_app_all system_server:udp_socket {
135*e4a36f41SAndroid Build Coastguard Worker        connect getattr read recvfrom sendto write getopt setopt };
136*e4a36f41SAndroid Build Coastguard Worker
137*e4a36f41SAndroid Build Coastguard Worker# Allow the renderscript compiler to be run.
138*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(untrusted_app_all, rs_exec, rs)
139*e4a36f41SAndroid Build Coastguard Worker
140*e4a36f41SAndroid Build Coastguard Worker# suppress denials caused by debugfs_tracing
141*e4a36f41SAndroid Build Coastguard Workerdontaudit untrusted_app_all debugfs_tracing:file rw_file_perms;
142*e4a36f41SAndroid Build Coastguard Worker
143*e4a36f41SAndroid Build Coastguard Worker# This is allowed for targetSdkVersion <= 25 but disallowed on newer versions.
144*e4a36f41SAndroid Build Coastguard Workerdontaudit untrusted_app_all net_dns_prop:file read;
145*e4a36f41SAndroid Build Coastguard Worker
146*e4a36f41SAndroid Build Coastguard Worker# These have been disallowed since Android O.
147*e4a36f41SAndroid Build Coastguard Worker# For P, we assume that apps are safely handling the denial.
148*e4a36f41SAndroid Build Coastguard Workerdontaudit untrusted_app_all {
149*e4a36f41SAndroid Build Coastguard Worker  proc_stat
150*e4a36f41SAndroid Build Coastguard Worker  proc_uptime
151*e4a36f41SAndroid Build Coastguard Worker  proc_vmstat
152*e4a36f41SAndroid Build Coastguard Worker  proc_zoneinfo
153*e4a36f41SAndroid Build Coastguard Worker}:file read;
154*e4a36f41SAndroid Build Coastguard Worker
155*e4a36f41SAndroid Build Coastguard Worker# Allow the allocation and use of ptys
156*e4a36f41SAndroid Build Coastguard Worker# Used by: https://play.google.com/store/apps/details?id=jackpal.androidterm
157*e4a36f41SAndroid Build Coastguard Workercreate_pty(untrusted_app_all)
158*e4a36f41SAndroid Build Coastguard Worker
159*e4a36f41SAndroid Build Coastguard Worker# Allow access to kcov via its ioctl interface for coverage
160*e4a36f41SAndroid Build Coastguard Worker# guided kernel fuzzing.
161*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
162*e4a36f41SAndroid Build Coastguard Worker  allow untrusted_app_all debugfs_kcov:file rw_file_perms;
163*e4a36f41SAndroid Build Coastguard Worker  allowxperm untrusted_app_all debugfs_kcov:file ioctl { KCOV_INIT_TRACE KCOV_ENABLE KCOV_DISABLE };
164*e4a36f41SAndroid Build Coastguard Worker')
165*e4a36f41SAndroid Build Coastguard Worker
166*e4a36f41SAndroid Build Coastguard Worker# Allow running a VM for test/demo purposes. Note that access to the
167*e4a36f41SAndroid Build Coastguard Worker# service is still guarded with the
168*e4a36f41SAndroid Build Coastguard Worker# `android.permission.MANAGE_VIRTUAL_MACHINE` permission. The
169*e4a36f41SAndroid Build Coastguard Worker# protection level of the permission is
170*e4a36f41SAndroid Build Coastguard Worker# `signature|privileged|development` so that it can only be granted to
171*e4a36f41SAndroid Build Coastguard Worker# either platform-key signed apps, privileged apps, or test-only apps
172*e4a36f41SAndroid Build Coastguard Worker# having `android:testOnly="true"` in their manifest.
173*e4a36f41SAndroid Build Coastguard Workervirtualizationservice_use(untrusted_app_all)
174*e4a36f41SAndroid Build Coastguard Worker
175*e4a36f41SAndroid Build Coastguard Workerwith_native_coverage(`
176*e4a36f41SAndroid Build Coastguard Worker  # Allow writing coverage information to /data/misc/trace
177*e4a36f41SAndroid Build Coastguard Worker  allow domain method_trace_data_file:dir create_dir_perms;
178*e4a36f41SAndroid Build Coastguard Worker  allow domain method_trace_data_file:file create_file_perms;
179*e4a36f41SAndroid Build Coastguard Worker')
180