app.te 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. ###
  2. ### Domain for all zygote spawned apps
  3. ###
  4. ### This file is the base policy for all zygote spawned apps.
  5. ### Other policy files, such as isolated_app.te, untrusted_app.te, etc
  6. ### extend from this policy. Only policies which should apply to ALL
  7. ### zygote spawned apps should be added here.
  8. ###
  9. type appdomain_tmpfs, file_type;
  10. # WebView and other application-specific JIT compilers
  11. allow appdomain self:process execmem;
  12. allow appdomain ashmem_device:chr_file execute;
  13. # Receive and use open file descriptors inherited from zygote.
  14. allow appdomain zygote:fd use;
  15. # gdbserver for ndk-gdb reads the zygote.
  16. # valgrind needs mmap exec for zygote
  17. allow appdomain zygote_exec:file rx_file_perms;
  18. # Notify zygote of death;
  19. allow appdomain zygote:process sigchld;
  20. # Read /data/dalvik-cache.
  21. allow appdomain dalvikcache_data_file:dir { search getattr };
  22. allow appdomain dalvikcache_data_file:file r_file_perms;
  23. # Read the /sdcard and /mnt/sdcard symlinks
  24. allow { appdomain -isolated_app } rootfs:lnk_file r_file_perms;
  25. allow { appdomain -isolated_app } tmpfs:lnk_file r_file_perms;
  26. # Search /storage/emulated tmpfs mount.
  27. allow appdomain tmpfs:dir r_dir_perms;
  28. # Notify zygote of the wrapped process PID when using --invoke-with.
  29. allow appdomain zygote:fifo_file write;
  30. userdebug_or_eng(`
  31. # Allow apps to create and write method traces in /data/misc/trace.
  32. allow appdomain method_trace_data_file:dir w_dir_perms;
  33. allow appdomain method_trace_data_file:file { create w_file_perms };
  34. ')
  35. # Notify shell and adbd of death when spawned via runas for ndk-gdb.
  36. allow appdomain shell:process sigchld;
  37. allow appdomain adbd:process sigchld;
  38. # child shell or gdbserver pty access for runas.
  39. allow appdomain devpts:chr_file { getattr read write ioctl };
  40. # Use pipes and sockets provided by system_server via binder or local socket.
  41. allow appdomain system_server:fd use;
  42. allow appdomain system_server:fifo_file rw_file_perms;
  43. allow appdomain system_server:unix_stream_socket { read write setopt getattr getopt shutdown };
  44. allow appdomain system_server:tcp_socket { read write getattr getopt shutdown };
  45. # For AppFuse.
  46. allow appdomain vold:fd use;
  47. # Communication with other apps via fifos
  48. allow appdomain appdomain:fifo_file rw_file_perms;
  49. # Communicate with surfaceflinger.
  50. allow appdomain surfaceflinger:unix_stream_socket { read write setopt getattr getopt shutdown };
  51. # App sandbox file accesses.
  52. allow { appdomain -isolated_app } { app_data_file privapp_data_file }:dir create_dir_perms;
  53. allow { appdomain -isolated_app } { app_data_file privapp_data_file }:file create_file_perms;
  54. # Traverse into expanded storage
  55. allow appdomain mnt_expand_file:dir r_dir_perms;
  56. # Keychain and user-trusted credentials
  57. r_dir_file(appdomain, keychain_data_file)
  58. allow appdomain misc_user_data_file:dir r_dir_perms;
  59. allow appdomain misc_user_data_file:file r_file_perms;
  60. # TextClassifier
  61. r_dir_file({ appdomain -isolated_app }, textclassifier_data_file)
  62. # Access to OEM provided data and apps
  63. allow appdomain oemfs:dir r_dir_perms;
  64. allow appdomain oemfs:file rx_file_perms;
  65. # Execute the shell or other system executables.
  66. allow { appdomain -ephemeral_app } shell_exec:file rx_file_perms;
  67. allow { appdomain -ephemeral_app } toolbox_exec:file rx_file_perms;
  68. allow appdomain system_file:file x_file_perms;
  69. not_full_treble(`allow { appdomain -ephemeral_app } vendor_file:file x_file_perms;')
  70. # Renderscript needs the ability to read directories on /system
  71. allow appdomain system_file:dir r_dir_perms;
  72. allow appdomain system_file:lnk_file { getattr open read };
  73. # Renderscript specific permissions to open /system/vendor/lib64.
  74. not_full_treble(`
  75. allow appdomain vendor_file_type:dir r_dir_perms;
  76. allow appdomain vendor_file_type:lnk_file { getattr open read };
  77. ')
  78. full_treble_only(`
  79. # For looking up Renderscript vendor drivers
  80. allow { appdomain -isolated_app } vendor_file:dir { open read };
  81. ')
  82. # Allow apps access to /vendor/app except for privileged
  83. # apps which cannot be in /vendor.
  84. r_dir_file({ appdomain -ephemeral_app }, vendor_app_file)
  85. allow { appdomain -ephemeral_app } vendor_app_file:file execute;
  86. # Allow apps access to /vendor/overlay
  87. r_dir_file(appdomain, vendor_overlay_file)
  88. # Allow apps access to /vendor/framework
  89. # for vendor provided libraries.
  90. r_dir_file(appdomain, vendor_framework_file)
  91. # Allow apps read / execute access to vendor public libraries.
  92. allow appdomain vendor_public_lib_file:dir r_dir_perms;
  93. allow appdomain vendor_public_lib_file:file { execute read open getattr map };
  94. # Read/write wallpaper file (opened by system).
  95. allow appdomain wallpaper_file:file { getattr read write map };
  96. # Read/write cached ringtones (opened by system).
  97. allow appdomain ringtone_file:file { getattr read write map };
  98. # Read ShortcutManager icon files (opened by system).
  99. allow appdomain shortcut_manager_icons:file { getattr read map };
  100. # Read icon file (opened by system).
  101. allow appdomain icon_file:file { getattr read map };
  102. # Old stack dumping scheme : append to a global trace file (/data/anr/traces.txt).
  103. #
  104. # TODO: All of these permissions except for anr_data_file:file append can be
  105. # withdrawn once we've switched to the new stack dumping mechanism, see b/32064548
  106. # and the rules below.
  107. allow appdomain anr_data_file:dir search;
  108. allow appdomain anr_data_file:file { open append };
  109. # New stack dumping scheme : request an output FD from tombstoned via a unix
  110. # domain socket.
  111. #
  112. # Allow apps to connect and write to the tombstoned java trace socket in
  113. # order to dump their traces. Also allow them to append traces to pipes
  114. # created by dumptrace. (Also see the rules below where they are given
  115. # additional permissions to dumpstate pipes for other aspects of bug report
  116. # creation).
  117. unix_socket_connect(appdomain, tombstoned_java_trace, tombstoned)
  118. allow appdomain tombstoned:fd use;
  119. allow appdomain dumpstate:fifo_file append;
  120. allow appdomain incidentd:fifo_file append;
  121. # Allow apps to send dump information to dumpstate
  122. allow appdomain dumpstate:fd use;
  123. allow appdomain dumpstate:unix_stream_socket { read write getopt getattr shutdown };
  124. allow appdomain dumpstate:fifo_file { write getattr };
  125. allow appdomain shell_data_file:file { write getattr };
  126. # Allow apps to send dump information to incidentd
  127. allow appdomain incidentd:fd use;
  128. allow appdomain incidentd:fifo_file { write getattr };
  129. # Allow apps to send information to statsd socket.
  130. unix_socket_send(appdomain, statsdw, statsd)
  131. # Write profiles /data/misc/profiles
  132. allow appdomain user_profile_data_file:dir { search write add_name };
  133. allow appdomain user_profile_data_file:file create_file_perms;
  134. # Send heap dumps to system_server via an already open file descriptor
  135. # % adb shell am set-watch-heap com.android.systemui 1048576
  136. # % adb shell dumpsys procstats --start-testing
  137. # debuggable builds only.
  138. userdebug_or_eng(`
  139. allow appdomain heapdump_data_file:file append;
  140. ')
  141. # /proc/net access.
  142. # TODO(b/9496886) Audit access for removal.
  143. # proc_net access for the negated domains below is granted (or not) in their
  144. # individual .te files.
  145. r_dir_file({
  146. appdomain
  147. -ephemeral_app
  148. -isolated_app
  149. -platform_app
  150. -priv_app
  151. -shell
  152. -system_app
  153. -untrusted_app_all
  154. }, proc_net_type)
  155. # audit access for all these non-core app domains.
  156. userdebug_or_eng(`
  157. auditallow {
  158. appdomain
  159. -ephemeral_app
  160. -isolated_app
  161. -platform_app
  162. -priv_app
  163. -shell
  164. -su
  165. -system_app
  166. -untrusted_app_all
  167. } proc_net_type:{ dir file lnk_file } { getattr open read };
  168. ')
  169. # Grant GPU access to all processes started by Zygote.
  170. # They need that to render the standard UI.
  171. allow { appdomain -isolated_app } gpu_device:chr_file rw_file_perms;
  172. # Use the Binder.
  173. binder_use(appdomain)
  174. # Perform binder IPC to binder services.
  175. binder_call(appdomain, binderservicedomain)
  176. # Perform binder IPC to other apps.
  177. binder_call(appdomain, appdomain)
  178. # Perform binder IPC to ephemeral apps.
  179. binder_call(appdomain, ephemeral_app)
  180. # Talk with graphics composer fences
  181. allow appdomain hal_graphics_composer:fd use;
  182. # Already connected, unnamed sockets being passed over some other IPC
  183. # hence no sock_file or connectto permission. This appears to be how
  184. # Chrome works, may need to be updated as more apps using isolated services
  185. # are examined.
  186. allow appdomain appdomain:unix_stream_socket { getopt getattr read write shutdown };
  187. # Backup ability for every app. BMS opens and passes the fd
  188. # to any app that has backup ability. Hence, no open permissions here.
  189. allow appdomain backup_data_file:file { read write getattr map };
  190. allow appdomain cache_backup_file:file { read write getattr map };
  191. allow appdomain cache_backup_file:dir getattr;
  192. # Backup ability using 'adb backup'
  193. allow appdomain system_data_file:lnk_file r_file_perms;
  194. allow appdomain system_data_file:file { getattr read map };
  195. # Allow read/stat of /data/media files passed by Binder or local socket IPC.
  196. allow { appdomain -isolated_app } media_rw_data_file:file { read getattr };
  197. # Read and write /data/data/com.android.providers.telephony files passed over Binder.
  198. allow { appdomain -isolated_app } radio_data_file:file { read write getattr };
  199. # Allow access to external storage; we have several visible mount points under /storage
  200. # and symlinks to primary storage at places like /storage/sdcard0 and /mnt/user/0/primary
  201. allow { appdomain -isolated_app -ephemeral_app } storage_file:dir r_dir_perms;
  202. allow { appdomain -isolated_app -ephemeral_app } storage_file:lnk_file r_file_perms;
  203. allow { appdomain -isolated_app -ephemeral_app } mnt_user_file:dir r_dir_perms;
  204. allow { appdomain -isolated_app -ephemeral_app } mnt_user_file:lnk_file r_file_perms;
  205. # Read/write visible storage
  206. allow { appdomain -isolated_app -ephemeral_app } sdcard_type:dir create_dir_perms;
  207. allow { appdomain -isolated_app -ephemeral_app } sdcard_type:file create_file_perms;
  208. # This should be removed if sdcardfs is modified to alter the secontext for its
  209. # accesses to the underlying FS.
  210. allow { appdomain -isolated_app -ephemeral_app } media_rw_data_file:dir create_dir_perms;
  211. allow { appdomain -isolated_app -ephemeral_app } media_rw_data_file:file create_file_perms;
  212. # Allow apps to use the USB Accessory interface.
  213. # http://developer.android.com/guide/topics/connectivity/usb/accessory.html
  214. #
  215. # USB devices are first opened by the system server (USBDeviceManagerService)
  216. # and the file descriptor is passed to the right Activity via binder.
  217. allow { appdomain -isolated_app -ephemeral_app } usb_device:chr_file { read write getattr ioctl };
  218. allow { appdomain -isolated_app -ephemeral_app } usbaccessory_device:chr_file { read write getattr };
  219. # For art.
  220. allow appdomain dalvikcache_data_file:file execute;
  221. allow appdomain dalvikcache_data_file:lnk_file r_file_perms;
  222. # Allow any app to read shared RELRO files.
  223. allow appdomain shared_relro_file:dir search;
  224. allow appdomain shared_relro_file:file r_file_perms;
  225. # Allow apps to read/execute installed binaries
  226. allow appdomain apk_data_file:dir r_dir_perms;
  227. allow appdomain apk_data_file:file rx_file_perms;
  228. # /data/resource-cache
  229. allow appdomain resourcecache_data_file:file r_file_perms;
  230. allow appdomain resourcecache_data_file:dir r_dir_perms;
  231. # logd access
  232. read_logd(appdomain)
  233. control_logd({ appdomain -ephemeral_app })
  234. # application inherit logd write socket (urge is to deprecate this long term)
  235. allow appdomain zygote:unix_dgram_socket write;
  236. allow { appdomain -isolated_app -ephemeral_app } keystore:keystore_key { get_state get insert delete exist list sign verify };
  237. use_keystore({ appdomain -isolated_app -ephemeral_app })
  238. allow appdomain console_device:chr_file { read write };
  239. # only allow unprivileged socket ioctl commands
  240. allowxperm { appdomain -bluetooth } self:{ rawip_socket tcp_socket udp_socket }
  241. ioctl { unpriv_sock_ioctls unpriv_tty_ioctls };
  242. allow { appdomain -isolated_app } ion_device:chr_file r_file_perms;
  243. # Allow AAudio apps to use shared memory file descriptors from the HAL
  244. allow { appdomain -isolated_app } hal_audio:fd use;
  245. # Allow app to access shared memory created by camera HAL1
  246. allow { appdomain -isolated_app } hal_camera:fd use;
  247. # RenderScript always-passthrough HAL
  248. allow { appdomain -isolated_app } hal_renderscript_hwservice:hwservice_manager find;
  249. allow appdomain same_process_hal_file:file { execute read open getattr map };
  250. # TODO: switch to meminfo service
  251. allow appdomain proc_meminfo:file r_file_perms;
  252. # For app fuse.
  253. allow appdomain app_fuse_file:file { getattr read append write };
  254. pdx_client({ appdomain -isolated_app -ephemeral_app }, display_client)
  255. pdx_client({ appdomain -isolated_app -ephemeral_app }, display_manager)
  256. pdx_client({ appdomain -isolated_app -ephemeral_app }, display_vsync)
  257. pdx_client({ appdomain -isolated_app -ephemeral_app }, performance_client)
  258. # Apps do not directly open the IPC socket for bufferhubd.
  259. pdx_use({ appdomain -isolated_app -ephemeral_app }, bufferhub_client)
  260. ###
  261. ### CTS-specific rules
  262. ###
  263. # For cts/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java.
  264. # testRunAsHasCorrectCapabilities
  265. allow appdomain runas_exec:file getattr;
  266. # Others are either allowed elsewhere or not desired.
  267. # Apps receive an open tun fd from the framework for
  268. # device traffic. Do not allow untrusted app to directly open tun_device
  269. allow { appdomain -isolated_app -ephemeral_app } tun_device:chr_file { read write getattr append ioctl };
  270. allowxperm { appdomain -isolated_app -ephemeral_app } tun_device:chr_file ioctl TUNGETIFF;
  271. # Connect to adbd and use a socket transferred from it.
  272. # This is used for e.g. adb backup/restore.
  273. allow appdomain adbd:unix_stream_socket connectto;
  274. allow appdomain adbd:fd use;
  275. allow appdomain adbd:unix_stream_socket { getattr getopt ioctl read write shutdown };
  276. allow appdomain cache_file:dir getattr;
  277. # Allow apps to run with asanwrapper.
  278. with_asan(`allow appdomain asanwrapper_exec:file rx_file_perms;')
  279. # Read access to FDs from the DropboxManagerService.
  280. allow appdomain dropbox_data_file:file { getattr read };
  281. # Read tmpfs types from these processes.
  282. allow appdomain audioserver_tmpfs:file { getattr map read write };
  283. allow appdomain system_server_tmpfs:file { getattr map read write };
  284. allow appdomain zygote_tmpfs:file { map read };
  285. # Allow vendor apps access to ashmemd to request /dev/ashmem fds.
  286. binder_call({ appdomain -coredomain }, ashmemd)
  287. ###
  288. ### Neverallow rules
  289. ###
  290. ### These are things that Android apps should NEVER be able to do
  291. ###
  292. # Superuser capabilities.
  293. # bluetooth requires net_admin and wake_alarm. network stack app requires net_admin.
  294. neverallow { appdomain -bluetooth -network_stack } self:capability_class_set *;
  295. # Block device access.
  296. neverallow appdomain dev_type:blk_file { read write };
  297. # Access to any of the following character devices.
  298. neverallow appdomain {
  299. audio_device
  300. camera_device
  301. dm_device
  302. radio_device
  303. rpmsg_device
  304. video_device
  305. }:chr_file { read write };
  306. # Note: Try expanding list of app domains in the future.
  307. neverallow { untrusted_app isolated_app shell } graphics_device:chr_file { read write };
  308. neverallow { appdomain -nfc } nfc_device:chr_file
  309. { read write };
  310. neverallow { appdomain -bluetooth } hci_attach_dev:chr_file
  311. { read write };
  312. neverallow appdomain tee_device:chr_file { read write };
  313. # Privileged netlink socket interfaces.
  314. neverallow appdomain
  315. domain:{
  316. netlink_tcpdiag_socket
  317. netlink_nflog_socket
  318. netlink_xfrm_socket
  319. netlink_audit_socket
  320. netlink_dnrt_socket
  321. } *;
  322. # These messages are broadcast messages from the kernel to userspace.
  323. # Do not allow the writing of netlink messages, which has been a source
  324. # of rooting vulns in the past.
  325. neverallow appdomain domain:netlink_kobject_uevent_socket { write append };
  326. # Sockets under /dev/socket that are not specifically typed.
  327. neverallow appdomain socket_device:sock_file write;
  328. # Unix domain sockets.
  329. neverallow appdomain adbd_socket:sock_file write;
  330. neverallow { appdomain -radio } rild_socket:sock_file write;
  331. # ptrace access to non-app domains.
  332. neverallow appdomain { domain -appdomain }:process ptrace;
  333. # The Android security model guarantees the confidentiality and integrity
  334. # of application data and execution state. Ptrace bypasses those
  335. # confidentiality guarantees. Disallow ptrace access from system components
  336. # to apps. Crash_dump is excluded, as it needs ptrace access to
  337. # produce stack traces. llkd is excluded, as it needs ptrace access to
  338. # inspect stack traces for live lock conditions.
  339. neverallow {
  340. domain
  341. -appdomain
  342. -crash_dump
  343. userdebug_or_eng(`-llkd')
  344. } appdomain:process ptrace;
  345. # Read or write access to /proc/pid entries for any non-app domain.
  346. # A different form of hidepid=2 like protections
  347. neverallow appdomain { domain -appdomain }:file no_w_file_perms;
  348. neverallow { appdomain -shell } { domain -appdomain }:file no_rw_file_perms;
  349. # signal access to non-app domains.
  350. # sigchld allowed for parent death notification.
  351. # signull allowed for kill(pid, 0) existence test.
  352. # All others prohibited.
  353. # -perfetto is to allow shell (which is an appdomain) to kill perfetto
  354. # (see private/shell.te).
  355. neverallow appdomain { domain -appdomain -perfetto }:process
  356. { sigkill sigstop signal };
  357. # Write to rootfs.
  358. neverallow appdomain rootfs:dir_file_class_set
  359. { create write setattr relabelfrom relabelto append unlink link rename };
  360. # Write to /system.
  361. neverallow appdomain system_file:dir_file_class_set
  362. { create write setattr relabelfrom relabelto append unlink link rename };
  363. # Write to entrypoint executables.
  364. neverallow appdomain exec_type:file
  365. { create write setattr relabelfrom relabelto append unlink link rename };
  366. # Write to system-owned parts of /data.
  367. # This is the default type for anything under /data not otherwise
  368. # specified in file_contexts. Define a different type for portions
  369. # that should be writable by apps.
  370. neverallow appdomain system_data_file:dir_file_class_set
  371. { create write setattr relabelfrom relabelto append unlink link rename };
  372. # Write to various other parts of /data.
  373. neverallow appdomain drm_data_file:dir_file_class_set
  374. { create write setattr relabelfrom relabelto append unlink link rename };
  375. neverallow { appdomain -platform_app }
  376. apk_data_file:dir_file_class_set
  377. { create write setattr relabelfrom relabelto append unlink link rename };
  378. neverallow { appdomain -platform_app }
  379. apk_tmp_file:dir_file_class_set
  380. { create write setattr relabelfrom relabelto append unlink link rename };
  381. neverallow { appdomain -platform_app }
  382. apk_private_data_file:dir_file_class_set
  383. { create write setattr relabelfrom relabelto append unlink link rename };
  384. neverallow { appdomain -platform_app }
  385. apk_private_tmp_file:dir_file_class_set
  386. { create write setattr relabelfrom relabelto append unlink link rename };
  387. neverallow { appdomain -shell }
  388. shell_data_file:dir_file_class_set
  389. { create setattr relabelfrom relabelto append unlink link rename };
  390. neverallow { appdomain -bluetooth }
  391. bluetooth_data_file:dir_file_class_set
  392. { create write setattr relabelfrom relabelto append unlink link rename };
  393. neverallow appdomain
  394. keystore_data_file:dir_file_class_set
  395. { create write setattr relabelfrom relabelto append unlink link rename };
  396. neverallow appdomain
  397. systemkeys_data_file:dir_file_class_set
  398. { create write setattr relabelfrom relabelto append unlink link rename };
  399. neverallow appdomain
  400. wifi_data_file:dir_file_class_set
  401. { create write setattr relabelfrom relabelto append unlink link rename };
  402. neverallow appdomain
  403. dhcp_data_file:dir_file_class_set
  404. { create write setattr relabelfrom relabelto append unlink link rename };
  405. # access tmp apk files
  406. neverallow { appdomain -untrusted_app_all -platform_app -priv_app }
  407. { apk_tmp_file apk_private_tmp_file }:dir_file_class_set *;
  408. neverallow untrusted_app_all { apk_tmp_file apk_private_tmp_file }:{ devfile_class_set dir fifo_file lnk_file sock_file } *;
  409. neverallow untrusted_app_all { apk_tmp_file apk_private_tmp_file }:file ~{ getattr read };
  410. # Access to factory files.
  411. neverallow appdomain efs_file:dir_file_class_set write;
  412. neverallow { appdomain -shell } efs_file:dir_file_class_set read;
  413. # Write to various pseudo file systems.
  414. neverallow { appdomain -bluetooth -nfc }
  415. sysfs:dir_file_class_set write;
  416. neverallow appdomain
  417. proc:dir_file_class_set write;
  418. # Access to syslog(2) or /proc/kmsg.
  419. neverallow appdomain kernel:system { syslog_read syslog_mod syslog_console };
  420. # SELinux is not an API for apps to use
  421. neverallow { appdomain -shell } *:security { compute_av check_context };
  422. neverallow { appdomain -shell } *:netlink_selinux_socket *;
  423. # Ability to perform any filesystem operation other than statfs(2).
  424. # i.e. no mount(2), unmount(2), etc.
  425. neverallow appdomain fs_type:filesystem ~getattr;
  426. # prevent creation/manipulation of globally readable symlinks
  427. neverallow appdomain {
  428. apk_data_file
  429. cache_file
  430. cache_recovery_file
  431. dev_type
  432. rootfs
  433. system_file
  434. tmpfs
  435. }:lnk_file no_w_file_perms;
  436. # Blacklist app domains not allowed to execute from /data
  437. neverallow {
  438. bluetooth
  439. isolated_app
  440. nfc
  441. radio
  442. shared_relro
  443. system_app
  444. } {
  445. data_file_type
  446. -dalvikcache_data_file
  447. -system_data_file # shared libs in apks
  448. -apk_data_file
  449. }:file no_x_file_perms;
  450. # Applications should use the activity model for receiving events
  451. neverallow {
  452. appdomain
  453. -shell # bugreport
  454. } input_device:chr_file ~getattr;
  455. # Do not allow access to Bluetooth-related system properties except for a few whitelisted domains.
  456. # neverallow rules for access to Bluetooth-related data files are above.
  457. neverallow {
  458. appdomain
  459. -bluetooth
  460. -system_app
  461. } { bluetooth_audio_hal_prop bluetooth_a2dp_offload_prop bluetooth_prop exported_bluetooth_prop }:file create_file_perms;
  462. # Apps cannot access proc_uid_time_in_state
  463. neverallow appdomain proc_uid_time_in_state:file *;
  464. # Apps cannot access proc_uid_concurrent_active_time
  465. neverallow appdomain proc_uid_concurrent_active_time:file *;
  466. # Apps cannot access proc_uid_concurrent_policy_time
  467. neverallow appdomain proc_uid_concurrent_policy_time:file *;
  468. # Apps cannot access proc_uid_cpupower
  469. neverallow appdomain proc_uid_cpupower:file *;
  470. # Apps may not read /proc/net/{tcp,tcp6,udp,udp6}. These files leak information across the
  471. # application boundary. VPN apps may use the ConnectivityManager.getConnectionOwnerUid() API to
  472. # perform UID lookups.
  473. neverallow { appdomain -shell } proc_net_tcp_udp:file *;
  474. # Apps cannot access bootstrap files. The bootstrap files are only for
  475. # extremely early processes (like init, etc.) which are started before
  476. # the runtime APEX is activated and Bionic libs are provided from there.
  477. # If app process accesses (or even load/execute) the bootstrap files,
  478. # it might cause problems such as ODR violation, etc.
  479. neverallow appdomain system_bootstrap_lib_file:file
  480. { open read write append execute execute_no_trans map };
  481. neverallow appdomain system_bootstrap_lib_file:dir
  482. { open read getattr search };