2013-07-13 01:33:29 +02:00
|
|
|
###
|
|
|
|
### Untrusted apps.
|
|
|
|
###
|
2014-02-21 19:26:20 +01:00
|
|
|
### This file defines the rules for untrusted apps.
|
|
|
|
### Apps are labeled based on mac_permissions.xml (maps signer and
|
|
|
|
### optionally package name to seinfo value) and seapp_contexts (maps UID
|
|
|
|
### and optionally seinfo value to domain for process and type for data
|
|
|
|
### directory). The untrusted_app domain is the default assignment in
|
|
|
|
### seapp_contexts for any app with UID between APP_AID (10000)
|
|
|
|
### and AID_ISOLATED_START (99000) if the app has no specific seinfo
|
|
|
|
### value as determined from mac_permissions.xml. In current AOSP, this
|
|
|
|
### domain is assigned to all non-system apps as well as to any system apps
|
Coalesce shared_app, media_app, release_app into untrusted_app.
This change folds the shared_app, media_app, and release_app
domains into untrusted_app, reducing the set of app domains down
to just distinct domains for the fixed UID apps (e.g. system_app, bluetooth,
nfc, radio), a single domain for apps signed by the platform key
(platform_app), and a single domain for all other apps (untrusted_app).
Thus, SELinux only distinguishes when already distinguished by a predefined
Android ID (AID) or by the platform certificate (which get the signature-only
Android permissions and thus may require special OS-level accesses).
It is still possible to introduce specific app domains for specific
apps by adding signer and package stanzas to mac_permissions.xml,
but this can be done on an as-needed basis for specialized apps that
require particular OS-level permissions outside the usual set.
As there is now only a single platform app domains, get rid of the
platformappdomain attribute and platform_app_domain() macro. We used
to add mlstrustedsubject to those domains but drop this since we are not
using MLS in AOSP presently; we can revisit which domains need it if/when
we use MLS.
Since we are dropping the shared, media, and release seinfo entries from
seapp_contexts, drop them from mac_permissions.xml as well. However,
we leave the keys.conf entries in case someone wants to add a signer
entry in the future for specific apps signed by those keys to
mac_permissions.xml.
Change-Id: I877192cca07360c4a3c0ef475f016cc273e1d968
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2014-04-04 15:09:25 +02:00
|
|
|
### that are not signed by the platform key. To move
|
2014-02-21 19:26:20 +01:00
|
|
|
### a system app into a specific domain, add a signer entry for it to
|
|
|
|
### mac_permissions.xml and assign it one of the pre-existing seinfo values
|
|
|
|
### or define and use a new seinfo value in both mac_permissions.xml and
|
|
|
|
### seapp_contexts.
|
2013-07-13 01:33:29 +02:00
|
|
|
###
|
|
|
|
### untrusted_app includes all the appdomain rules, plus the
|
|
|
|
### additional following rules:
|
|
|
|
###
|
|
|
|
|
2016-01-23 00:51:41 +01:00
|
|
|
type untrusted_app, domain;
|
2013-07-13 01:33:29 +02:00
|
|
|
app_domain(untrusted_app)
|
|
|
|
net_domain(untrusted_app)
|
|
|
|
bluetooth_domain(untrusted_app)
|
untrusted_app.te / isolated_app.te / app.te first pass
This is my first attempt at creating an enforcing SELinux domain for
apps, untrusted_apps, and isolated_apps. Much of these rules are based on the
contents of app.te as of commit 11153ef34928ab9d13658606695cba192aa03e21
with extensive modifications, some of which are included below.
* Allow communication with netd/dnsproxyd, to allow netd to handle
dns requests
* Allow binder communications with the DNS server
* Allow binder communications with surfaceflinger
* Allow an app to bind to tcp/udp ports
* Allow all domains to read files from the root partition, assuming
the DAC allows access.
In addition, I added a bunch of "neverallow" rules, to assert that
certain capabilities are never added.
This change has a high probability of breaking someone, somewhere.
If it does, then I'm happy to fix the breakage, rollback this change,
or put untrusted_app into permissive mode.
Change-Id: I83f220135d20ab4f70fbd7be9401b5b1def1fe35
2013-07-13 03:45:56 +02:00
|
|
|
|
2013-12-11 15:08:09 +01:00
|
|
|
# Some apps ship with shared libraries and binaries that they write out
|
|
|
|
# to their sandbox directory and then execute.
|
2014-06-02 23:49:10 +02:00
|
|
|
allow untrusted_app app_data_file:file { rx_file_perms execmod };
|
2013-12-11 15:08:09 +01:00
|
|
|
|
untrusted_app.te / isolated_app.te / app.te first pass
This is my first attempt at creating an enforcing SELinux domain for
apps, untrusted_apps, and isolated_apps. Much of these rules are based on the
contents of app.te as of commit 11153ef34928ab9d13658606695cba192aa03e21
with extensive modifications, some of which are included below.
* Allow communication with netd/dnsproxyd, to allow netd to handle
dns requests
* Allow binder communications with the DNS server
* Allow binder communications with surfaceflinger
* Allow an app to bind to tcp/udp ports
* Allow all domains to read files from the root partition, assuming
the DAC allows access.
In addition, I added a bunch of "neverallow" rules, to assert that
certain capabilities are never added.
This change has a high probability of breaking someone, somewhere.
If it does, then I'm happy to fix the breakage, rollback this change,
or put untrusted_app into permissive mode.
Change-Id: I83f220135d20ab4f70fbd7be9401b5b1def1fe35
2013-07-13 03:45:56 +02:00
|
|
|
# ASEC
|
|
|
|
allow untrusted_app asec_apk_file:file r_file_perms;
|
2016-07-15 18:23:44 +02:00
|
|
|
allow untrusted_app asec_apk_file:dir r_dir_perms;
|
2014-02-04 17:36:41 +01:00
|
|
|
# Execute libs in asec containers.
|
2014-06-02 23:49:10 +02:00
|
|
|
allow untrusted_app asec_public_file:file { execute execmod };
|
untrusted_app.te / isolated_app.te / app.te first pass
This is my first attempt at creating an enforcing SELinux domain for
apps, untrusted_apps, and isolated_apps. Much of these rules are based on the
contents of app.te as of commit 11153ef34928ab9d13658606695cba192aa03e21
with extensive modifications, some of which are included below.
* Allow communication with netd/dnsproxyd, to allow netd to handle
dns requests
* Allow binder communications with the DNS server
* Allow binder communications with surfaceflinger
* Allow an app to bind to tcp/udp ports
* Allow all domains to read files from the root partition, assuming
the DAC allows access.
In addition, I added a bunch of "neverallow" rules, to assert that
certain capabilities are never added.
This change has a high probability of breaking someone, somewhere.
If it does, then I'm happy to fix the breakage, rollback this change,
or put untrusted_app into permissive mode.
Change-Id: I83f220135d20ab4f70fbd7be9401b5b1def1fe35
2013-07-13 03:45:56 +02:00
|
|
|
|
|
|
|
# Allow the allocation and use of ptys
|
|
|
|
# Used by: https://play.google.com/store/apps/details?id=jackpal.androidterm
|
2013-09-27 15:44:32 +02:00
|
|
|
create_pty(untrusted_app)
|
2013-07-16 00:48:34 +02:00
|
|
|
|
|
|
|
# Used by Finsky / Android "Verify Apps" functionality when
|
|
|
|
# running "adb install foo.apk".
|
|
|
|
# TODO: Long term, we don't want apps probing into shell data files.
|
|
|
|
# Figure out a way to remove these rules.
|
2013-09-05 01:12:33 +02:00
|
|
|
allow untrusted_app shell_data_file:file r_file_perms;
|
2013-07-16 00:48:34 +02:00
|
|
|
allow untrusted_app shell_data_file:dir r_dir_perms;
|
Coalesce shared_app, media_app, release_app into untrusted_app.
This change folds the shared_app, media_app, and release_app
domains into untrusted_app, reducing the set of app domains down
to just distinct domains for the fixed UID apps (e.g. system_app, bluetooth,
nfc, radio), a single domain for apps signed by the platform key
(platform_app), and a single domain for all other apps (untrusted_app).
Thus, SELinux only distinguishes when already distinguished by a predefined
Android ID (AID) or by the platform certificate (which get the signature-only
Android permissions and thus may require special OS-level accesses).
It is still possible to introduce specific app domains for specific
apps by adding signer and package stanzas to mac_permissions.xml,
but this can be done on an as-needed basis for specialized apps that
require particular OS-level permissions outside the usual set.
As there is now only a single platform app domains, get rid of the
platformappdomain attribute and platform_app_domain() macro. We used
to add mlstrustedsubject to those domains but drop this since we are not
using MLS in AOSP presently; we can revisit which domains need it if/when
we use MLS.
Since we are dropping the shared, media, and release seinfo entries from
seapp_contexts, drop them from mac_permissions.xml as well. However,
we leave the keys.conf entries in case someone wants to add a signer
entry in the future for specific apps signed by those keys to
mac_permissions.xml.
Change-Id: I877192cca07360c4a3c0ef475f016cc273e1d968
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2014-04-04 15:09:25 +02:00
|
|
|
|
2015-03-06 00:40:04 +01:00
|
|
|
# Read and write system app data files passed over Binder.
|
|
|
|
# Motivating case was /data/data/com.android.settings/cache/*.jpg for
|
|
|
|
# cropping or taking user photos.
|
|
|
|
allow untrusted_app system_app_data_file:file { read write getattr };
|
|
|
|
|
Coalesce shared_app, media_app, release_app into untrusted_app.
This change folds the shared_app, media_app, and release_app
domains into untrusted_app, reducing the set of app domains down
to just distinct domains for the fixed UID apps (e.g. system_app, bluetooth,
nfc, radio), a single domain for apps signed by the platform key
(platform_app), and a single domain for all other apps (untrusted_app).
Thus, SELinux only distinguishes when already distinguished by a predefined
Android ID (AID) or by the platform certificate (which get the signature-only
Android permissions and thus may require special OS-level accesses).
It is still possible to introduce specific app domains for specific
apps by adding signer and package stanzas to mac_permissions.xml,
but this can be done on an as-needed basis for specialized apps that
require particular OS-level permissions outside the usual set.
As there is now only a single platform app domains, get rid of the
platformappdomain attribute and platform_app_domain() macro. We used
to add mlstrustedsubject to those domains but drop this since we are not
using MLS in AOSP presently; we can revisit which domains need it if/when
we use MLS.
Since we are dropping the shared, media, and release seinfo entries from
seapp_contexts, drop them from mac_permissions.xml as well. However,
we leave the keys.conf entries in case someone wants to add a signer
entry in the future for specific apps signed by those keys to
mac_permissions.xml.
Change-Id: I877192cca07360c4a3c0ef475f016cc273e1d968
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2014-04-04 15:09:25 +02:00
|
|
|
#
|
|
|
|
# Rules migrated from old app domains coalesced into untrusted_app.
|
|
|
|
# This includes what used to be media_app, shared_app, and release_app.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Access to /data/media.
|
|
|
|
allow untrusted_app media_rw_data_file:dir create_dir_perms;
|
|
|
|
allow untrusted_app media_rw_data_file:file create_file_perms;
|
|
|
|
|
2015-05-19 22:52:51 +02:00
|
|
|
# Traverse into /mnt/media_rw for bypassing FUSE daemon
|
|
|
|
# TODO: narrow this to just MediaProvider
|
|
|
|
allow untrusted_app mnt_media_rw_file:dir search;
|
|
|
|
|
2015-09-09 03:22:12 +02:00
|
|
|
# allow cts to query all services
|
|
|
|
allow untrusted_app servicemanager:service_manager list;
|
|
|
|
|
2015-09-09 19:48:04 +02:00
|
|
|
allow untrusted_app audioserver_service:service_manager find;
|
2015-12-04 01:10:05 +01:00
|
|
|
allow untrusted_app cameraserver_service:service_manager find;
|
2014-12-12 01:01:27 +01:00
|
|
|
allow untrusted_app drmserver_service:service_manager find;
|
|
|
|
allow untrusted_app mediaserver_service:service_manager find;
|
2015-09-22 19:56:03 +02:00
|
|
|
allow untrusted_app mediaextractor_service:service_manager find;
|
2016-02-03 01:10:37 +01:00
|
|
|
allow untrusted_app mediacodec_service:service_manager find;
|
2016-02-12 18:05:42 +01:00
|
|
|
allow untrusted_app mediadrmserver_service:service_manager find;
|
2014-12-12 01:01:27 +01:00
|
|
|
allow untrusted_app nfc_service:service_manager find;
|
|
|
|
allow untrusted_app radio_service:service_manager find;
|
|
|
|
allow untrusted_app surfaceflinger_service:service_manager find;
|
2015-04-03 01:50:08 +02:00
|
|
|
allow untrusted_app app_api_service:service_manager find;
|
|
|
|
|
2015-05-06 00:11:44 +02:00
|
|
|
# Allow GMS core to access perfprofd output, which is stored
|
|
|
|
# in /data/misc/perfprofd/. GMS core will need to list all
|
|
|
|
# data stored in that directory to process them one by one.
|
|
|
|
userdebug_or_eng(`
|
|
|
|
allow untrusted_app perfprofd_data_file:file r_file_perms;
|
|
|
|
allow untrusted_app perfprofd_data_file:dir r_dir_perms;
|
|
|
|
')
|
2015-05-14 01:06:34 +02:00
|
|
|
|
2015-10-14 01:20:05 +02:00
|
|
|
# gdbserver for ndk-gdb ptrace attaches to app process.
|
|
|
|
allow untrusted_app self:process ptrace;
|
|
|
|
|
2016-01-27 01:56:24 +01:00
|
|
|
# access /proc/net/xt_qtguid/stats
|
|
|
|
r_dir_file(untrusted_app, proc_net)
|
2016-01-23 00:49:42 +01:00
|
|
|
|
2016-03-12 00:23:49 +01:00
|
|
|
# Cts: HwRngTest
|
|
|
|
allow untrusted_app sysfs_hwrandom:dir search;
|
|
|
|
allow untrusted_app sysfs_hwrandom:file r_file_perms;
|
|
|
|
|
2014-05-13 23:45:00 +02:00
|
|
|
###
|
|
|
|
### neverallow rules
|
|
|
|
###
|
|
|
|
|
2014-09-22 08:35:24 +02:00
|
|
|
# Receive or send uevent messages.
|
2015-01-29 02:46:30 +01:00
|
|
|
neverallow untrusted_app domain:netlink_kobject_uevent_socket *;
|
|
|
|
|
|
|
|
# Receive or send generic netlink messages
|
|
|
|
neverallow untrusted_app domain:netlink_socket *;
|
2014-09-22 08:35:24 +02:00
|
|
|
|
2014-05-13 23:45:00 +02:00
|
|
|
# Too much leaky information in debugfs. It's a security
|
|
|
|
# best practice to ensure these files aren't readable.
|
2015-12-18 01:38:21 +01:00
|
|
|
neverallow untrusted_app debugfs_type:file read;
|
2014-07-07 18:27:53 +02:00
|
|
|
|
|
|
|
# Do not allow untrusted apps to register services.
|
|
|
|
# Only trusted components of Android should be registering
|
|
|
|
# services.
|
|
|
|
neverallow untrusted_app service_manager_type:service_manager add;
|
2014-07-10 03:58:04 +02:00
|
|
|
|
2014-07-10 04:03:08 +02:00
|
|
|
# Do not allow untrusted_apps to connect to the property service
|
2014-07-10 03:58:04 +02:00
|
|
|
# or set properties. b/10243159
|
|
|
|
neverallow untrusted_app property_socket:sock_file write;
|
|
|
|
neverallow untrusted_app init:unix_stream_socket connectto;
|
|
|
|
neverallow untrusted_app property_type:property_service set;
|
2015-03-13 21:54:48 +01:00
|
|
|
|
|
|
|
# Do not allow untrusted_app to be assigned mlstrustedsubject.
|
|
|
|
# This would undermine the per-user isolation model being
|
|
|
|
# enforced via levelFrom=user in seapp_contexts and the mls
|
|
|
|
# constraints. As there is no direct way to specify a neverallow
|
|
|
|
# on attribute assignment, this relies on the fact that fork
|
|
|
|
# permission only makes sense within a domain (hence should
|
|
|
|
# never be granted to any other domain within mlstrustedsubject)
|
|
|
|
# and untrusted_app is allowed fork permission to itself.
|
|
|
|
neverallow untrusted_app mlstrustedsubject:process fork;
|
2015-03-27 02:18:03 +01:00
|
|
|
|
|
|
|
# Do not allow untrusted_app to hard link to any files.
|
|
|
|
# In particular, if untrusted_app links to other app data
|
|
|
|
# files, installd will not be able to guarantee the deletion
|
|
|
|
# of the linked to file. Hard links also contribute to security
|
|
|
|
# bugs, so we want to ensure untrusted_app never has this
|
|
|
|
# capability.
|
|
|
|
neverallow untrusted_app file_type:file link;
|
2015-07-24 22:25:45 +02:00
|
|
|
|
|
|
|
# Do not allow untrusted_app to access network MAC address file
|
|
|
|
neverallow untrusted_app sysfs_mac_address:file no_rw_file_perms;
|
2015-10-06 18:11:02 +02:00
|
|
|
|
2016-04-15 19:54:40 +02:00
|
|
|
# Restrict socket ioctls. Either 1. disallow privileged ioctls, 2. disallow the
|
|
|
|
# ioctl permission, or 3. disallow the socket class.
|
2016-01-05 18:36:12 +01:00
|
|
|
neverallowxperm untrusted_app domain:{ rawip_socket tcp_socket udp_socket } ioctl priv_sock_ioctls;
|
2016-04-15 19:54:40 +02:00
|
|
|
neverallow untrusted_app *:{ netlink_route_socket netlink_selinux_socket } ioctl;
|
|
|
|
neverallow untrusted_app *:{
|
|
|
|
socket netlink_socket packet_socket key_socket appletalk_socket
|
|
|
|
netlink_firewall_socket netlink_tcpdiag_socket netlink_nflog_socket
|
|
|
|
netlink_xfrm_socket netlink_audit_socket netlink_ip6fw_socket
|
|
|
|
netlink_dnrt_socket netlink_kobject_uevent_socket tun_socket
|
|
|
|
netlink_iscsi_socket netlink_fib_lookup_socket netlink_connector_socket
|
|
|
|
netlink_netfilter_socket netlink_generic_socket netlink_scsitransport_socket
|
|
|
|
netlink_rdma_socket netlink_crypto_socket
|
|
|
|
} *;
|
2015-12-07 17:30:43 +01:00
|
|
|
|
2015-10-16 02:11:27 +02:00
|
|
|
# Do not allow untrusted_app access to /cache
|
2015-12-22 21:37:17 +01:00
|
|
|
neverallow untrusted_app { cache_file cache_recovery_file }:dir ~{ r_dir_perms };
|
|
|
|
neverallow untrusted_app { cache_file cache_recovery_file }:file ~{ read getattr };
|
2016-01-08 19:35:19 +01:00
|
|
|
|
2016-02-09 01:20:50 +01:00
|
|
|
# Do not allow untrusted_app to create/unlink files outside of its sandbox,
|
|
|
|
# internal storage or sdcard.
|
|
|
|
# World accessible data locations allow application to fill the device
|
|
|
|
# with unaccounted for data. This data will not get removed during
|
|
|
|
# application un-installation.
|
|
|
|
neverallow untrusted_app {
|
|
|
|
fs_type
|
|
|
|
-fuse # sdcard
|
2016-03-02 01:13:50 +01:00
|
|
|
-sdcardfs # sdcard
|
2016-02-09 01:20:50 +01:00
|
|
|
file_type
|
|
|
|
-app_data_file # The apps sandbox itself
|
|
|
|
-media_rw_data_file # Internal storage. Known that apps can
|
|
|
|
# leave artfacts here after uninstall.
|
2016-02-01 20:28:39 +01:00
|
|
|
-user_profile_data_file # Access to profile files
|
2016-02-23 17:34:23 +01:00
|
|
|
-user_profile_foreign_dex_data_file # Access to profile files
|
2016-02-09 01:20:50 +01:00
|
|
|
userdebug_or_eng(`
|
|
|
|
-method_trace_data_file # only on ro.debuggable=1
|
|
|
|
-coredump_file # userdebug/eng only
|
|
|
|
')
|
|
|
|
}:dir_file_class_set { create unlink };
|
2016-02-29 05:52:55 +01:00
|
|
|
|
|
|
|
# Do not allow untrusted_app to directly open tun_device
|
|
|
|
neverallow untrusted_app tun_device:chr_file open;
|
2016-03-25 20:22:32 +01:00
|
|
|
|
|
|
|
# Only allow appending to /data/anr/traces.txt (b/27853304, b/18340553)
|
|
|
|
neverallow untrusted_app anr_data_file:file ~{ open append };
|
|
|
|
neverallow untrusted_app anr_data_file:dir ~search;
|