blob: cef8b25a2331bc362314f32b4a98fde0d5398a73 [file] [log] [blame]
Alex Klyubina3903972017-01-05 16:06:54 -08001###
2### Services with isolatedProcess=true in their manifest.
3###
4### This file defines the rules for isolated apps. An "isolated
5### app" is an APP with UID between AID_ISOLATED_START (99000)
6### and AID_ISOLATED_END (99999).
7###
8
Alex Klyubinf5446eb2017-03-23 14:27:32 -07009typeattribute isolated_app coredomain;
10
dcashman3e8dbf02016-12-08 11:23:34 -080011app_domain(isolated_app)
dcashman2e00e632016-10-12 14:58:09 -070012
Alex Klyubina3903972017-01-05 16:06:54 -080013# Access already open app data files received over Binder or local socket IPC.
Nick Kralevich00252202018-10-31 12:47:27 -070014allow isolated_app { app_data_file privapp_data_file }:file { append read write getattr lock map };
Alex Klyubina3903972017-01-05 16:06:54 -080015
16allow isolated_app activity_service:service_manager find;
17allow isolated_app display_service:service_manager find;
18allow isolated_app webviewupdate_service:service_manager find;
19
20# Google Breakpad (crash reporter for Chrome) relies on ptrace
21# functionality. Without the ability to ptrace, the crash reporter
22# tool is broken.
23# b/20150694
24# https://code.google.com/p/chromium/issues/detail?id=475270
25allow isolated_app self:process ptrace;
26
27# b/32896414: Allow accessing sdcard file descriptors passed to isolated_apps
28# by other processes. Open should never be allowed, and is blocked by
29# neverallow rules below.
Alex Klyubina3903972017-01-05 16:06:54 -080030# media_rw_data_file is included for sdcardfs, and can be removed if sdcardfs
31# is modified to change the secontext when accessing the lower filesystem.
Nick Kralevich00252202018-10-31 12:47:27 -070032allow isolated_app { sdcard_type media_rw_data_file }:file { read write append getattr lock map };
Alex Klyubina3903972017-01-05 16:06:54 -080033
34# For webviews, isolated_app processes can be forked from the webview_zygote
35# in addition to the zygote. Allow access to resources inherited from the
36# webview_zygote process. These rules are specialized copies of the ones in app.te.
37# Inherit FDs from the webview_zygote.
38allow isolated_app webview_zygote:fd use;
39# Notify webview_zygote of child death.
40allow isolated_app webview_zygote:process sigchld;
41# Inherit logd write socket.
42allow isolated_app webview_zygote:unix_dgram_socket write;
dcashman2e00e632016-10-12 14:58:09 -070043# Read system properties managed by webview_zygote.
44allow isolated_app webview_zygote_tmpfs:file read;
Alex Klyubina3903972017-01-05 16:06:54 -080045
Martijn Coenen1bbda7e2018-11-05 11:39:15 +010046# Inherit FDs from the app_zygote.
47allow isolated_app app_zygote:fd use;
48# Notify app_zygote of child death.
49allow isolated_app app_zygote:process sigchld;
50# Inherit logd write socket.
51allow isolated_app app_zygote:unix_dgram_socket write;
52
Dan Cashman91d398d2017-09-26 12:58:29 -070053# TODO (b/63631799) fix this access
54# suppress denials to /data/local/tmp
55dontaudit isolated_app shell_data_file:dir search;
56
Primiano Tuccic80f9e02017-12-21 03:51:15 +010057# Write app-specific trace data to the Perfetto traced damon. This requires
58# connecting to its producer socket and obtaining a (per-process) tmpfs fd.
Florian Mayer5e522812019-10-08 16:15:14 +010059perfetto_producer(isolated_app)
Primiano Tuccic80f9e02017-12-21 03:51:15 +010060
Ryan Savitskica0690e2019-01-16 16:29:43 +000061# Allow heap profiling if the main app has been marked as profileable or
62# debuggable.
63can_profile_heap(isolated_app)
64
Tri Vo9fbc87c2019-02-28 10:46:57 -080065allow isolated_app ashmem_device:chr_file { getattr read ioctl lock map append write };
Tri Vo8b12ff52019-02-12 14:14:30 -080066
Alex Klyubina3903972017-01-05 16:06:54 -080067#####
68##### Neverallow
69#####
70
Alex Klyubina3903972017-01-05 16:06:54 -080071# Isolated apps should not directly open app data files themselves.
Nick Kralevich23c9d912018-08-02 15:54:23 -070072neverallow isolated_app { app_data_file privapp_data_file }:file open;
Alex Klyubina3903972017-01-05 16:06:54 -080073
74# Only allow appending to /data/anr/traces.txt (b/27853304, b/18340553)
75# TODO: are there situations where isolated_apps write to this file?
76# TODO: should we tighten these restrictions further?
77neverallow isolated_app anr_data_file:file ~{ open append };
78neverallow isolated_app anr_data_file:dir ~search;
79
Dan Cashman91d398d2017-09-26 12:58:29 -070080# Isolated apps must not be permitted to use HwBinder
81neverallow isolated_app hwbinder_device:chr_file *;
82neverallow isolated_app *:hwservice_manager *;
83
84# Isolated apps must not be permitted to use VndBinder
85neverallow isolated_app vndbinder_device:chr_file *;
86
87# Isolated apps must not be permitted to perform actions on Binder and VndBinder service_manager
88# except the find actions for services whitelisted below.
89neverallow isolated_app *:service_manager ~find;
90
Alex Klyubina3903972017-01-05 16:06:54 -080091# b/17487348
92# Isolated apps can only access three services,
Tri Vobfcddbe2019-09-25 11:20:01 -070093# activity_service, display_service, webviewupdate_service.
Alex Klyubina3903972017-01-05 16:06:54 -080094neverallow isolated_app {
95 service_manager_type
96 -activity_service
97 -display_service
98 -webviewupdate_service
99}:service_manager find;
100
101# Isolated apps shouldn't be able to access the driver directly.
102neverallow isolated_app gpu_device:chr_file { rw_file_perms execute };
103
104# Do not allow isolated_app access to /cache
105neverallow isolated_app cache_file:dir ~{ r_dir_perms };
106neverallow isolated_app cache_file:file ~{ read getattr };
107
Alex Klyubina3903972017-01-05 16:06:54 -0800108# Do not allow isolated_app to access external storage, except for files passed
109# via file descriptors (b/32896414).
110neverallow isolated_app { storage_file mnt_user_file sdcard_type }:dir ~getattr;
111neverallow isolated_app { storage_file mnt_user_file }:file_class_set *;
112neverallow isolated_app sdcard_type:{ devfile_class_set lnk_file sock_file fifo_file } *;
Nick Kralevich00252202018-10-31 12:47:27 -0700113neverallow isolated_app sdcard_type:file ~{ read write append getattr lock map };
Alex Klyubina3903972017-01-05 16:06:54 -0800114
115# Do not allow USB access
116neverallow isolated_app { usb_device usbaccessory_device }:chr_file *;
117
118# Restrict the webview_zygote control socket.
Robert Sesek869562e2018-01-30 10:54:33 -0500119neverallow isolated_app webview_zygote:sock_file write;
Nick Kralevich62d3b4f2017-10-09 15:10:30 -0700120
121# Limit the /sys files which isolated_app can access. This is important
122# for controlling isolated_app attack surface.
123neverallow isolated_app {
124 sysfs_type
125 -sysfs_devices_system_cpu
Tri Vod6c5ff52019-03-13 12:06:01 -0700126 -sysfs_transparent_hugepage
Nick Kralevich62d3b4f2017-10-09 15:10:30 -0700127 -sysfs_usb # TODO: check with audio team if needed for isolated_app (b/28417852)
128}:file no_rw_file_perms;
Nick Kralevich8f084562018-10-02 21:43:20 -0700129
130# No creation of sockets families other than AF_UNIX sockets.
131# List taken from system/sepolicy/public/global_macros - socket_class_set
132# excluding unix_stream_socket and unix_dgram_socket.
133# Many of these are socket families which have never and will never
134# be compiled into the Android kernel.
135neverallow isolated_app self:{
136 socket tcp_socket udp_socket rawip_socket netlink_socket packet_socket
137 key_socket appletalk_socket netlink_route_socket
138 netlink_tcpdiag_socket netlink_nflog_socket netlink_xfrm_socket
139 netlink_selinux_socket netlink_audit_socket netlink_dnrt_socket
140 netlink_kobject_uevent_socket tun_socket netlink_iscsi_socket
141 netlink_fib_lookup_socket netlink_connector_socket netlink_netfilter_socket
142 netlink_generic_socket netlink_scsitransport_socket netlink_rdma_socket
143 netlink_crypto_socket sctp_socket icmp_socket ax25_socket ipx_socket
144 netrom_socket atmpvc_socket x25_socket rose_socket decnet_socket atmsvc_socket
145 rds_socket irda_socket pppox_socket llc_socket can_socket tipc_socket
146 bluetooth_socket iucv_socket rxrpc_socket isdn_socket phonet_socket
147 ieee802154_socket caif_socket alg_socket nfc_socket vsock_socket kcm_socket
Nick Kralevicha194d372018-11-16 02:48:03 -0800148 qipcrtr_socket smc_socket xdp_socket
Nick Kralevich8f084562018-10-02 21:43:20 -0700149} create;