2017-01-28 00:53:38 +01:00
|
|
|
###
|
|
|
|
### neverallow rules for untrusted app domains
|
|
|
|
###
|
|
|
|
|
2017-02-13 22:33:27 +01:00
|
|
|
# Only allow domains in AOSP to use the untrusted_app_all attribute.
|
|
|
|
neverallow { untrusted_app_all -untrusted_app -untrusted_app_25 } domain:process fork;
|
|
|
|
|
2017-04-11 01:57:48 +02:00
|
|
|
define(`all_untrusted_apps',`{ untrusted_app_all untrusted_app_25 untrusted_app ephemeral_app isolated_app mediaprovider }')
|
2017-01-28 00:53:38 +01:00
|
|
|
# Receive or send uevent messages.
|
2017-02-06 19:31:45 +01:00
|
|
|
neverallow all_untrusted_apps domain:netlink_kobject_uevent_socket *;
|
2017-01-28 00:53:38 +01:00
|
|
|
|
|
|
|
# Receive or send generic netlink messages
|
2017-02-06 19:31:45 +01:00
|
|
|
neverallow all_untrusted_apps domain:netlink_socket *;
|
2017-01-28 00:53:38 +01:00
|
|
|
|
|
|
|
# Too much leaky information in debugfs. It's a security
|
|
|
|
# best practice to ensure these files aren't readable.
|
2017-02-06 19:31:45 +01:00
|
|
|
neverallow all_untrusted_apps debugfs_type:file read;
|
2017-01-28 00:53:38 +01:00
|
|
|
|
|
|
|
# Do not allow untrusted apps to register services.
|
|
|
|
# Only trusted components of Android should be registering
|
|
|
|
# services.
|
2017-02-06 19:31:45 +01:00
|
|
|
neverallow all_untrusted_apps service_manager_type:service_manager add;
|
2017-01-28 00:53:38 +01:00
|
|
|
|
|
|
|
# Do not allow untrusted apps to connect to the property service
|
|
|
|
# or set properties. b/10243159
|
2017-04-11 01:57:48 +02:00
|
|
|
neverallow { all_untrusted_apps -mediaprovider } property_socket:sock_file write;
|
|
|
|
neverallow { all_untrusted_apps -mediaprovider } init:unix_stream_socket connectto;
|
|
|
|
neverallow { all_untrusted_apps -mediaprovider } property_type:property_service set;
|
2017-01-28 00:53:38 +01:00
|
|
|
|
|
|
|
# Do not allow untrusted apps 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 an untrusted app is allowed fork permission to itself.
|
2017-02-06 19:31:45 +01:00
|
|
|
neverallow all_untrusted_apps mlstrustedsubject:process fork;
|
2017-01-28 00:53:38 +01:00
|
|
|
|
|
|
|
# Do not allow untrusted apps to hard link to any files.
|
|
|
|
# In particular, if an 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 apps never have this
|
|
|
|
# capability.
|
2017-02-06 19:31:45 +01:00
|
|
|
neverallow all_untrusted_apps file_type:file link;
|
2017-01-28 00:53:38 +01:00
|
|
|
|
|
|
|
# Do not allow untrusted apps to access network MAC address file
|
2017-02-06 19:31:45 +01:00
|
|
|
neverallow all_untrusted_apps sysfs_mac_address:file no_rw_file_perms;
|
2017-01-28 00:53:38 +01:00
|
|
|
|
|
|
|
# Restrict socket ioctls. Either 1. disallow privileged ioctls, 2. disallow the
|
|
|
|
# ioctl permission, or 3. disallow the socket class.
|
2017-02-06 19:31:45 +01:00
|
|
|
neverallowxperm all_untrusted_apps domain:{ rawip_socket tcp_socket udp_socket } ioctl priv_sock_ioctls;
|
|
|
|
neverallow all_untrusted_apps *:{ netlink_route_socket netlink_selinux_socket } ioctl;
|
|
|
|
neverallow all_untrusted_apps *:{
|
2017-01-28 00:53:38 +01:00
|
|
|
socket netlink_socket packet_socket key_socket appletalk_socket
|
2017-02-06 20:14:58 +01:00
|
|
|
netlink_tcpdiag_socket netlink_nflog_socket
|
|
|
|
netlink_xfrm_socket netlink_audit_socket
|
2017-01-28 00:53:38 +01:00
|
|
|
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
|
|
|
|
} *;
|
|
|
|
|
|
|
|
# Do not allow untrusted apps access to /cache
|
2017-04-11 01:57:48 +02:00
|
|
|
neverallow { all_untrusted_apps -mediaprovider } { cache_file cache_recovery_file }:dir ~{ r_dir_perms };
|
|
|
|
neverallow { all_untrusted_apps -mediaprovider } { cache_file cache_recovery_file }:file ~{ read getattr };
|
2017-01-28 00:53:38 +01:00
|
|
|
|
|
|
|
# Do not allow untrusted apps 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.
|
2017-04-11 01:57:48 +02:00
|
|
|
neverallow { all_untrusted_apps -mediaprovider } {
|
2017-01-28 00:53:38 +01:00
|
|
|
fs_type
|
|
|
|
-fuse # sdcard
|
|
|
|
-sdcardfs # sdcard
|
|
|
|
-vfat
|
|
|
|
file_type
|
|
|
|
-app_data_file # The apps sandbox itself
|
|
|
|
-media_rw_data_file # Internal storage. Known that apps can
|
|
|
|
# leave artfacts here after uninstall.
|
|
|
|
-user_profile_data_file # Access to profile files
|
|
|
|
userdebug_or_eng(`
|
|
|
|
-method_trace_data_file # only on ro.debuggable=1
|
|
|
|
-coredump_file # userdebug/eng only
|
|
|
|
')
|
|
|
|
}:dir_file_class_set { create unlink };
|
|
|
|
|
|
|
|
# Do not allow untrusted apps to directly open tun_device
|
2017-02-06 19:31:45 +01:00
|
|
|
neverallow all_untrusted_apps tun_device:chr_file open;
|
2017-01-28 00:53:38 +01:00
|
|
|
|
|
|
|
# Only allow appending to /data/anr/traces.txt (b/27853304, b/18340553)
|
2017-02-06 19:31:45 +01:00
|
|
|
neverallow all_untrusted_apps anr_data_file:file ~{ open append };
|
|
|
|
neverallow all_untrusted_apps anr_data_file:dir ~search;
|
2017-01-28 00:53:38 +01:00
|
|
|
|
|
|
|
# Avoid reads from generically labeled /proc files
|
|
|
|
# Create a more specific label if needed
|
2017-02-06 19:31:45 +01:00
|
|
|
neverallow all_untrusted_apps proc:file { no_rw_file_perms no_x_file_perms };
|
2017-03-14 19:42:03 +01:00
|
|
|
|
|
|
|
# Do not allow untrusted apps access to preloads data files
|
|
|
|
neverallow all_untrusted_apps preloads_data_file:file no_rw_file_perms;
|
2017-03-22 18:35:24 +01:00
|
|
|
|
|
|
|
# Locking of files on /system could lead to denial of service attacks
|
|
|
|
# against privileged system components
|
|
|
|
neverallow all_untrusted_apps system_file:file lock;
|