Nick Kralevich | 4be3190 | 2014-07-01 13:59:50 -0700 | [diff] [blame] | 1 | # Input selectors: |
Michael Peck | f54b362 | 2017-02-14 09:48:57 -0800 | [diff] [blame] | 2 | # isSystemServer (boolean) |
| 3 | # isEphemeralApp (boolean) |
Chad Brubaker | a782a81 | 2017-02-06 10:31:45 -0800 | [diff] [blame] | 4 | # isV2App (boolean) |
Michael Peck | f54b362 | 2017-02-14 09:48:57 -0800 | [diff] [blame] | 5 | # isOwner (boolean) |
| 6 | # user (string) |
| 7 | # seinfo (string) |
| 8 | # name (string) |
| 9 | # path (string) |
| 10 | # isPrivApp (boolean) |
| 11 | # minTargetSdkVersion (unsigned integer) |
Yabin Cui | ffa2b61 | 2018-11-02 14:34:06 -0700 | [diff] [blame] | 12 | # fromRunAs (boolean) |
Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 13 | # isSystemServer=true can only be used once. |
Stephen Smalley | dd31ddf | 2012-07-27 17:08:21 -0400 | [diff] [blame] | 14 | # An unspecified isSystemServer defaults to false. |
Chad Brubaker | 06cf31e | 2016-10-06 13:15:44 -0700 | [diff] [blame] | 15 | # isEphemeralApp=true will match apps marked by PackageManager as Ephemeral |
Chad Brubaker | a782a81 | 2017-02-06 10:31:45 -0800 | [diff] [blame] | 16 | # isV2App=true will match apps in the v2 app sandbox. |
Stephen Smalley | ff4db91 | 2014-09-15 15:16:06 -0400 | [diff] [blame] | 17 | # isOwner=true will only match for the owner/primary user. |
| 18 | # isOwner=false will only match for secondary users. |
| 19 | # If unspecified, the entry can match either case. |
Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 20 | # An unspecified string selector will match any value. |
| 21 | # A user string selector that ends in * will perform a prefix match. |
Stephen Smalley | 3ac1d26 | 2012-09-24 10:16:03 -0400 | [diff] [blame] | 22 | # user=_app will match any regular app UID. |
| 23 | # user=_isolated will match any isolated service UID. |
Jeff Vander Stoep | ee9c0b5 | 2015-10-05 09:15:04 -0700 | [diff] [blame] | 24 | # isPrivApp=true will only match for applications preinstalled in |
| 25 | # /system/priv-app. |
Michael Peck | f54b362 | 2017-02-14 09:48:57 -0800 | [diff] [blame] | 26 | # minTargetSdkVersion will match applications with a targetSdkVersion |
| 27 | # greater than or equal to the specified value. If unspecified, |
| 28 | # it has a default value of 0. |
Yabin Cui | ffa2b61 | 2018-11-02 14:34:06 -0700 | [diff] [blame] | 29 | # fromRunAs=true means the setcontext request is from run-as. Default is false. |
Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 30 | # All specified input selectors in an entry must match (i.e. logical AND). |
| 31 | # Matching is case-insensitive. |
Nick Kralevich | 4be3190 | 2014-07-01 13:59:50 -0700 | [diff] [blame] | 32 | # |
Alex Klyubin | e392020 | 2016-12-19 10:18:19 -0800 | [diff] [blame] | 33 | # Precedence rules (see external/selinux/libselinux/src/android/android.c seapp_context_cmp()): |
Michael Peck | f54b362 | 2017-02-14 09:48:57 -0800 | [diff] [blame] | 34 | # (1) isSystemServer=true before isSystemServer=false. |
| 35 | # (2) Specified isEphemeralApp= before unspecified isEphemeralApp= boolean. |
Chad Brubaker | a782a81 | 2017-02-06 10:31:45 -0800 | [diff] [blame] | 36 | # (3) Specified isV2App= before unspecified isV2App= boolean. |
| 37 | # (4) Specified isOwner= before unspecified isOwner= boolean. |
| 38 | # (5) Specified user= string before unspecified user= string. |
| 39 | # (6) Fixed user= string before user= prefix (i.e. ending in *). |
| 40 | # (7) Longer user= prefix before shorter user= prefix. |
| 41 | # (8) Specified seinfo= string before unspecified seinfo= string. |
Michael Peck | f54b362 | 2017-02-14 09:48:57 -0800 | [diff] [blame] | 42 | # ':' character is reserved and may not be used. |
Chad Brubaker | a782a81 | 2017-02-06 10:31:45 -0800 | [diff] [blame] | 43 | # (9) Specified name= string before unspecified name= string. |
| 44 | # (10) Specified path= string before unspecified path= string. |
| 45 | # (11) Specified isPrivApp= before unspecified isPrivApp= boolean. |
| 46 | # (12) Higher value of minTargetSdkVersion= before lower value of minTargetSdkVersion= |
Michael Peck | f54b362 | 2017-02-14 09:48:57 -0800 | [diff] [blame] | 47 | # integer. Note that minTargetSdkVersion= defaults to 0 if unspecified. |
Yabin Cui | ffa2b61 | 2018-11-02 14:34:06 -0700 | [diff] [blame] | 48 | # (13) fromRunAs=true before fromRunAs=false. |
Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 49 | # |
| 50 | # Outputs: |
Michael Peck | f54b362 | 2017-02-14 09:48:57 -0800 | [diff] [blame] | 51 | # domain (string) |
| 52 | # type (string) |
| 53 | # levelFrom (string; one of none, all, app, or user) |
| 54 | # level (string) |
Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 55 | # Only entries that specify domain= will be used for app process labeling. |
| 56 | # Only entries that specify type= will be used for app directory labeling. |
Stephen Smalley | 3808414 | 2012-11-28 10:46:18 -0500 | [diff] [blame] | 57 | # levelFrom=user is only supported for _app or _isolated UIDs. |
| 58 | # levelFrom=app or levelFrom=all is only supported for _app UIDs. |
Nick Kralevich | 4be3190 | 2014-07-01 13:59:50 -0700 | [diff] [blame] | 59 | # level may be used to specify a fixed level for any UID. |
Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 60 | # |
William Roberts | 81e1f90 | 2015-06-03 21:57:47 -0700 | [diff] [blame] | 61 | # |
| 62 | # Neverallow Assertions |
| 63 | # Additional compile time assertion checks can be added as well. The assertion |
| 64 | # rules are lines beginning with the keyword neverallow. Full support for PCRE |
| 65 | # regular expressions exists on all input and output selectors. Neverallow |
| 66 | # rules are never output to the built seapp_contexts file. Like all keywords, |
| 67 | # neverallows are case-insensitive. A neverallow is asserted when all key value |
| 68 | # inputs are matched on a key value rule line. |
| 69 | # |
| 70 | |
| 71 | # only the system server can be in system_server domain |
| 72 | neverallow isSystemServer=false domain=system_server |
| 73 | neverallow isSystemServer="" domain=system_server |
| 74 | |
| 75 | # system domains should never be assigned outside of system uid |
| 76 | neverallow user=((?!system).)* domain=system_app |
| 77 | neverallow user=((?!system).)* type=system_app_data_file |
| 78 | |
| 79 | # anything with a non-known uid with a specified name should have a specified seinfo |
| 80 | neverallow user=_app name=.* seinfo="" |
| 81 | neverallow user=_app name=.* seinfo=default |
| 82 | |
| 83 | # neverallow shared relro to any other domain |
| 84 | # and neverallow any other uid into shared_relro |
| 85 | neverallow user=shared_relro domain=((?!shared_relro).)* |
| 86 | neverallow user=((?!shared_relro).)* domain=shared_relro |
| 87 | |
| 88 | # neverallow non-isolated uids into isolated_app domain |
| 89 | # and vice versa |
| 90 | neverallow user=_isolated domain=((?!isolated_app).)* |
| 91 | neverallow user=((?!_isolated).)* domain=isolated_app |
| 92 | |
| 93 | # uid shell should always be in shell domain, however non-shell |
| 94 | # uid's can be in shell domain |
| 95 | neverallow user=shell domain=((?!shell).)* |
| 96 | |
Max Bires | 77d41f7 | 2018-01-24 21:17:18 +0000 | [diff] [blame] | 97 | # only the package named com.android.shell can run in the shell domain |
| 98 | neverallow domain=shell name=((?!com\.android\.shell).)* |
| 99 | neverallow user=shell name=((?!com\.android\.shell).)* |
| 100 | |
Chad Brubaker | 06cf31e | 2016-10-06 13:15:44 -0700 | [diff] [blame] | 101 | # Ephemeral Apps must run in the ephemeral_app domain |
| 102 | neverallow isEphemeralApp=true domain=((?!ephemeral_app).)* |
Jeff Vander Stoep | 400d3ac | 2015-10-30 12:43:19 -0700 | [diff] [blame] | 103 | |
Nick Kralevich | caf42d6 | 2018-10-04 10:57:29 -0700 | [diff] [blame] | 104 | isSystemServer=true domain=system_server_startup |
| 105 | |
Max Bires | 4ea5569 | 2017-12-11 16:19:23 -0800 | [diff] [blame] | 106 | user=_app seinfo=platform name=com.android.traceur domain=traceur_app type=app_data_file levelFrom=all |
William Roberts | 92dfa31 | 2014-09-29 10:29:48 -0700 | [diff] [blame] | 107 | user=system seinfo=platform domain=system_app type=system_app_data_file |
| 108 | user=bluetooth seinfo=platform domain=bluetooth type=bluetooth_data_file |
Remi NGUYEN VAN | aed7180 | 2019-01-08 17:29:38 +0900 | [diff] [blame] | 109 | user=network_stack seinfo=platform name=com.android.mainline.networkstack domain=network_stack levelFrom=all |
William Roberts | 92dfa31 | 2014-09-29 10:29:48 -0700 | [diff] [blame] | 110 | user=nfc seinfo=platform domain=nfc type=nfc_data_file |
Ruchi Kandoi | 8a2b4a7 | 2018-01-04 10:33:20 -0800 | [diff] [blame] | 111 | user=secure_element seinfo=platform domain=secure_element levelFrom=all |
William Roberts | 92dfa31 | 2014-09-29 10:29:48 -0700 | [diff] [blame] | 112 | user=radio seinfo=platform domain=radio type=radio_data_file |
Nick Kralevich | b5ffbb7 | 2015-01-07 13:52:43 -0800 | [diff] [blame] | 113 | user=shared_relro domain=shared_relro |
Max Bires | 77d41f7 | 2018-01-24 21:17:18 +0000 | [diff] [blame] | 114 | user=shell seinfo=platform domain=shell name=com.android.shell type=shell_data_file |
Robert Sesek | bacb19b | 2018-01-30 10:54:33 -0500 | [diff] [blame] | 115 | user=webview_zygote seinfo=webview_zygote domain=webview_zygote |
Jeff Vander Stoep | 6231b4d | 2017-12-17 20:55:12 -0800 | [diff] [blame] | 116 | user=_isolated domain=isolated_app levelFrom=all |
Jerry Zhang | 9f152d9 | 2017-04-10 16:57:48 -0700 | [diff] [blame] | 117 | user=_app seinfo=media domain=mediaprovider name=android.process.media type=app_data_file levelFrom=user |
Stephen Smalley | a833763 | 2014-09-11 14:07:28 -0400 | [diff] [blame] | 118 | user=_app seinfo=platform domain=platform_app type=app_data_file levelFrom=user |
Jeff Vander Stoep | 6231b4d | 2017-12-17 20:55:12 -0800 | [diff] [blame] | 119 | user=_app isV2App=true isEphemeralApp=true domain=ephemeral_app type=app_data_file levelFrom=all |
Nick Kralevich | 5d17551 | 2018-09-12 12:30:32 -0700 | [diff] [blame] | 120 | user=_app isPrivApp=true domain=priv_app type=privapp_data_file levelFrom=user |
Yabin Cui | 5dc2c8c | 2018-11-02 11:12:43 -0700 | [diff] [blame] | 121 | user=_app minTargetSdkVersion=29 domain=untrusted_app type=app_data_file levelFrom=all |
| 122 | user=_app minTargetSdkVersion=28 domain=untrusted_app_27 type=app_data_file levelFrom=all |
Jeff Vander Stoep | 6231b4d | 2017-12-17 20:55:12 -0800 | [diff] [blame] | 123 | user=_app minTargetSdkVersion=26 domain=untrusted_app_27 type=app_data_file levelFrom=user |
Jeff Vander Stoep | bacb6d7 | 2017-02-13 13:33:27 -0800 | [diff] [blame] | 124 | user=_app domain=untrusted_app_25 type=app_data_file levelFrom=user |
Yabin Cui | 770a4f6 | 2019-01-07 16:37:24 -0800 | [diff] [blame] | 125 | user=_app minTargetSdkVersion=28 fromRunAs=true domain=runas_app levelFrom=all |
| 126 | user=_app fromRunAs=true domain=runas_app levelFrom=user |