priv_app.te revision 0f754edf7b72582ed28d062a9c8f1b911d57a6f3
1###
2### A domain for further sandboxing privileged apps.
3###
4type priv_app, domain;
5app_domain(priv_app)
6# Access the network.
7net_domain(priv_app)
8# Access bluetooth.
9bluetooth_domain(priv_app)
10
11# Some apps ship with shared libraries and binaries that they write out
12# to their sandbox directory and then execute.
13allow priv_app app_data_file:file rx_file_perms;
14
15# android.process.media uses /dev/mtp_usb
16allow priv_app mtp_device:chr_file rw_file_perms;
17
18# Allow the allocation and use of ptys
19# Used by: https://play.privileged.com/store/apps/details?id=jackpal.androidterm
20create_pty(priv_app)
21
22allow priv_app drmserver_service:service_manager find;
23allow priv_app mediaserver_service:service_manager find;
24allow priv_app mediaextractor_service:service_manager find;
25allow priv_app nfc_service:service_manager find;
26allow priv_app radio_service:service_manager find;
27allow priv_app surfaceflinger_service:service_manager find;
28allow priv_app app_api_service:service_manager find;
29allow priv_app system_api_service:service_manager find;
30allow priv_app persistent_data_block_service:service_manager find;
31
32# Traverse into /mnt/media_rw for bypassing FUSE daemon
33# TODO: narrow this to just MediaProvider
34allow priv_app mnt_media_rw_file:dir search;
35
36# Write to /cache.
37allow priv_app cache_file:dir create_dir_perms;
38allow priv_app cache_file:file create_file_perms;
39
40# Access to /data/media.
41allow priv_app media_rw_data_file:dir create_dir_perms;
42allow priv_app media_rw_data_file:file create_file_perms;
43
44# Used by Finsky / Android "Verify Apps" functionality when
45# running "adb install foo.apk".
46allow priv_app shell_data_file:file r_file_perms;
47allow priv_app shell_data_file:dir r_dir_perms;
48
49# Allow verifier to access staged apks.
50allow priv_app { apk_tmp_file apk_private_tmp_file }:dir r_dir_perms;
51allow priv_app { apk_tmp_file apk_private_tmp_file }:file r_file_perms;
52
53# b/18504118: Allow reads from /data/anr/traces.txt
54allow priv_app anr_data_file:file r_file_perms;
55
56# Allow GMS core to access perfprofd output, which is stored
57# in /data/misc/perfprofd/. GMS core will need to list all
58# data stored in that directory to process them one by one.
59userdebug_or_eng(`
60  allow priv_app perfprofd_data_file:file r_file_perms;
61  allow priv_app perfprofd_data_file:dir r_dir_perms;
62')
63
64###
65### neverallow rules
66###
67
68# Receive or send uevent messages.
69neverallow priv_app domain:netlink_kobject_uevent_socket *;
70
71# Receive or send generic netlink messages
72neverallow priv_app domain:netlink_socket *;
73
74# Too much leaky information in debugfs. It's a security
75# best practice to ensure these files aren't readable.
76neverallow priv_app debugfs:file read;
77
78# Do not allow privileged apps to register services.
79# Only trusted components of Android should be registering
80# services.
81neverallow priv_app service_manager_type:service_manager add;
82
83# Do not allow privileged apps to connect to the property service
84# or set properties. b/10243159
85neverallow priv_app property_socket:sock_file write;
86neverallow priv_app init:unix_stream_socket connectto;
87neverallow priv_app property_type:property_service set;
88
89# Do not allow priv_app to be assigned mlstrustedsubject.
90# This would undermine the per-user isolation model being
91# enforced via levelFrom=user in seapp_contexts and the mls
92# constraints.  As there is no direct way to specify a neverallow
93# on attribute assignment, this relies on the fact that fork
94# permission only makes sense within a domain (hence should
95# never be granted to any other domain within mlstrustedsubject)
96# and priv_app is allowed fork permission to itself.
97neverallow priv_app mlstrustedsubject:process fork;
98
99# Do not allow priv_app to hard link to any files.
100# In particular, if priv_app links to other app data
101# files, installd will not be able to guarantee the deletion
102# of the linked to file. Hard links also contribute to security
103# bugs, so we want to ensure priv_app never has this
104# capability.
105neverallow priv_app file_type:file link;
106