blob: 56f9a0b4cb5c722027e3cda6e5d56a54d1809dbe [file] [log] [blame]
RafayKamraneaa18ce2021-10-27 14:12:44 +00001# /proc/net access.
2# TODO(b/9496886) Audit access for removal.
3# proc_net access for the negated domains below is granted (or not) in their
4# individual .te files.
5r_dir_file({
6 appdomain
7 -ephemeral_app
8 -isolated_app
9 -platform_app
10 -priv_app
11 -shell
12 -supplemental_process
13 -system_app
14 -untrusted_app_all
15}, proc_net_type)
16# audit access for all these non-core app domains.
17userdebug_or_eng(`
18 auditallow {
19 appdomain
20 -ephemeral_app
21 -isolated_app
22 -platform_app
23 -priv_app
24 -shell
25 -su
26 -supplemental_process
27 -system_app
28 -untrusted_app_all
29 } proc_net_type:{ dir file lnk_file } { getattr open read };
30')
31
William Hester5f486c72019-01-15 13:39:30 -080032# Allow apps to read the Test Harness Mode property. This property is used in
33# the implementation of ActivityManager.isDeviceInTestHarnessMode()
34get_prop(appdomain, test_harness_prop)
35
Inseob Kimdbcc4592020-05-21 20:12:55 +090036get_prop(appdomain, boot_status_prop)
37get_prop(appdomain, dalvik_config_prop)
Inseob Kimdddf6f52020-07-06 22:24:11 +090038get_prop(appdomain, media_config_prop)
Inseob Kim5eacf722020-07-01 01:27:49 +090039get_prop(appdomain, packagemanager_config_prop)
Inseob Kim4ae7ec12020-08-03 14:29:47 +090040get_prop(appdomain, radio_control_prop)
Inseob Kimdbcc4592020-05-21 20:12:55 +090041get_prop(appdomain, surfaceflinger_color_prop)
42get_prop(appdomain, systemsound_config_prop)
Inseob Kim641cffe2020-06-05 10:40:16 +090043get_prop(appdomain, telephony_config_prop)
Inseob Kimdbcc4592020-05-21 20:12:55 +090044get_prop(appdomain, userspace_reboot_config_prop)
45get_prop(appdomain, vold_config_prop)
Hongguang Chen67c36882020-07-27 15:15:53 -070046get_prop(appdomain, adbd_config_prop)
Inseob Kimdbcc4592020-05-21 20:12:55 +090047
Calin Juravle0b2ca6c2021-05-18 15:33:08 -070048# Allow ART to be configurable via device_config properties
49# (ART "runs" inside the app process)
50get_prop(appdomain, device_config_runtime_native_prop)
51get_prop(appdomain, device_config_runtime_native_boot_prop)
52
Florian Mayer5e522812019-10-08 16:15:14 +010053userdebug_or_eng(`perfetto_producer({ appdomain })')
54
Jeff Vander Stoep607bc672019-12-16 10:59:03 +010055# Prevent apps from causing presubmit failures.
56# Apps can cause selinux denials by accessing CE storage
57# and/or external storage. In either case, the selinux denial is
58# not the cause of the failure, but just a symptom that
59# storage isn't ready. Many apps handle the failure appropriately.
60#
61# Apps cannot access external storage before it becomes available.
62dontaudit appdomain storage_stub_file:dir getattr;
63# Attempts to write to system_data_file is generally a sign
64# that apps are attempting to access encrypted storage before
65# the ACTION_USER_UNLOCKED intent is delivered. Apps are not
66# allowed to write to CE storage before it's available.
67# Attempting to do so will be blocked by both selinux and unix
68# permissions.
69dontaudit appdomain system_data_file:dir write;
Jeff Vander Stoep67896ee2020-04-02 13:36:17 +020070# Apps should not be reading vendor-defined properties.
71dontaudit appdomain vendor_default_prop:file read;
Jeff Vander Stoep607bc672019-12-16 10:59:03 +010072
Zimb61bcc82021-04-08 12:20:26 +010073# Access to /mnt/media_rw/<vol> (limited by DAC to apps with external_storage gid)
74allow appdomain mnt_media_rw_file:dir search;
75
Nathan Haroldee268642017-12-14 18:20:30 -080076neverallow appdomain system_server:udp_socket {
Nathan Harold252b0152018-03-27 06:34:54 -070077 accept append bind create ioctl listen lock name_bind
78 relabelfrom relabelto setattr shutdown };
Nick Kralevich1e5021c2018-11-28 17:50:24 -080079
80# Transition to a non-app domain.
81# Exception for the shell and su domains, can transition to runas, etc.
Nick Kralevich0eb0a162018-12-12 09:06:05 -080082# Exception for crash_dump to allow for app crash reporting.
83# Exception for renderscript binaries (/system/bin/bcc, /system/bin/ld.mc)
84# to allow renderscript to create privileged executable files.
85neverallow { appdomain -shell userdebug_or_eng(`-su') }
86 { domain -appdomain -crash_dump -rs }:process { transition };
87neverallow { appdomain -shell userdebug_or_eng(`-su') }
88 { domain -appdomain }:process { dyntransition };
Daniel Rosenbergafede842020-05-11 22:50:40 -070089
90# Don't allow regular apps access to storage configuration properties.
91neverallow { appdomain -mediaprovider_app } storage_config_prop:file no_rw_file_perms;
Peiyong Lin37dea072020-06-03 12:20:41 -070092
Inseob Kimc80b0242020-07-16 22:25:47 +090093# Allow to read sendbug.preferred.domain
94get_prop(appdomain, sendbug_config_prop)
95
Peiyong Lin37dea072020-06-03 12:20:41 -070096# Allow to read graphics related properties.
97get_prop(appdomain, graphics_config_prop)
Inseob Kimc97a97c2020-07-20 20:26:07 +090098
99# Allow to read persist.config.calibration_fac
100get_prop(appdomain, camera_calibration_prop)
Inseob Kim0cef0fe2020-11-17 13:54:52 +0900101
102# Allow to read db.log.detailed, db.log.slow_query_threshold*
103get_prop(appdomain, sqlite_log_prop)
Orion Hodson8f75f762020-10-16 15:29:55 +0100104
Seigo Nonaka9c3707f2021-01-21 13:08:31 -0800105# Allow font file read by apps.
106allow appdomain font_data_file:file r_file_perms;
107allow appdomain font_data_file:dir r_dir_perms;
108
Martijn Coenen4825e862021-03-29 13:51:35 +0200109# Enter /data/misc/apexdata/
110allow appdomain apex_module_data_file:dir search;
Orion Hodson13ee6532021-04-27 15:51:33 +0100111# Read /data/misc/apexdata/com.android.art, execute signed AOT artifacts.
Martijn Coenen4825e862021-03-29 13:51:35 +0200112allow appdomain apex_art_data_file:dir r_dir_perms;
Orion Hodson13ee6532021-04-27 15:51:33 +0100113allow appdomain apex_art_data_file:file rx_file_perms;
Orion Hodson8f75f762020-10-16 15:29:55 +0100114
Josh Gaoce1c4a52021-02-03 18:35:06 -0800115# Allow access to tombstones if an fd to one is given to you.
116# This is restricted by unix permissions, so an app must go through system_server to get one.
117allow appdomain tombstone_data_file:file { getattr read };
118neverallow appdomain tombstone_data_file:file ~{ getattr read };
119
RafayKamraneaa18ce2021-10-27 14:12:44 +0000120# Execute the shell or other system executables.
121allow { appdomain -ephemeral_app -supplemental_process } shell_exec:file rx_file_perms;
122allow { appdomain -ephemeral_app -supplemental_process } toolbox_exec:file rx_file_perms;
123not_full_treble(`allow { appdomain -ephemeral_app -supplemental_process } vendor_file:file x_file_perms;')
124
125# Allow apps access to /vendor/app except for privileged
126# apps which cannot be in /vendor.
127r_dir_file({ appdomain -ephemeral_app -supplemental_process }, vendor_app_file)
128allow { appdomain -ephemeral_app -supplemental_process } vendor_app_file:file execute;
129
130# Perform binder IPC to supplemental process.
131binder_call(appdomain, supplemental_process)
132
133# Allow access to external storage; we have several visible mount points under /storage
134# and symlinks to primary storage at places like /storage/sdcard0 and /mnt/user/0/primary
135allow { appdomain -isolated_app -ephemeral_app -supplemental_process } storage_file:dir r_dir_perms;
136allow { appdomain -isolated_app -ephemeral_app -supplemental_process } storage_file:lnk_file r_file_perms;
137allow { appdomain -isolated_app -ephemeral_app -supplemental_process } mnt_user_file:dir r_dir_perms;
138allow { appdomain -isolated_app -ephemeral_app -supplemental_process } mnt_user_file:lnk_file r_file_perms;
139
140# Read/write visible storage
141allow { appdomain -isolated_app -ephemeral_app -supplemental_process } { sdcard_type fuse }:dir create_dir_perms;
142allow { appdomain -isolated_app -ephemeral_app -supplemental_process } { sdcard_type fuse }:file create_file_perms;
143# This should be removed if sdcardfs is modified to alter the secontext for its
144# accesses to the underlying FS.
145allow { appdomain -isolated_app -ephemeral_app -supplemental_process } media_rw_data_file:dir create_dir_perms;
146allow { appdomain -isolated_app -ephemeral_app -supplemental_process } media_rw_data_file:file create_file_perms;
147
148# Allow apps to use the USB Accessory interface.
149# http://developer.android.com/guide/topics/connectivity/usb/accessory.html
150#
151# USB devices are first opened by the system server (USBDeviceManagerService)
152# and the file descriptor is passed to the right Activity via binder.
153allow { appdomain -isolated_app -ephemeral_app -supplemental_process } usb_device:chr_file { read write getattr ioctl };
154allow { appdomain -isolated_app -ephemeral_app -supplemental_process } usbaccessory_device:chr_file { read write getattr };
155
156#logd access
157control_logd({ appdomain -ephemeral_app -supplemental_process })
158
159# application inherit logd write socket (urge is to deprecate this long term)
160allow { appdomain -isolated_app -ephemeral_app -supplemental_process } keystore:keystore_key { get_state get insert delete exist list sign verify };
161allow { appdomain -isolated_app -ephemeral_app -supplemental_process } keystore:keystore2_key { delete use get_info rebind update };
162
163allow { appdomain -isolated_app -ephemeral_app -supplemental_process } keystore_maintenance_service:service_manager find;
164allow { appdomain -isolated_app -ephemeral_app -supplemental_process } keystore:keystore2 get_state;
165
166use_keystore({ appdomain -isolated_app -ephemeral_app -supplemental_process })
167
168use_credstore({ appdomain -isolated_app -ephemeral_app -supplemental_process })
169
170# For app fuse.
171pdx_client({ appdomain -isolated_app -ephemeral_app -supplemental_process }, display_client)
172pdx_client({ appdomain -isolated_app -ephemeral_app -supplemental_process }, display_manager)
173pdx_client({ appdomain -isolated_app -ephemeral_app -supplemental_process }, display_vsync)
174pdx_client({ appdomain -isolated_app -ephemeral_app -supplemental_process }, performance_client)
175# Apps do not directly open the IPC socket for bufferhubd.
176pdx_use({ appdomain -isolated_app -ephemeral_app -supplemental_process }, bufferhub_client)
177
178# Apps receive an open tun fd from the framework for
179# device traffic. Do not allow untrusted app to directly open tun_device
180allow { appdomain -isolated_app -ephemeral_app -supplemental_process } tun_device:chr_file { read write getattr append ioctl };
181allowxperm { appdomain -isolated_app -ephemeral_app -supplemental_process } tun_device:chr_file ioctl TUNGETIFF;
182
Orion Hodson8f75f762020-10-16 15:29:55 +0100183# Sensitive app domains are not allowed to execute from /data
184# to prevent persistence attacks and ensure all code is executed
185# from read-only locations.
186neverallow {
187 bluetooth
188 isolated_app
189 nfc
190 radio
191 shared_relro
192 system_app
193} {
194 data_file_type
195 -apex_art_data_file
196 -dalvikcache_data_file
197 -system_data_file # shared libs in apks
198 -apk_data_file
199}:file no_x_file_perms;
Tianjieb729aa62021-10-05 22:13:20 -0700200
201# For now, don't allow apps other than gmscore to access /data/misc_ce/<userid>/checkin
202neverallow { appdomain -gmscore_app } checkin_data_file:dir *;
203neverallow { appdomain -gmscore_app } checkin_data_file:file *;