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:
|
|
|
|
###
|
|
|
|
|
|
|
|
type untrusted_app, domain;
|
|
|
|
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
|
|
|
allow untrusted_app tun_device:chr_file rw_file_perms;
|
|
|
|
|
|
|
|
# ASEC
|
|
|
|
allow untrusted_app asec_apk_file:file r_file_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
|
|
|
|
2014-12-04 01:26:26 +01:00
|
|
|
# b/18504118: Allow reads from /data/anr/traces.txt
|
|
|
|
# TODO: We shouldn't be allowing all untrusted_apps to read
|
|
|
|
# this file. This is only needed for the GMS feedback agent.
|
|
|
|
# See also b/18340553. GMS runs as untrusted_app, and
|
|
|
|
# it's too late to change the domain it runs in.
|
|
|
|
# This line needs to be deleted.
|
|
|
|
allow untrusted_app anr_data_file:file r_file_perms;
|
|
|
|
|
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 /dev/mtp_usb.
|
|
|
|
allow untrusted_app mtp_device:chr_file rw_file_perms;
|
|
|
|
|
|
|
|
# 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;
|
|
|
|
|
|
|
|
# Write to /cache.
|
|
|
|
allow untrusted_app cache_file:dir create_dir_perms;
|
|
|
|
allow untrusted_app cache_file:file create_file_perms;
|
2014-05-13 23:45:00 +02:00
|
|
|
|
2014-12-12 01:01:27 +01:00
|
|
|
allow untrusted_app drmserver_service:service_manager find;
|
|
|
|
allow untrusted_app mediaserver_service:service_manager find;
|
|
|
|
allow untrusted_app nfc_service:service_manager find;
|
|
|
|
allow untrusted_app radio_service:service_manager find;
|
|
|
|
allow untrusted_app surfaceflinger_service:service_manager find;
|
|
|
|
allow untrusted_app system_server_service:service_manager find;
|
2014-12-17 00:45:26 +01:00
|
|
|
allow untrusted_app tmp_system_server_service:service_manager find;
|
|
|
|
|
|
|
|
service_manager_local_audit_domain(untrusted_app)
|
|
|
|
auditallow untrusted_app {
|
|
|
|
tmp_system_server_service
|
|
|
|
-accessibility_service
|
|
|
|
-account_service
|
|
|
|
-activity_service
|
|
|
|
-appops_service
|
|
|
|
-appwidget_service
|
|
|
|
-assetatlas_service
|
|
|
|
-audio_service
|
2015-01-16 00:12:18 +01:00
|
|
|
-backup_service
|
2015-03-03 20:20:15 +01:00
|
|
|
-battery_service
|
2015-01-16 00:12:18 +01:00
|
|
|
-batterystats_service
|
2014-12-17 00:45:26 +01:00
|
|
|
-bluetooth_manager_service
|
|
|
|
-connectivity_service
|
|
|
|
-content_service
|
2015-03-03 20:20:15 +01:00
|
|
|
-country_detector_service
|
|
|
|
-default_android_service
|
2014-12-17 00:45:26 +01:00
|
|
|
-device_policy_service
|
|
|
|
-display_service
|
|
|
|
-dropbox_service
|
|
|
|
-input_method_service
|
|
|
|
-input_service
|
|
|
|
-jobscheduler_service
|
2015-03-03 20:20:15 +01:00
|
|
|
-launcherapps_service
|
2015-01-16 00:12:18 +01:00
|
|
|
-location_service
|
2015-03-03 20:20:15 +01:00
|
|
|
-lock_settings_service
|
|
|
|
-media_router_service
|
|
|
|
-media_session_service
|
|
|
|
-meminfo_service
|
2015-01-16 00:12:18 +01:00
|
|
|
-mount_service
|
2015-03-03 20:20:15 +01:00
|
|
|
-netpolicy_service
|
2015-01-16 00:12:18 +01:00
|
|
|
-netstats_service
|
2015-01-17 02:27:25 +01:00
|
|
|
-network_management_service
|
2015-01-16 00:12:18 +01:00
|
|
|
-network_score_service
|
2014-12-17 00:45:26 +01:00
|
|
|
-notification_service
|
|
|
|
-persistent_data_block_service
|
|
|
|
-power_service
|
|
|
|
-registry_service
|
2015-03-03 20:20:15 +01:00
|
|
|
-search_service
|
|
|
|
-sensorservice_service
|
2015-03-06 19:14:13 +01:00
|
|
|
-statusbar_service
|
2014-12-17 00:45:26 +01:00
|
|
|
-textservices_service
|
|
|
|
-trust_service
|
2015-01-16 00:12:18 +01:00
|
|
|
-uimode_service
|
2014-12-17 00:45:26 +01:00
|
|
|
-user_service
|
2015-01-17 02:27:25 +01:00
|
|
|
-vibrator_service
|
2015-03-03 20:20:15 +01:00
|
|
|
-voiceinteraction_service
|
|
|
|
-wallpaper_service
|
2014-12-17 00:45:26 +01:00
|
|
|
-webviewupdate_service
|
|
|
|
-wifi_service
|
2015-03-03 20:20:15 +01:00
|
|
|
-wifip2p_service
|
2014-12-17 00:45:26 +01:00
|
|
|
}:service_manager find;
|
2014-07-07 22:56:27 +02:00
|
|
|
|
2015-03-13 21:42:42 +01:00
|
|
|
# Allow verifier to access staged apks.
|
|
|
|
allow untrusted_app { apk_tmp_file apk_private_tmp_file }:dir r_dir_perms;
|
|
|
|
allow untrusted_app { apk_tmp_file apk_private_tmp_file }: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.
|
|
|
|
neverallow untrusted_app debugfs: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;
|